Warning: session_start(): open(/var/lib/php/sessions/sess_ppjkjg2o1lbvnnskd43npv0mq8, 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
sS inputDiagrams = [[
CirclesAndLines(circles=[Circle(text="A [Anything]", x=d("0.32"), y=d("0.55")), Circle(text="B [Anything]", x=d("0.68"), y=d("0.55"))], lines=[Arrow(a=t5, b=t26, text="is"), Arrow(a=t26, b=t5, text="then: is?")], title="A B B A")
CirclesAndLines(circles=[Circle(quickvis="Philosophy", text="Philosophy", x=d("0.27"), y=d("0.47")), Circle(quickvis="Asking questions", text="Asking questions", x=d("0.75"), y=d("0.47"))], lines=[Arrow(a=t5, b=t30, text="is")], title="Philosophy")
]];
sS linkWord = "always";
static L webs;
static Web inputWeb, resultWeb;
static S question;
static JTabbedPane tabs;
p-subst {
cal_lineLength(50);
webs = websFromCALStructures_vis(inputDiagrams);
inputWeb = last(webs);
think();
final CirclesAndLines cal = webToCAL_live_vis(inputWeb,
voidfunc(Web w) { inputWeb = w; think() });
setFrameWidth(700, tabs = showTabbedWebs(
"Instruction", calAutoLayout2(webToCAL_live_vis(first(webs),
voidfunc(Web w) { webs.set(0, w); think() })),
"Input", /*inputWeb,*/ calAutoLayout2(cal),
"Result", resultWeb != null ? resultWeb : jlabel("Sorry"),
"Computer's Question", second(jFullCenterTextPane(question))));
think();
}
svoid think { loading {
print("Thinking.");
Web web = first(webs); // Instruction
Web patternWeb, Map patternMap = unpair cloneWebWithMap(web);
web_dropRelationsStartingWith(patternWeb, "Then:");
Web thenWeb, Map thenMap = unpair cloneWebWithMap(web);
web_unpackRelationsStartingWith(thenWeb, "Then:");
Map match = web_matchAllPerms(patternWeb, inputWeb);
// Clone inputWeb to get resultWeb
Web resultWeb, Map resultMap = unpair cloneWebWithMap(inputWeb);
main.resultWeb = resultWeb;
if (match != null) {
// Then add relations from thenWeb
for (WebRelation rel : web_relationObjects(thenWeb)) {
WebNode a = mapGet(resultMap, mapGet(match, mapGet(patternMap, reverseLookup(thenMap, rel.a)));
WebNode b = mapGet(resultMap, mapGet(match, mapGet(patternMap, reverseLookup(thenMap, rel.b)));
if (a != null && b != null) {
print("Adding labels " + rel.labels + " to: " + a + " - " + b);
WebRelation rel2 = resultWeb.getRelation(a, b);
web_addLabelsFromNodeToNode(rel, rel2);
}
}
}
// Make question
WebRelation rel = web_findDoubleRelation(resultWeb, "Is", "Is?");
question = "?";
if (rel != null) {
S a = web_text(rel.a), b = web_text(rel.b);
question = firstToUpper(a) + " may be " + firstToLower(b) + ".\n\n"
+ "But is " + firstToLower(b) + " " + addSpaceIfNempty(linkWord) + firstToLower(a) + "?";
}
if (tabs != null) {
printWeb(resultWeb);
CirclesAndLines cal = webToCAL(resultWeb);
printBeautify(cal_structure(cal));
replaceTab(tabs, "Result", webToCALWithAutoLayout(resultWeb));
replaceTab(tabs, "Computer's Question", second(jFullCenterTextPane(question)));
}
}}