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

!7

sS rule = [[
  input(I'm a $scammer!)
    && fact(a $scammer $scams_people)
    && relationX($scams_people, $scam_people)
    => output(You $scam_people?!)
]];

sS input = "I'm a driver";
sS expectedOutput = "You drive cars?!";

p-exp {
  NLLogicChecker_v2 c = new NLLogicChecker_v2 {
    bool checkExpression(Exp e, Matching m) {
      if (e cast Func) {
        if (eq(e.name, "relationX")) {
          printStruct("Checking: " + e + " with " + sfu(m.matches));
          L<S> l = tok_splitAtComma(javaTokWithBrackets(nlLogic_text(e.arg)));
          if (l(l) != 2) false;
          l = mapReplaceVars2(l, m.matches);
          printStruct(l);
          if (isDollarVar(second(l)) && !isDollarVar(first(l)))
            ret strictPutIC(m.matches, second(l), ai_verbPhraseFromThirdPerson(first(l)));
          ret eqic(second(l), first(l));
        }
      }
      ret super.checkExpression(e, m);
    }
  };
  c.matcher = new NLStringMatcher_dollarVars_underscores;
  
  c.input = input;
  c.facts = ll("A driver drives cars");
  
  applyNLLogicFacts_v2_verbose.set(true);
  applyNLLogicFacts_v2(c, vf_print(),
    ll(pair(aGlobalID(), nlLogic_parseRule(rule))));
    
  assertEqualsVerbose(ll(expectedOutput), c.posted);
}

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: 517 / 1085
Version history: 16 change(s)
Referenced in: