!7 sclass Suggestion { RuleWithParams rule; S output; S facts; S newInput; *() {} *(RuleWithParams *rule, S *output, S *facts, S *newInput) {} } sclass TestBot extends DynObjectTable { InputChooser inputChooser = new(this); S source; S inputAs = "Input:"; // "Input:" or "Fact:" start { inputChooser.delay = 1000; } visualize { ret withMargin(northAndCenter(vstackWithSpacing( westAndCenter(dm_fieldComboBox('inputAs, ll("Input:", "Fact:")), wrap(inputChooser)), withLabel("Rules mech list (empty for default rules&facts):", onEnter(dm_fieldTextField('source), rThread { update(inputChooser.input()) }))), super.visualize())); } void update { if (inputChooser.update()) update(inputChooser.input()); } void update(S input) { temp enter(); new NLLogicChecker_v3 c; bool inputAsFact = cic(inputAs, 'fact); if (!inputAsFact) c.input = input; Pair, LS> rulesAndFacts; if (empty(trim(source))) rulesAndFacts = ai_activeRulesAndFacts(); else rulesAndFacts = pair(ai_parseRulesWithMacros(mL_raw(trim(source))), emptyList(S)); c.facts = reversed(rulesAndFacts.b); if (inputAsFact) c.facts = concatLists(ll(input), c.facts); c.rules = reversed(rulesAndFacts.a); // latest rules first! if (!inputAsFact) c.rules = [IfThen r : c.rules | ai_ruleAccessesInput(r)]; c.rules = nlLogic_safeLHSEvalsOnly_verbose(c.rules); print("Have " + n2(rulesAndFacts.a, "rule")); c.useIterate = true; c.staticVerbose = true; new L battleSpace; nlLogic_fillBattleSpace(c, battleSpace, false); //print("l=" + l(battleSpace)); setData(map(battleSpace, func(RuleWithParams r) -> Suggestion { L l = nlLogic_unrollAndApplyRuleWithParams(r); ret Suggestion(r, nullIfEmpty(join("|", nlLogic_certainOperatorArgs(l, 'output, 'say))), nullIfEmpty(join("|", nlLogic_certainOperatorArgs(l, 'fact))), nullIfEmpty(join("|", nlLogic_certainOperatorArgs(l, 'input)))); })); } }