static L gazelle_getChildren(GazelleTree tree, O... _) { if (tree == null) null; if (tree.children != null) ret tree.children; tree.children = new L; double qualityCutOff = optPar qualityCutOff(_, -0.75); LS dialogHistory = cast optPar dialogHistory(_); bool debug = boolPar debug(_); // make rule engine etc. if (tree.ctx == null) tree.setContext(assertNotNull('evalContext, (GazelleEvalContext) callF(assertNotNull('makeEvalContext, (O) optPar makeEvalContext(_))))); GazelleEvalContext ctx = tree.ctx; RuleEngine2 engine = ctx.engine; SS inputMap = gazelle_inputMapFromLineAndHistory(tree.line, concatLists(dialogHistory, tree.history())); if (boolPar respondingToHuman(_)) inputMap.put("_respondingToHuman" := "true"); if (debug) print("inputMap=" + sfu(asTreeMap(inputMap))); // Splitters if (!boolPar skipSplitters(_)) for (RuleEngine2.SimplifyWithRule rule : engine.splitterRules()) pcall { Collection out = gazelle_executeSplitterRule(engine, rule, tree.line); if (empty(out)) continue; GazelleTree child = new(joinWithVBar(out)); child.ctx = ctx; child.isSplitNode = true; tree.add(child); for (S line : out) child.add(GazelleTree(line)); } // Other rules bool firstConditionOnly = boolPar firstConditionOnly(_); O[] params = litobjectarray(debug := optPar debug(_), +tree); L l = sortByMethodDesc qualitySum( firstConditionOnly ? ai_ruleEngine2_rulesForInput_5(engine, inputMap, params) : ai_ruleEngine2_rulesForInput_5_allConditions(engine, inputMap, params)); //print("Got rules: " + l(l)); for (RuleEngine2_MatchedRule r : l) { double quality = r.relativeQuality(); double cutOff = qualityCutOff; if (r.rule != null && r.rule.qualityCutOff != null) cutOff = r.rule.qualityCutOff; if (quality < cutOff && boolPar skipBad(_, true)) { if (debug) print("Match under quality (" + quality + "/" + qualityCutOff + "): " + r); continue; } S line = r.outText(); GazelleTree child = new(line); child.ctx = ctx; child.mr = r; if (r.rule != null) child.lineType = r.rule.outType(); // TODO: there can be multiple out types gazelle_addPredictionToTreeNode(child); tree.add(child); } gazelle_sortChildren(tree); ret tree.children; }