!7 sS facts = [[ We want to find out what is more correct than what. "not correct" is a candidate. "maybe quite correct" is a candidate. "really really correct" is a candidate. "buggy" is a candidate. "total garbage" is a candidate. "incorrect" is a candidate. "almost correct" is a candidate. "absolutely correct" is a candidate. "very correct" is a candidate. [nfhwfngqkgoqtngs] (X is a candidate.) and (Y is a candidate.) and (X <> Y) and (I don't know if (X is more correct than Y.)) => (Ask (Is X # more correct than Y?)) // Note: The # is just a filler for parsing, we'll get rid of that in time. Also, you will be able to write stuff without brackets of course. ]]; sS concepts = [[ phkdhqkhzytkwdpb - (X) and (Y) and (Z) and (AA) => (AB) cdzttdbxadjreorm - We want to find out what is X than what. ogqdgzepqbunuuht - X is a candidate. psrgtxwtfzmfzhsx - Is X Y than Z? hszwyiyetuuhcfwz - Is X # Y than Z? qgxjwufpfzkqvmxb - X is Y than Z. ylvaoplzguvhegka - X is not Y than Z. buahjsodljsaxvaq - X <> Y fxxathfdlfzgmaov - Ask (X) mzdvauejerzefagk - I don't know if (X) ltyqczktgtjxrtlf - more correct zveeggveflecjwvr - total garbage wolealpbqkkqkvqq - not correct tomkbzlqlpeiekvu - maybe quite correct dnxyynujqydgcxcd - really really correct trajdgvqepyhsumb - buggy lwikikhkydtewtjc - incorrect muxjpepnjiyjghwj - almost correct wtnpjovqqiswlyay - absolutely correct bmliokweerblfxco - very correct ]]; static Map> evaluators = new HashMap; p-tt { centerConsole(); substance(); // customize parsing set englishToConceptLanguage_unquote; set englishToConceptLanguage_simple_noXYZ; useConceptsAndStatements(concepts, facts); printLispStatements(); // create evaluators evaluators.put("buahjsodljsaxvaq", func(Lisp l) -> Bool { l.size() == 2 && neq(l.get(0), l.get(1)) }); // process the rule Lisp rule = getLispTruth("nfhwfngqkgoqtngs"); L conditions = dropLast(rule.args); Lisp out = last(rule.args); //for (Lisp cond : conditions) print("Condition: " + cond); new Map matches; int n = matchConditions_random(conditions, matches); if (n == -1) print("Yo! " + struct(matches)); else print("Only " + n + " of " + n(conditions, "condition") + " met"); } // if match: returns -1 // if no match: returns how many conditions were met static int matchConditions_random(L conditions, Map m) { if (empty(conditions)) ret -1; Lisp condition = first(conditions); Map m2 = cloneMap(m); if (!matchCondition_random(condition, m2)) ret 0; int n = matchConditions_random(dropFirst(conditions), m2); if (n == -1) { m.putAll(m2); ret -1; } ret n+1; // failure } static bool matchCondition_random(Lisp condition, Map m) { L facts = lispTruth(); L> candidates = new L; O evaluator = evaluators.get(condition.head); if (evaluator != null) ret isTrue(callF(evaluator, lispReplaceVars(condition, m))); for (Lisp fact : facts) { Map m2 = cloneMap(m); if (lispMatchIC_xyzVars_sub(condition, fact, m2)) candidates.add(m2); } //print("Have " + n(candidates, "candidate")); if (empty(candidates)) false; m.putAll(random(candidates)); true; }