Warning: session_start(): open(/var/lib/php/sessions/sess_7p3l76cctr762hpcn2642v1usc, 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
!7
sS data = [[
---- Rules
I ate pizza with a fork.
=> I used a fork to eat pizza.
I used a fork to eat pizza.
=> I used a fork.
I used a fork.
=> A fork is a tool.
I ate pizza with pepperoni.
=> {I ate pizza} and {the pizza had pepperoni on it}.
The pizza had pepperoni on it.
=> Pepperoni is edible.
I ate pizza with Bob.
=> {I ate pizza} and {Bob was with me}.
Bob was with me.
=> Bob is a person.
A and B.
=> A.
A and B
=> B.
nicer wording for {is it true that {Mom is a person.}?} = {is Mom a person?}
nicer wording for {is it true that {Mom is edible.}?} = {is Mom edible?}
---- Input
I ate pizza with mom.
I ate pizza with anchovis.
I ate pizza with ducks.
I ate pizza with my hands.
]];
p-exp {
set serverMechList_raw_fresh_verbose;
centerBigTTConsole();
S data = mapEachLine ai_groupSimplestNounPhrases(main.data);
SS sections = asCIMap(minusSignsSections(data));
LS rulesRaw = splitAtEmptyLines(sections.get("Rules"));
//pnl(rulesRaw);
LPair rules = mapNonNulls splitAtDoubleArrow_pair(rulesRaw);
//pnlStruct(rules);
print();
LS inputs = tlft(sections.get("Input"));
for (S input : inputs) {
print("\n" + tok_dropCurlyBrackets(input) + "\n");
new MultiSet ms;
LS tokI = defaultParse(input);
new L> interpretations;
for (PairS rule : rules) {
LS tokR = defaultParse(rule.a);
final SS map = ciMapWithoutKeysEqualToValues(zipTwoListsToCIMap_strict(tokR, tokI));
if (map == null) continue;
// Found matching rule
int score = l(tokR)-l(map);
ms.add(rule, score+1);
//print(" " + reverseMapCI_joinDuplicatesWithPlus(map) + " | " + rule.a);
// Make consequence
LS tokC = javaTok(rule.b);
tokC = mapCodeTokens(tokC, func(S s) -> S {
getOrKeep_tryUncurlied(map, s)
});
addPair(interpretations, tok_dropCurlyBrackets(join(tokC)), ratioToIntPercent(score, l(tokR)));
}
for (Pair p : sortByPairBDesc(interpretations))
print(" Interpretation (score " + p.b + "%): " + ai_superSimpleVerbCorrector(p.a));
//print(" Best rules: " + renderMultiSet(msMapKeys pairA(ms)));
}
}
static LS defaultParse(S s) {
ret codeTokens_lazy_uncurly(javaTokWithBrackets_cached(s));
}