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

44
LINES

< > BotCompany Repo | #1012732 // Parsing in thought space v2 [OK]

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

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

1  
!7
2  
3  
sS input = "the dog barked and ran away";
4  
5  
p {
6  
  ai_alternativeSmartBot();
7  
  
8  
  temp ParseEnv env = parse_start(input);
9  
  
10  
  // Split at and?
11  
  
12  
  int i = indexOfIC_fullWord(env.input, "and");
13  
  if (i >= 0)
14  
    post("Suggest", "splitting at indices", struct(ll(i, i + l("and"))));
15  
    
16  
  // Split after noun phrase
17  
  
18  
  L<S> tok = defaultTok(env.input);
19  
  i = tokenIndexToCharIndex(tok, ai_endOfNounPhrase(tok));
20  
  if (i >= 0)
21  
    post("Suggest", "grouping starting at index", str(i));
22  
    
23  
  // Harvest
24  
  
25  
  L<TripleWeb> suggestions = ai_triplesWithA("Suggest");
26  
  pnl(suggestions);
27  
  TripleWeb suggestion = random(suggestions);
28  
  
29  
  S idx = ai_text_onTriple(suggestion, "Suggest", "splitting at indices", "$X");
30  
  if (idx != null) {
31  
    L<Int> indices = safeUnstructureList(idx);
32  
    print("Split to: " + sfu(splitStringAtIndices(env.input, indices)));
33  
    ret;
34  
  }
35  
  
36  
  idx = ai_text_onTriple(suggestion, "Suggest", "grouping starting at index", "$X");
37  
  if (idx != null) {
38  
    i = parseInt(idx);
39  
    print("Grouped to: " + curlyGroupFromIndex(env.input, i));
40  
    ret;
41  
  }
42  
  
43  
  print("Couldn't run suggestion " + suggestion);
44  
}

Author comment

Began life as a copy of #1012724

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, imzmzdywqqli, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1012732
Snippet name: Parsing in thought space v2 [OK]
Eternal ID of this version: #1012732/12
Text MD5: d6811fff5af5c528a95ecccecefb745f
Transpilation MD5: 7ec910f68d82603d1a84c76f9b2a9ac2
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:06:47
Source code size: 1177 bytes / 44 lines
Pitched / IR pitched: No / No
Views / Downloads: 374 / 948
Version history: 11 change(s)
Referenced in: [show references]