sbool nlLogic_evalExp_verbose = true; static O nlLogic_evalExp(final NLLogicChecker_v2 c, Exp e, NLLogicChecker_v2.Matching m) { ret nlLogic_evalExp(c, e.text(), m); } static O nlLogic_evalExp(final NLLogicChecker_v2 c, S code, NLLogicChecker_v2.Matching m) { // prepare context final SS vars = m.matches; temp tempSetTL(ai_context_tl(), new O { LS getList(S var) { int i = 1; S s; new LS l; while ((s = vars.get(var + i++)) != null) l.add(s); ret l; } IfThen getRule(S id) { ret findByField(c.rules, globalID := id); } }); if (nlLogic_evalExp_verbose) print("Eval'ing: " + code); temp tempAdd(hotwire_copyOver_after, voidfunc(Class c) { copyFields(mc(), c, ai_staticVars()) }); O result = null; pcall { temp tempSetTL(evalJava_prep2_useCacheInThread, true); temp tempSetTL(evalJava_prep_voidMagic, false); Pair<LS, O> p = prepareEvalWithDollarVars_assertAllVarsSet(code, m.matches); // Accomodate ai_isTrue if (hasField(p.b, 'ai_isTrue_f)) set(p.b, 'ai_isTrue_f := func(S s) -> bool { nlLogic_matchAnyFact(c, s, new NLLogicChecker_v2.Matching()) }); // Accomodate ai_input if (c.input != null) { ThreadLocal tl_vars = cast getOpt(p.b, 'ai_getVar_map); if (tl_vars != null) tl_vars.set(litmap("#input" := c.input)); } result = evalWithDollarVars_step2(p, m.matches); } if (nlLogic_evalExp_verbose) print(" eval => " + shorten(str(result), 100)); ret result; }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1018082 |
Snippet name: | nlLogic_evalExp |
Eternal ID of this version: | #1018082/17 |
Text MD5: | 21be5c0506a8a447f0fb8782d9691b39 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-09-19 22:00:15 |
Source code size: | 1588 bytes / 50 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 400 / 451 |
Version history: | 16 change(s) |
Referenced in: | [show references] |