Warning: session_start(): open(/var/lib/php/sessions/sess_6id7sss5p932fua3084gmfgegu, 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
static JTextArea ta;
static L usedConcepts;
static new L facts;
p-substance {
aiEnhancements();
usedConcepts = findAIConcepts(
"rplldtbwbbnlrotj kjuwvfidiwmbjsuc xzhtvnqwzuuzixci mibnjwgfxnetaxyz cdtwmxtqspigpyap kdpoqkaoypqenusd");
facts = clParse(linesToCL([[
"!" is a typical first word in a program.
"Hello" is a typical first word in a letter.
cdtwmxtqspigpyap confirms mibnjwgfxnetaxyz.
]]));
ta = showText("");
onChangeAndNow(ta, r {
fS text = getText(ta);
thread { think(text); }
});
requestFocus(ta);
}
sS firstWord(S s) {
if (empty(s)) ret "";
if (isLetterOrDigit(first(s)))
ret takeCharsWhile(s, f isLetterOrDigit);
else ret "" + first(s);
}
svoid think(S text) {
time {
S w = firstWord(text);
S x = aGlobalID();
/*
w is the first word in x.
Is x a letter (1) or a program (2)?
*/
S riddle = quote(w) + " is the first word in " + x + ". Is " + x + " a letter (1) or a program (2)?";
L localFacts = concatLists(facts,
clParse(sentencesToCL(riddle)));
pcall-short {
int answer = solveRiddle(localFacts);
print("Answer: " + (answer == 1 ? "letter" : answer == 2 ? "program" : "?"));
}
}
}
static L sentencesToCL(S text) {
ret listToCL(splitIntoSentences(text));
}
static L linesToCL(S text) {
ret listToCL(toLinesFullTrim(text));
}
static L listToCL(L l) {
englishToConceptLanguage_concepts.set(usedConcepts);
new L out;
print("Have " + n(l, "sentence"));
for (S line : l) {
S c = englishToConceptLanguage(line);
print(line + " => " + c);
out.add(c);
}
ret out;
}
static int solveRiddle(L facts) {
// Find the question
Lisp q = findHead(facts, "rplldtbwbbnlrotj");
if (q == null) fail("No question found");
S pivot = q.s(0);
L candidates = ll(q.s(1), q.s(2));
new Best best;
for i over candidates: {
S candidate = candidates.get(i);
new Web web;
web.newNode(pivot, candidate);
for (Lisp fact : facts)
web.relation(fact);
best.put(candidate, countConfirms(web, facts));
}
ret toInt(best.get(best));
}
static int countConfirms(Web web, L facts) {
for (filterfacts
}
sclass Web {
}