!752 static L statements = toLinesFullTrim([[ "arnold" is a "good guy". a "good guy" is not a "bad guy". a "bad guy" is not a "good guy". ]]); p { checkIs("arnold", "good guy"); checkIs("arnold", "bad guy"); } static void checkIs(S a, S b) { printF("Checking if * is a *", a, b); pcall { S answer = checkIs_impl(a, b); print(" " + answer); } } static S checkIs_impl(S a, S b) { // find direct statements L l = findStatements(format("* is a *", a, b)); if (nempty(l)) ret "yes"; l = findStatements(format("* is not a *", a, b)); if (nempty(l)) ret "no"; // derived stuff (find all classes of a) l = findStatements(quote(a) + "is a *"); new TreeSet classes; for (Matches m : l) classes.add(m.unq(0)); print("Classes found: " + structure(classes)); for (S c : classes) { if (nempty(findStatements(format("a * is a *", c, b)))) ret "yes"; if (nempty(findStatements(format("a * is not a *", c, b)))) ret "no"; } ret "unknown"; } static L findStatements(S pat) { new L l; for (S s : statements) { new Matches m; if (match(pat, s, m)) // todo: match quoted and identifier (arnold vs "arnold") l.add(m); } ret l; }