Uses 911K of libraries. Click here for Pure Java version (10967L/73K).
!7 !include once #1027167 // Compact Module Include 2 v2 module WinogradSolver1 > DynSingleFunctionWithPrintLog { transient PhilosophyBot1 engine; transient O multiStage; // unused S prelude = "import bool"; S input = "Bob paid for Charlie's college education. He is very [generous/grateful]. Who is [generous/grateful]?"; Map<S, SS> answers = syncMap(); void doIt { clear(answers); change(); if (empty(input)) ret; // Stage 1: take one option out of square brackets for (S variant : winograd_variants(input)) { print(variant); SS _answers = ciMap(); dm_call(multiStage, 'addStage, "Variant", variant); // Stage 1b: Split off 's S input2b = ai_splitOffApostropheS(variant); 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<virtual TryPatterns> parsed = map(sentences, s -> dm_call(parser, 'parse, s)); L<Cl<S>> parsed = map(sentences, s -> (Cl<S>) dm_call(parser, 'parseToGroupings, s)); pnl(parsed); Set<S> allGroupings = concatListsToCISet(parsed); print("Have " + n2(allGroupings, "grouping")); dm_call(multiStage, 'addStage, "Parser", parsed); // Stage 3a: Select the right rules for the task Cl<S> allRules = dm_getUnclearList("Rules"); // take all for now // Stage 3b: Run logic engine S program = joinWithEmptyLines(concatLists(ll(prelude), allGroupings, allRules)); engine = PhilosophyBot1(program); engine.standardImports(); engine.enableTrails(); engine.printFactsAfterThinking = false; engine.think(); engine.printDeducedFactsWithTrails(); for (SS map : engine.matchFacts("the answer to $x is $y")) if (allGroupings.contains($x(map))) { printAfterNewLine("ANSWER>> " + $x(map) + ": " + $y(map)); _answers.put($x(map), $y(map)); } answers.put(variant, _answers); change(); print(); } } visual northCenterAndSouthWithMargins( jCenteredSection("Input", dm_centeredTextField input()), super, jCenteredSection("Answers", //dm_calculatedTextArea(() -> pnlToString(answers))) dm_calculatedCenteredLabel(() -> joinWithSlash( map(values(answers), map -> joinWithComma(values(map))))) ); }
Began life as a copy of #1027165
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1027181 |
Snippet name: | Winograd Solver (backup before trails) |
Eternal ID of this version: | #1027181/1 |
Text MD5: | f23c3d25ecbafc3180093553e539f026 |
Transpilation MD5: | 0af4c881f3cc47b0db490b39a449f204 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-02-24 11:59:21 |
Source code size: | 2653 bytes / 72 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 227 / 305 |
Referenced in: | -