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

28
LINES

< > BotCompany Repo | #1010753 // Smart Thought Bot v2

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

Download Jar. Libraryless. Click here for Pure Java version (14106L/99K).

1  
!7
2  
3  
p {
4  
  botIfMain();
5  
  consoleInputIfMain("What did you learn today?");
6  
}
7  
8  
answer {
9  
  if "What did you learn today?"
10  
    ret search("I learned today:", "I learned today/", "I learned today/that");
11  
  if "What's your name?|What is your name?"
12  
    ret search("My name is", "My name/is", "My name is/");
13  
    
14  
  for (WebNode n : indexedNodes2("Standard answer"))
15  
    if (match(web_operandText(n, "to"), s))
16  
      try answer web_operandText(n, "is", "can be");
17  
}
18  
19  
static S search(S text, S... stuff) {
20  
  new LinkedHashSet<S> results;
21  
  for (S s : stuff) {
22  
    int i = smartIndexOf(s, '/');
23  
    L<WebNode> l = indexedNodes2(takeFirst(i, s));
24  
    results.addAll(web_uniqueOperandTexts(l, substring(s, i+1)));
25  
  }
26  
  
27  
  ret addSpaceIfNempty(text) + or2(joinWithSpace(map addDotIfNoPunctuation(results)), "Nothing");
28  
}

Author comment

Began life as a copy of #1010737

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1010753
Snippet name: Smart Thought Bot v2
Eternal ID of this version: #1010753/7
Text MD5: 993da124b22bd4f19198001e9045fd51
Transpilation MD5: 2ac2b81d8591b02585c2a3e8878ce177
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-10-20 02:07:26
Source code size: 836 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 528 / 1673
Version history: 6 change(s)
Referenced in: [show references]