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

41
LINES

< > BotCompany Repo | #1017690 // Scammer => Driver [Logic Spike, OK]

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

Download Jar. Libraryless. Click here for Pure Java version (10183L/75K).

1  
!7
2  
3  
sS rule = [[
4  
  input(I'm a $scammer!)
5  
    && fact(a $scammer $scams_people)
6  
    && relationX($scams_people, $scam_people)
7  
    => output(You $scam_people?!)
8  
]];
9  
10  
sS input = "I'm a driver";
11  
sS expectedOutput = "You drive cars?!";
12  
13  
p-exp {
14  
  NLLogicChecker_v2 c = new NLLogicChecker_v2 {
15  
    bool checkExpression(Exp e, Matching m) {
16  
      if (e cast Func) {
17  
        if (eq(e.name, "relationX")) {
18  
          printStruct("Checking: " + e + " with " + sfu(m.matches));
19  
          L<S> l = tok_splitAtComma(javaTokWithBrackets(nlLogic_text(e.arg)));
20  
          if (l(l) != 2) false;
21  
          l = mapReplaceVars2(l, m.matches);
22  
          printStruct(l);
23  
          if (isDollarVar(second(l)) && !isDollarVar(first(l)))
24  
            ret strictPutIC(m.matches, second(l), ai_verbPhraseFromThirdPerson(first(l)));
25  
          ret eqic(second(l), first(l));
26  
        }
27  
      }
28  
      ret super.checkExpression(e, m);
29  
    }
30  
  };
31  
  c.matcher = new NLStringMatcher_dollarVars_underscores;
32  
  
33  
  c.input = input;
34  
  c.facts = ll("A driver drives cars");
35  
  
36  
  applyNLLogicFacts_v2_verbose.set(true);
37  
  applyNLLogicFacts_v2(c, vf_print(),
38  
    ll(pair(aGlobalID(), nlLogic_parseRule(rule))));
39  
    
40  
  assertEqualsVerbose(ll(expectedOutput), c.posted);
41  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1017690
Snippet name: Scammer => Driver [Logic Spike, OK]
Eternal ID of this version: #1017690/17
Text MD5: d4620d75948902bc79fd04f8b1f3f518
Transpilation MD5: b9fd48d3e7b42b746ff7a5af677fd36b
Author: stefan
Category: javax / a.i.
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-08-03 14:34:21
Source code size: 1269 bytes / 41 lines
Pitched / IR pitched: No / No
Views / Downloads: 393 / 810
Version history: 16 change(s)
Referenced in: [show references]