Download Jar. Libraryless. Click here for Pure Java version (19376L/137K).
1 | !759 |
2 | |
3 | sS input = "the dog barked and ran away"; |
4 | |
5 | static record SplitTo(L<S> l) {} |
6 | static record GroupAs(S s) {} |
7 | |
8 | p { |
9 | ai_independentSmartBot(); |
10 | |
11 | temp ParseEnv env = parse_start(input); |
12 | |
13 | // Split at and? |
14 | |
15 | int i = indexOfIC_fullWord(env.input, "and"); |
16 | if (i >= 0) |
17 | post("Suggest", "splitting at indices", struct(ll(i, i + l("and")))); |
18 | |
19 | // Split after noun phrase |
20 | |
21 | L<S> tok = defaultTok(env.input); |
22 | i = tokenIndexToCharIndex(tok, ai_endOfNounPhrase(tok)); |
23 | if (i >= 0) |
24 | post("Suggest", "grouping starting at index", str(i)); |
25 | |
26 | // Suggestions -> Executions |
27 | |
28 | L<TripleWeb> suggestions = ai_triplesWithA("Suggest"); |
29 | pnl(suggestions); |
30 | new L executions; |
31 | |
32 | for (TripleWeb suggestion : suggestions) { |
33 | S idx = ai_text_onTriple(suggestion, "Suggest", "splitting at indices", "$X"); |
34 | if (idx != null) { |
35 | L<Int> indices = safeUnstructureList(idx); |
36 | executions.add(SplitTo(splitStringAtIndices(env.input, indices))); |
37 | } |
38 | |
39 | idx = ai_text_onTriple(suggestion, "Suggest", "grouping starting at index", "$X"); |
40 | if (idx != null) { |
41 | i = parseInt(idx); |
42 | executions.add(GroupAs(curlyGroupFromIndex(env.input, i))); |
43 | } |
44 | } |
45 | |
46 | print("Have " + n2(executions, "execution", "executions")); |
47 | pnlStruct(executions); |
48 | |
49 | O execution = random(executions); |
50 | print("Choosing: " + structure(execution)); |
51 | } |
Began life as a copy of #1012732
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1012743 |
Snippet name: | Parsing in thought space v3 [OK] |
Eternal ID of this version: | #1012743/8 |
Text MD5: | 522262eb0d5c8c9969dfe9feb52b04e1 |
Transpilation MD5: | 37de40295df200a95fa50e84017e750b |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-12-11 16:47:07 |
Source code size: | 1416 bytes / 51 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 543 / 1188 |
Version history: | 7 change(s) |
Referenced in: | [show references] |