Uses 911K of libraries. Click here for Pure Java version (15340L/82K).
1 | !7 |
2 | |
3 | // English: |
4 | // x is contained in a mech list whose name contains "noun" => x is a noun |
5 | |
6 | concept Result {
|
7 | int count; |
8 | S output; |
9 | MapSO vars; |
10 | S result; // yes or no |
11 | } |
12 | |
13 | cmodule FindingNouns > DynCRUD<Result> {
|
14 | S freeText; |
15 | |
16 | transient new LPair<S, MapSO> suggestionsAndVars; |
17 | transient JButton btnYes, btnNo; |
18 | transient Pair<S, MapSO> current; // proposal and variables used |
19 | |
20 | start-thread {
|
21 | db(); |
22 | LS emits = getEmits_tee(r { javaxSimple(); });
|
23 | MapSO lastVars = null; |
24 | for (S s : emits) {
|
25 | MapSO vars = parseLineFromEmitVariables(s); |
26 | if (vars != null) lastVars = vars; |
27 | else |
28 | suggestionsAndVars.add(pair(s, lastVars)); |
29 | } |
30 | |
31 | runByUser(); |
32 | } |
33 | |
34 | visual jtabs("Dialog" := centerAndSouthWithMargins(dm_printLogView(),
|
35 | westAndCenterWithMargin( |
36 | jline( |
37 | btnYes = jbutton("Yes", rThread yes),
|
38 | btnNo = jbutton("No", rThread no),
|
39 | jlabel("or free text:")),
|
40 | onEnter(dm_textField freeText(), rThread { storeResult(freeText) }))), "Results" := super);
|
41 | |
42 | void runByUser {
|
43 | current = random(suggestionsAndVars); |
44 | if (current == null) ret; |
45 | printWithPrecedingNL(current.a); |
46 | print("Correct?");
|
47 | enableButtons(btnYes, btnNo); |
48 | } |
49 | |
50 | void yes { storeResult("yes"); }
|
51 | void no { storeResult("no"); }
|
52 | |
53 | void storeResult(S result) enter {
|
54 | if (current == null) ret; |
55 | print("Storing result: " + result);
|
56 | Result r = uniq(Result, output := current.a, vars := current.b, +result); |
57 | cset(r, count := r.count+1); |
58 | disableButtons(btnYes, btnNo); |
59 | //sleepSeconds(1); |
60 | runByUser(); |
61 | } |
62 | |
63 | void javaxSimple() {
|
64 | for (S listName : mechListNames()) |
65 | if (cic(listName, "noun")) |
66 | for (S s : mL(listName)) {
|
67 | emitVariables(+listName, +s); |
68 | emit(quote(s) + " is a noun"); |
69 | } |
70 | } |
71 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1026487 |
| Snippet name: | Finding Nouns [dev.] |
| Eternal ID of this version: | #1026487/16 |
| Text MD5: | c0eb60e61a2f3d80a485b496c4f24165 |
| Transpilation MD5: | 4f8be89c80a66352d2a6de0dd28a99d4 |
| Author: | stefan |
| Category: | javax / speech recognition |
| Type: | JavaX source code (Dynamic Module) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-01-06 19:58:34 |
| Source code size: | 1905 bytes / 71 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 493 / 814 |
| Version history: | 15 change(s) |
| Referenced in: | [show references] |