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

51
LINES

< > BotCompany Repo | #1012743 // Parsing in thought space v3 [OK]

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

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

!759

sS input = "the dog barked and ran away";

static record SplitTo(L<S> l) {}
static record GroupAs(S s) {}

p {
  ai_independentSmartBot();
  
  temp ParseEnv env = parse_start(input);
  
  // Split at and?
  
  int i = indexOfIC_fullWord(env.input, "and");
  if (i >= 0)
    post("Suggest", "splitting at indices", struct(ll(i, i + l("and"))));
    
  // Split after noun phrase
  
  L<S> tok = defaultTok(env.input);
  i = tokenIndexToCharIndex(tok, ai_endOfNounPhrase(tok));
  if (i >= 0)
    post("Suggest", "grouping starting at index", str(i));
    
  // Suggestions -> Executions
  
  L<TripleWeb> suggestions = ai_triplesWithA("Suggest");
  pnl(suggestions);
  new L executions;
  
  for (TripleWeb suggestion : suggestions) {
    S idx = ai_text_onTriple(suggestion, "Suggest", "splitting at indices", "$X");
    if (idx != null) {
      L<Int> indices = safeUnstructureList(idx);
      executions.add(SplitTo(splitStringAtIndices(env.input, indices)));
    }
    
    idx = ai_text_onTriple(suggestion, "Suggest", "grouping starting at index", "$X");
    if (idx != null) {
      i = parseInt(idx);
      executions.add(GroupAs(curlyGroupFromIndex(env.input, i)));
    }
  }
  
  print("Have " + n2(executions, "execution", "executions"));
  pnlStruct(executions);
  
  O execution = random(executions);
  print("Choosing: " + structure(execution));
}

Author comment

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: 541 / 1182
Version history: 7 change(s)
Referenced in: [show references]