Libraryless. Click here for Pure Java version (8048L/54K/178K).
1 | !7 |
2 | |
3 | static Pair<SS, SS> text2tag, tag2answer; |
4 | static SS text2tag_symbols; |
5 | static new ThreadLocal<Session> session; |
6 | static ThreadLocal<L<S>> buttons = new ThreadLocal; |
7 | static Map<S, Int> spellMap; |
8 | static L<S> countries; |
9 | |
10 | concept Session { |
11 | S cookie; |
12 | Double lastDollarValue; |
13 | S lastQuestion; |
14 | } |
15 | |
16 | sbool debug; |
17 | |
18 | svoid setSession(S cookie) { |
19 | session.set(uniq_sync(Session, +cookie)); |
20 | } |
21 | |
22 | svoid clearSession(S cookie) { |
23 | deleteConcepts(Session, +cookie); |
24 | } |
25 | |
26 | p { |
27 | db(); |
28 | |
29 | // load stuff |
30 | spellMap = loadSpellList(#1008389); |
31 | |
32 | veryBigConsole(); |
33 | bot(); |
34 | } |
35 | |
36 | sS returnQuestion(S q) { |
37 | cset(session!, lastQuestion := q); |
38 | ret q; |
39 | } |
40 | |
41 | sS answer(S s) { |
42 | if (session! == null) setSession("default"); |
43 | buttons.set(null); |
44 | if (creator() == null) if "debug" set debug; |
45 | |
46 | S lq = session->lastQuestion; |
47 | cset(session!, lastQuestion := null); |
48 | |
49 | if (eq(lq, "Would you like some tea?")) { |
50 | if "yes" ret "Here's your tea."; |
51 | if "no" ret "Very well then."; |
52 | } |
53 | |
54 | if "test buttons" { |
55 | buttons.set(ll("Yes", "No")); |
56 | ret returnQuestion("Would you like some tea?"); |
57 | } |
58 | |
59 | S _s = s; |
60 | s = levenAttract(spellMap, s); |
61 | if (neqic(s, _s)) print("Spell-correct => " + s); |
62 | |
63 | ret "Sorry, I didn't understand that"; |
64 | } |
65 | |
66 | sS initialMessage() { |
67 | ret "Stefan's Hypercube Bot here. What's up?"; |
68 | } |
Began life as a copy of #1008347
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1008534 |
Snippet name: | Stefan's Thought Bot [dev.] |
Eternal ID of this version: | #1008534/3 |
Text MD5: | 9425357f12bdb3d0fb729ae3f7e5149c |
Transpilation MD5: | 67c91b8931d9258ec14d517418e081f4 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-06-01 17:19:15 |
Source code size: | 1360 bytes / 68 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 490 / 914 |
Version history: | 2 change(s) |
Referenced in: | [show references] |