sclass BEACalculations { GazelleBEA mod; *(GazelleBEA *mod) {} void reactAllInputsWithSomePatterns() { for (BEAObject input : mod.beaObjectsOfType("input")) { new ReactInputWithSomePatterns r; r.input = input; r.ccOut = db_mainConcepts(); r.max = 10; r.start(); stepAllWithTimeout(10.0, r); } } class ReactInputWithSomePatterns implements Steppable { BEAObject input; Concepts ccOut; int max = 3, n; Iterator patterns; void start { n = countConceptsWhereIC(ccOut, BEAObject, +input, type := "match"); patterns = iterator(sortByConceptID(conceptsWhereIC BEAObject(type := "Pattern"))); } public bool step() { if (n >= max) false; if (!patterns.hasNext()) false; if (reactInputWithPattern(input, patterns.next(), ccOut) != null) ++n; true; } } SS matchInputWithPattern(BEAObject input, BEAObject pattern) { S pat = getString text(pattern); S text = getString text(input); ret flexMatchAngleBracketVarsIC_honorPunctuation_first(pat, text); //ret flexMatchAngleBracketVarsIC_first(pat, text); } BEAObject reactInputWithPattern(BEAObject input, BEAObject pattern, Concepts ccOut) { SS mapping = matchInputWithPattern(input, pattern); printVars_str("reactInputWithPattern", +input, +pattern, +mapping); if (mapping == null) null; ret cnew(ccOut, BEAObject, type := "Match", +input, +pattern, +mapping); } O serveAnalyzeInput(GazelleBEA.Req req) { new Concepts ccOut; BEAObject input = getConcept BEAObject(parseLong(req.get("id"))); if (input == null) input = cnew(ccOut, BEAObject, type := "Input", text := req.get("q")); S text = getString text(input); new ReactInputWithSomePatterns r; r.input = input; r.ccOut = ccOut; r.max = 1000; r.start(); stepAllWithTimeout(10.0, r); L matches = conceptsWhereIC(ccOut, BEAObject, type := "Match"); ret h1_title("Analyze Input") + p("Input: " + b(htmlEncode(text))) + p(empty(matches) ? "No matches" : "Matches") + ul_htmlEncode(matches); } }