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).

!7

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

p {
  ai_alternativeSmartBot();
  
  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));
    
  // Harvest
  
  L<TripleWeb> suggestions = ai_triplesWithA("Suggest");
  pnl(suggestions);
  TripleWeb suggestion = random(suggestions);
  
  S idx = ai_text_onTriple(suggestion, "Suggest", "splitting at indices", "$X");
  if (idx != null) {
    L<Int> indices = safeUnstructureList(idx);
    print("Split to: " + sfu(splitStringAtIndices(env.input, indices)));
    ret;
  }
  
  idx = ai_text_onTriple(suggestion, "Suggest", "grouping starting at index", "$X");
  if (idx != null) {
    i = parseInt(idx);
    print("Grouped to: " + curlyGroupFromIndex(env.input, i));
    ret;
  }
  
  print("Couldn't run suggestion " + suggestion);
}

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