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

65
LINES

< > BotCompany Repo | #1023180 // I want you to be... [prelude spike v3, OK]

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

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

1  
!7
2  
3  
cmodule IWantYouToBePrelude > DynPrintLog {
4  
  // spaces & names
5  
  
6  
  sS objectiveSpace = 'objective, computerSpace = 'computer, userSpace = 'user;
7  
  transient S userName = "usery", computerName = "computery";
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  
    // { debug = true; }
23  
    run {
24  
      S x_simplified = simpleSpaces_nTok(getVar("X"));
25  
      if (contains(facts, x_simplified))
26  
        emit("But " + x_simplified + " already");
27  
      else if (contains(facts, "It is impossible that " + curly(x_simplified)))
28  
        emit("No way brother");
29  
      else if (debug) print("Can't decide on: " + x_simplified);
30  
    }
31  
  };
32  
  
33  
  // rules by space
34  
    
35  
  transient MultiMap<S, WordTokRule> rulesForSpace = litmultimap(
36  
    userSpace, ll(rule_iWantYouToBe),
37  
    objectiveSpace, ll(rule_useryWants)
38  
  );
39  
  
40  
  Set<S> rewriteInSpace(S space, Collection<S> inputs) {
41  
    ret applyWordTokRules(rulesForSpace.get(space), inputs);
42  
  }
43  
  
44  
  start-thread-printDone {
45  
    for (S input : ll("I want you to be my mother", "I want you to be my assistant")) {
46  
      print_nlBefore(input);
47  
      
48  
      // first, rewrite in user space
49  
      Set<S> outputs = rewriteInSpace(userSpace, ll(input));
50  
      pnlIndent("User space > ", outputs);
51  
      
52  
      // translate to objective space
53  
      LS outputs2 = ai_spaceToSpace(userSpace, objectiveSpace, outputs, +computerName, +userName);
54  
      pnlIndent("Objective space > ", outputs2);
55  
   
56  
      // rewrite in objective space
57  
      Set<S> outputs3 = rewriteInSpace(objectiveSpace, outputs2);
58  
      pnlIndent("Objective space > ", outputs3);
59  
      
60  
      // translate to computer space
61  
      LS outputs4 = ai_spaceToSpace(objectiveSpace, computerSpace, outputs3, +computerName, +userName);
62  
      pnlIndent("Bot space > ", outputs4);
63  
    }
64  
  }
65  
}

Author comment

Began life as a copy of #1023175

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: #1023180
Snippet name: I want you to be... [prelude spike v3, OK]
Eternal ID of this version: #1023180/31
Text MD5: 42be2934c9d38c67c6b760eb5c5f7226
Transpilation MD5: 8e52cc3826a342542d9ff5a7223bd530
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: 2019-05-16 02:58:42
Source code size: 2217 bytes / 65 lines
Pitched / IR pitched: No / No
Views / Downloads: 295 / 873
Version history: 30 change(s)
Referenced in: [show references]