Warning: session_start(): open(/var/lib/php/sessions/sess_8j3gi6c94bk8r8ivjvml1kkfgn, 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 RuleEngine2_MatchedRule {
S globalID = aGlobalID();
RuleEngine2.Rule rule;
SS map;
new Map mappingQuality; // key in map to -1, 0 or 1
new LPair matchedLines;
O tokenizationFunction;
int qualitySum() {
ret intSum(values(mappingQuality))-l(map);
}
RuleEngine2.Rule applyMapping() {
new RuleEngine2.Rule r;
r.in = map(rule.in, f applyMappingTo);
r.out = applyMappingTo(rule.out);
ret r;
}
S appliedRuleText() {
ret applyMapping().asText();
}
S applyMappingTo(S s) {
ret s == null ? null : join(ai_mapCodeTokensWithMap(tokenize(s), map));
}
LS tokenize(S s) {
ret (LS) callF(assertNotNull(tokenizationFunction), s);
}
}
static L ai_ruleEngine2_rulesForInput_3(RuleEngine2 engine, S q) {
new L l;
for (RuleEngine2.Rule rule : engine.rules) {
S cond = first(rule.in);
S tokenize = or(matchAny_firstGroup("tokenize with *", rule.comments), f javaTokNPunctuationWithBrackets);
LS tokI = (LS) callF(tokenize, q);
LS tokC = (LS) callF(tokenize, cond);
SS map = zipTwoListsToCIMap_strict_withoutEquals(tokC, tokI);
if (map == null) continue;
//print(map + " | " + cond + " | " + rule.vars);
new RuleEngine2_MatchedRule matched;
matched.rule = rule;
matched.map = map;
matched.matchedLines.add(pair(tokC, tokI));
matched.tokenizationFunction = tokenize;
Map qualities = ai_ruleEngine2_mappingQualities(rule);
for (S a, b : map) {
mapPut(matched.mappingQuality, a, qualities.get(pair(a, b)));
}
l.add(matched);
}
ret l;
}