Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

48
LINES

< > BotCompany Repo | #1023210 // I want you to be... [prelude spike v4, extended strings, OK]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (12278L/68K).

1  
!7
2  
3  
cmodule IWantYouToBePrelude > DynPrintLog {
4  
  transient LS inputs = tlft([[
5  
    I want you to be my mother
6  
    I want you to be my assistant
7  
  ]]);
8  
  
9  
  // the facts
10  
  
11  
  transient Set<S> facts = tlft_ciSet([[
12  
    Computery is usery's assistant
13  
    It is impossible that {Computery is usery's mother}
14  
  ]]);
15  
16  
  // the rules
17  
18  
  transient WordTokRule rule_iWantYouToBe = wordTokReplacerRule(
19  
    "I want you to be my assistant", "assistant", "I want that {you are my assistant}");
20  
    
21  
  transient WordTokRule rule_useryWants = new WordTokRule("Usery wants that X", "X") {
22  
    run {
23  
      S x_simplified = simpleSpaces_nTok(getVar("X"));
24  
      if (contains(facts, x_simplified))
25  
        emit(extMarkAs answer("But " + x_simplified + " already"));
26  
      else if (contains(facts, "It is impossible that " + curly(x_simplified)))
27  
        emit(extMarkAs answer("No way brother"));
28  
      else if (debug) print("Can't decide on: " + x_simplified);
29  
    }
30  
  };
31  
  
32  
  // rules by space
33  
    
34  
  transient MultiMap<S, WordTokRule> rulesForSpace = litmultimap(
35  
    MultiSpaceReasoning1.userSpace, ll(rule_iWantYouToBe),
36  
    MultiSpaceReasoning1.objectiveSpace, ll(rule_useryWants)
37  
  );
38  
  
39  
  start-thread-printDone {
40  
    new MultiSpaceReasoning1 mr;
41  
    mr.addRules(rulesForSpace);
42  
    
43  
    for (S input : printIterate_nl(inputs)) {
44  
      Collection<ES> outputs = mr.reason_inputToAnswer(input);
45  
      printLinesIndent("[Bot] ", extFilterByFlag answer(outputs));
46  
    }
47  
  }
48  
}

Author comment

Began life as a copy of #1023180

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1023210
Snippet name: I want you to be... [prelude spike v4, extended strings, OK]
Eternal ID of this version: #1023210/19
Text MD5: 91f78d9b185d63693b4739b051b93c0d
Transpilation MD5: 1a0d791c007675a4d81bbd06a4ca1b56
Author: stefan
Category: javax / logic engines
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-06-27 00:09:01
Source code size: 1508 bytes / 48 lines
Pitched / IR pitched: No / No
Views / Downloads: 241 / 488
Version history: 18 change(s)
Referenced in: [show references]