!7 !include once #1027167 // Compact Module Include 2 v2 module WinogradSolver1 > DynSingleFunctionWithPrintLog { transient PhilosophyBot1 engine; transient O multiStage; // unused void doIt { S input = "Bob paid for Charlie's college education. He is very [generous/grateful]. Who is [generous/grateful]?"; // Stage 1: take one option out of square brackets S input2 = winograd_takeFirstOption(input); //S input2 = winograd_takeSecondOption(input); dm_call(multiStage, 'addStage, "Take first option", input2); // Stage 1b: Split off 's S input2b = ai_splitOffApostropheS(input2); dm_call(multiStage, 'addStage, "Split off 's", input2b); // Stage 1c: Split into sentences LS sentences = map dropQuestionMark(sentences(input2b)); dm_call(multiStage, 'addStage, "Split into sentences", sentences); // Stage 2: Parser S parser = dm_makeModule("#1027108/TopDownParsing"); //L parsed = map(sentences, s -> dm_call(parser, 'parse, s)); L> parsed = map(sentences, s -> (Cl) dm_call(parser, 'parseToGroupings, s)); pnl(parsed); Set allGroupings = concatListsToCISet(parsed); print("Have " + n2(allGroupings, "grouping")); dm_call(multiStage, 'addStage, "Parser", parsed); // Stage 3a: Select the right rules for the task Cl allRules = dm_getUnclearList("Rules"); // take all for now // Stage 3b: Run logic engine S program = joinWithEmptyLines(concatLists(allGroupings, allRules)); engine = PhilosophyBot1(program); engine.think(); for (SS map : engine.matchFacts("the answer to $x is $y")) if (allGroupings.contains($x(map))) printAfterNewLine("ANSWER>> " + $x(map) + ": " + $y(map)); } }