Warning: session_start(): open(/var/lib/php/sessions/sess_f8odamhs3hpk3iecc4501p4ael, 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
!include once #1027630 // Msg
replace LogicRule with BasicLogicRule.
cmodule NewEngineSpike > DynPrintLog {
L msgs;
bool verbose = true, printNonMatches = true;
transient new Map facts; // facts to trail
transient AllOnAllWithOperation rulesAndFacts
= new(lambda2 applyLogicRuleToFact);
bool step() { ret rulesAndFacts.step(); }
void addLogicRule(LogicRule rule) {
if (verbose) print("New rule: " + rule);
rulesAndFacts.newA(rule);
}
void addFact(O fact) { addFact(fact, "external"); }
void addFact(O fact, O trail) {
if (!facts.put(fact, trail)) ret;
if (verbose) print("New fact: " + fact);
rulesAndFacts.newB(fact);
}
L factsInOrderOfDefinition() { ret rulesAndFacts.cloneBList(); }
start-thread {
if (empty(msgs))
setField(msgs := mainCruddieLog());
print("Have " + nMessages(msgs));
pnlStruct(takeFirst(2, msgs));
L msgs2 = whereFieldIsTrue fromUser(msgs);
for (Msg msg : takeFirst(5, msgs2))
addFact(ll(msg, Fragment("was understood correctly")));
addFact(ll(get(msgs2, 5), Fragment("is a wrong recognition")));
addLogicRule(new LogicRule(
ll("$x", Fragment("is a wrong recognition")),
ll("$x", Fragment("should be corrected"))));
stepAll(lambda0 step);
}
// define what a variable is
bool isVar(O o) { ret o instanceof S && isDollarVar(o/S); }
void applyLogicRuleToFact(LogicRule rule, O fact) {
new LogicRuleApplier ap;
ap.rule = rule;
ap.fact = fact;
ap.verbose = verbose;
ap.printNonMatches = printNonMatches;
ap.addRewrittenRHS = lambda2 addRewrittenRHS;
ap.tools.isVar = lambda1 isVar;
ap.run();
}
void addRewrittenRHS(O o, O trail) {
if (o cast LogicRule) {
o.trail = trail;
addLogicRule(o);
} else if o is And(O a, O b) {
addRewrittenRHS(a, o);
addRewrittenRHS(b, o);
} else if (o != null)
addFact(o, trail);
}
}