Warning: session_start(): open(/var/lib/php/sessions/sess_s4u095816f3cl97is1f65edf8e, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
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);
}
O serveQueryPage(GazelleBEA.Req req) {
S q = req.get("q"), algorithm = req.get("algorithm");
LS algorithms = ll("Analyze input");
ret htitle_h2("Gazelle BEA Query")
+ hform(
hcenter3("Query: " + htextfield(+q, style := "width: 300px") + " Algorithm: " + hselect_list(algorithms, algorithm, name := "algorithm") + " " + hbutton("OK"))
);
}
}