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

53
LINES

< > BotCompany Repo | #1012724 // Parsing in thought space v1 [OK with Smart Bot DB]

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

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

1  
!7
2  
3  
sS input = "lalalalala please give me the number yo la la";
4  
5  
p {
6  
  ai_alternativeSmartBot();
7  
  
8  
  while licensed {
9  
    temp ActualThoughtSpace myTS = newThoughtSpace();
10  
    
11  
    myTS.blockedA = litsymbolset("We", "Suggest");
12  
    
13  
    input = trim(input);
14  
    print("Have input: " + input);
15  
    post("We", "are parsing", quote(input));
16  
    
17  
    for (S tail : ai_texts_verified_quoted("$X", "is", "a droppable tail")) {
18  
      //print("Have tail: " + tail);
19  
      if (nempty(tail) && ewic(input, tail))
20  
        post("Suggest", "splitting off after index", l(rtrim(dropLast(l(tail), input))));
21  
    }
22  
        
23  
    for (S prefix : ai_texts_verified_quoted("$X", "is", "a droppable prefix")) {
24  
      //print("Have prefix: " + prefix);
25  
      if (nempty(prefix) && swic(input, prefix))
26  
        post("Suggest", "splitting off before index", smartIndexOf(input, ' ', l(prefix)));
27  
    }
28  
    
29  
    S idx = random(ai_texts("Suggest", "splitting off after index", "$X"));
30  
    if (idx != null) {
31  
      int i = parseInt(idx);
32  
      print("Splitting off: " + substring(input, i));
33  
      continue with input = takeFirst(i, input);
34  
    }
35  
    
36  
    idx = random(ai_texts("Suggest", "splitting off before index", "$X"));
37  
    if (idx != null) {
38  
      int i = parseInt(idx);
39  
      print("Splitting off: " + takeFirst(i, input));
40  
      continue with input = substring(input, i);
41  
    }
42  
    
43  
    // Nothing to do
44  
    break;
45  
    
46  
    // end of thought space
47  
  }
48  
  
49  
  print("Final input: " + input);
50  
  assertEqualsIC("give me the number", input);
51  
  print("OK");
52  
  //printThoughtSpace();
53  
}

Author comment

Began life as a copy of #1012716

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: #1012724
Snippet name: Parsing in thought space v1 [OK with Smart Bot DB]
Eternal ID of this version: #1012724/22
Text MD5: 883a318b73c629f71a587d653d69b932
Transpilation MD5: 199f63686b5ea0bcc0b5b9f630646be3
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-13 18:32:01
Source code size: 1613 bytes / 53 lines
Pitched / IR pitched: No / No
Views / Downloads: 381 / 869
Version history: 21 change(s)
Referenced in: [show references]