Warning: session_start(): open(/var/lib/php/sessions/sess_9g2lut7rk314dmo0i6gv4ib2o8, 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
!include once #1014750 // CSnippet
sS inspiration = [[
snippet titles
"[OK]"
]];
static new LL facts; // stores code token parses
static Map phrasesWordTree = wordTree();
static Clusters clusters = ciClusters();
sS reasoning = [[
assert(inspired "snippet titles")
assert(inspired "\"[OK]\"")
phrase "snippet titles"
"the snippet titles" = "snippet titles"
phrase "a set of strings"
phrase "a quoted string"
singular_plural("snippet title", "snippet titles")
snippet titles are a list of strings
fact_question_answer("X are Y", "what are X?", "Y")
assert_answer("what are snippet titles?", "a list of strings")
"[OK]" is a quoted string
//length of snippet titles is
]];
p-experiment-tt {
L program = tlftj(reasoning);
pnl(program);
print();
for (S s : tlftj(inspiration))
addFact("inspired " + quote(s));
for (S s : program) {
Pair> p = parseFunctionCall(s);
if (p != null) {
//print("Function call: " + sfu(p));
S f = p.a;
if (eqic(f, "assert"))
assertFact(getSingleton(p.b));
else if (swic(f, "assert_")) {
if (eqic(f, "assert_answer"))
assertAnswer(first(p.b), second(p.b));
else
fail("Unknown assertion function: " + f);
}
continue;
}
L tok = javaTokC(s);
if (l(tok) == 2 && isIdentifier(first(tok)) && isQuoted(second(tok)))
if (eq(first(tok), "phrase")) {
addPhrase(unquote(second(tok)));
continue;
}
if (l(tok) == 3 && eq(second(tok), "=")) {
ciClusters_add(clusters, unquote(first(tok)), unquote(third(tok)));
continue;
}
addFact(s);
}
printAsciiHeading("Facts");
pnlStruct(facts);
print();
print("Clusters: " + sfu(clusters));
//loadSnippets();
}
svoid loadSnippets {
loadMainConceptsFrom_readOnly(#1009918); // get snippets
print("Have " + countConcepts(CSnippet) + " snippets");
pnl(takeFirst10(collect(list(CSnippet), 'title));
}
static L parseFact(S s) {
ret map toLowerIfIdentifier(javaTokC(/*dropPunctuation*/(s)));
}
svoid assertFact(S fact) {
if (contains(facts, parseFact(fact)))
print("OK fact: " + fact);
else
print("FAILED fact assert: " + fact);
}
svoid assertAnswer(S q, S a) {
print("TODO");
}
svoid addPhrase(S s) {
wordTreeAdd(phrasesWordTree, javaTokC(s), "[" + s + "]");
}
svoid addFact(S s) {
facts.add(parseFact(s));
}