!7 cmodule IWantYouToBePrelude > DynPrintLog { // spaces & names sS objectiveSpace = 'objective, computerSpace = 'computer, userSpace = 'user; transient S userName = "usery", computerName = "computery"; // the facts transient Set facts = tlft_ciSet([[ Computery is usery's assistant It is impossible that {Computery is usery's mother} ]]); // the rules transient WordTokRule rule_iWantYouToBe = wordTokReplacerRule( "I want you to be my assistant", "assistant", "I want that {you are my assistant}"); transient WordTokRule rule_useryWants = new WordTokRule("Usery wants that X", "X") { // { debug = true; } run { S x_simplified = simpleSpaces_nTok(getVar("X")); if (contains(facts, x_simplified)) emit("But " + x_simplified + " already"); else if (contains(facts, "It is impossible that " + curly(x_simplified))) emit("No way brother"); else if (debug) print("Can't decide on: " + x_simplified); } }; // rules by space transient MultiMap rulesForSpace = litmultimap( userSpace, ll(rule_iWantYouToBe), objectiveSpace, ll(rule_useryWants) ); Set rewriteInSpace(S space, Collection inputs) { ret applyWordTokRules(rulesForSpace.get(space), inputs); } start-thread-printDone { for (S input : ll("I want you to be my mother", "I want you to be my assistant")) { print_nlBefore(input); // first, rewrite in user space Set outputs = rewriteInSpace(userSpace, ll(input)); pnlIndent("User space > ", outputs); // translate to objective space LS outputs2 = ai_spaceToSpace(userSpace, objectiveSpace, outputs, +computerName, +userName); pnlIndent("Objective space > ", outputs2); // rewrite in objective space Set outputs3 = rewriteInSpace(objectiveSpace, outputs2); pnlIndent("Objective space > ", outputs3); // translate to computer space LS outputs4 = ai_spaceToSpace(objectiveSpace, computerSpace, outputs3, +computerName, +userName); pnlIndent("Bot space > ", outputs4); } } }