Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

44
LINES

< > BotCompany Repo | #1012746 // Parsing in thought space v4 [OK]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (19360L/137K).

1  
!7
2  
3  
sS input = "the dog barked and ran away";
4  
5  
srecord SplitTo(L<S> l) {}
6  
7  
p {
8  
  ai_independentSmartBot();
9  
  
10  
  temp ParseEnv env = parse_start(input);
11  
  
12  
  // Split at and?
13  
  
14  
  int i = indexOfIC_fullWord(env.input, "and");
15  
  if (i >= 0)
16  
    post("Suggest", "splitting at indices", struct(ll(i, i + l("and"))));
17  
    
18  
  // Split after noun phrase
19  
  
20  
  L<S> tok = defaultTok(env.input);
21  
  i = tokenIndexToCharIndex(tok, ai_endOfNounPhrase(tok));
22  
  if (i >= 0)
23  
    post("Suggest", "splitting at indices", sfu(ll(i)));
24  
    
25  
  // Suggestions -> Executions
26  
  
27  
  L<TripleWeb> suggestions = ai_triplesWithA("Suggest");
28  
  pnl(suggestions);
29  
  new LinkedHashSet executions;
30  
  
31  
  for (TripleWeb suggestion : suggestions) {
32  
    S idx = ai_text_onTriple(suggestion, "Suggest", "splitting at indices", "$X");
33  
    if (idx != null) {
34  
      L<Int> indices = safeUnstructureList(idx);
35  
      executions.add(SplitTo(splitStringAtIndices(env.input, indices)));
36  
    }
37  
  }
38  
39  
  print("Have " + n2(executions, "execution", "executions"));
40  
  pnlStruct(executions);
41  
  
42  
  O execution = random(executions);
43  
  print("Choosing: " + structure(execution));
44  
}

Author comment

Began life as a copy of #1012743

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: #1012746
Snippet name: Parsing in thought space v4 [OK]
Eternal ID of this version: #1012746/4
Text MD5: 7a5307abc3e8c2f9b9c390693947de34
Transpilation MD5: f1994edce37f41cbd87be50632853724
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:50:30
Source code size: 1167 bytes / 44 lines
Pitched / IR pitched: No / No
Views / Downloads: 513 / 1295
Version history: 3 change(s)
Referenced in: [show references]