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

38
LINES

< > BotCompany Repo | #1012294 // ai_specReturn_answerToExternalQuestion

JavaX fragment (include)

1  
static S ai_specReturn_answerToExternalQuestion(S q, Var<S> answer) {
2  
  answer.set("[Calculating...]");
3  
  q = switcheroo(q);
4  
  print("Switcheroo to: " + q);
5  
  T3<S> t = ai_tripelize(q);
6  
  print("Have triple: " + t);
7  
  if (t == null) ret "[Couldn't tripelize]";
8  
  /*t = ai_switcherooTriple(t);
9  
  print("Have switched triple: " + t);*/
10  
  
11  
  T3 tFact = ai_tripleWithoutQuestionMark(t);
12  
  if (has_verbose(tFact)) ret "Yes";
13  
  
14  
  T3 tNot = ai_negateTriple(t);
15  
  if (has_verbose(tNot)) ret "No";
16  
  
17  
  try answer ai_answerIsQuestion(t);
18  
  try answer ai_answerWhatQuestion(t);
19  
20  
  S unknown = ai_findUnknownThingInTriple(t);
21  
  if (unknown != null) ret "What is " + unknown + "?";
22  
  
23  
  ret "[No answer found for: " + ai_renderTriple(t) + "]";
24  
}
25  
26  
static double ai_specReturn_answerToExternalQuestion_defaultTimeout = 10.0;
27  
28  
static S ai_specReturn_answerToExternalQuestion(fS q) {
29  
  ret ai_specReturn_answerToExternalQuestion(ai_specReturn_answerToExternalQuestion_defaultTimeout, q);
30  
}
31  
32  
static S ai_specReturn_answerToExternalQuestion(double timeout, fS q) {
33  
  final new Var<S> answer;
34  
  evalWithTimeout(timeout, r {
35  
    setVarUnlessNull(answer, ai_specReturn_answerToExternalQuestion(q, answer))
36  
  });
37  
  ret answer!;
38  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1012294
Snippet name: ai_specReturn_answerToExternalQuestion
Eternal ID of this version: #1012294/14
Text MD5: 9a769f54022e8f7e74dff90680df8e47
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-12-13 16:46:32
Source code size: 1245 bytes / 38 lines
Pitched / IR pitched: No / No
Views / Downloads: 445 / 444
Version history: 13 change(s)
Referenced in: [show references]