Download Jar. Uses 3874K of libraries. Click here for Pure Java version (21817L/156K).
1 | !7 |
2 | |
3 | sS yesText = [[ |
4 | y |
5 | yes |
6 | yeah |
7 | y |
8 | yup |
9 | yo |
10 | correct |
11 | sure |
12 | ok |
13 | affirmative |
14 | |
15 | ja |
16 | ok |
17 | richtig |
18 | gut |
19 | mach das |
20 | ja ich will |
21 | bitte |
22 | ist so |
23 | isso |
24 | jau |
25 | jawohl |
26 | stimmt |
27 | ]]; |
28 | |
29 | sS noText = [[ |
30 | no |
31 | n |
32 | nope |
33 | negative |
34 | don't do that |
35 | nay |
36 | |
37 | nein |
38 | nö |
39 | negativ |
40 | lass das |
41 | ]]; |
42 | |
43 | static Set<S> yesLiterals = ciSet(), noLiterals = ciSet(); |
44 | |
45 | static Bool algo_0_1(S s) { |
46 | if (yesLiterals.contains(s)) true; |
47 | if (noLiterals.contains(s)) false; |
48 | null; |
49 | } |
50 | |
51 | static Bool algo_0_2(S s) { |
52 | s = trim(s); |
53 | try bool algo_0_1(s); |
54 | S s2 = collapseWord(s); |
55 | if (neq(s, s2)) |
56 | try bool algo_0_1(s2); |
57 | null; |
58 | } |
59 | |
60 | static Bool algo_0_3(S s) { |
61 | try bool algo_0_2(s); |
62 | S s2 = firstWord(s); |
63 | if (neq(s, s2)) |
64 | try bool algo_0_2(s); |
65 | null; |
66 | } |
67 | |
68 | p { |
69 | autoRestart(); |
70 | independentSmartBot(); |
71 | onNewTriple(f onTriple); |
72 | sahara(); |
73 | consoleHeight(500); |
74 | showMessagesInGerman(true); |
75 | logModuleOutput(); |
76 | readLinePrefix("[] Eingabe: "); |
77 | addAll_withCollapsed(yesLiterals, tlftj(yesText)); |
78 | addAll_withCollapsed(noLiterals, tlftj(noText)); |
79 | for (T3<S> t : triplesWithB("heißt")) onTriple(t); |
80 | bot(); |
81 | centerBigConsole2(); |
82 | focusConsole(random(tossCoin() ? yesLiterals : noLiterals); |
83 | controls2_default(); |
84 | } |
85 | |
86 | svoid controls_feedback(S text) { |
87 | disableConsoleInput(); |
88 | hideControls2(); |
89 | showControls(withCenteredTitle("Ich glaube:", |
90 | vstackWithSpacing(setFontSize(15, jcenteredBoldLabel(text)), |
91 | centeredButtons( |
92 | "Das ist korrekt", r { |
93 | print("=> KORREKT"); |
94 | uploadOutputSinceLastInput(); |
95 | reset(); |
96 | }, |
97 | "Das ist nicht korrekt", r { |
98 | print("=> INKORREKT"); |
99 | fS s = lastInput(); |
100 | //uploadOutputSinceLastInput(); |
101 | |
102 | showControls(vstackWithSpacing( |
103 | setFontSize(13, jcenteredBoldLabel("Was heißt " + quote(s) + " denn?")), |
104 | jcenteredbuttons( |
105 | "Es heißt Ja", r { correct(s, true) }, |
106 | "Es heißt Nein", r { correct(s, false) }, |
107 | "Es heißt was anderes", r { correct(s, null) }))); |
108 | })))); |
109 | } |
110 | |
111 | answer { |
112 | Bool b = algo_0_3(s); |
113 | S a = formatSatz(s, b); |
114 | controls_feedback(a); |
115 | try answer a; |
116 | } |
117 | |
118 | sS formatSatz(S s, Bool b) { |
119 | ret quote(s) + " " + ( |
120 | isTrue(b) ? "bedeutet 'Ja'" |
121 | : isFalse(b) ? "bedeutet 'Nein'" |
122 | : "bedeutet weder Ja noch Nein"); |
123 | } |
124 | |
125 | svoid controls2_default() { |
126 | showControls2(jcenteredlabel("Schreib doch mal was ja-iges oder nein-iges:")); |
127 | } |
128 | |
129 | svoid correct(S input, Bool b) { |
130 | print(formatSatz(input, b)); |
131 | post(quote(input), "heißt", boolSwitch(b, "ja", "nein", "weder ja noch nein")); |
132 | uploadOutputSinceLastInput(); |
133 | reset(); |
134 | } |
135 | |
136 | svoid reset { |
137 | hideControls(); |
138 | enableConsoleInput(); |
139 | focusConsole(); |
140 | } |
141 | |
142 | svoid onTriple(T3<S> t) { |
143 | if (eqic(t.b, "heißt") && isQuoted(t.a)) { |
144 | if (eqic(t.c, "ja")) add_withCollapsed(yesLiterals, unquote(t.a)); |
145 | else if (eqic(t.c, "nein")) add_withCollapsed(noLiterals, unquote(t.a)); |
146 | } |
147 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xfbsdwenvhih
No comments. add comment
Snippet ID: | #1013840 |
Snippet name: | Ja Oder Nein Bot [OK, mit Upload] |
Eternal ID of this version: | #1013840/53 |
Text MD5: | 20e4286af4833e569f578e74a4a1fdf8 |
Transpilation MD5: | 914ba8e5d9ba8f77c59f2f4593ac08af |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-03-07 02:32:18 |
Source code size: | 3025 bytes / 147 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 531 / 3143 |
Version history: | 52 change(s) |
Referenced in: | [show references] |