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).

!7

cmodule IWantYouToBePrelude > DynPrintLog {
  // spaces & names
  
  sS objectiveSpace = 'objective, computerSpace = 'computer, userSpace = 'user;
  transient S userName = "usery", computerName = "computery";
  
  // the facts
  
  transient Set<S> 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<S, WordTokRule> rulesForSpace = litmultimap(
    userSpace, ll(rule_iWantYouToBe),
    objectiveSpace, ll(rule_useryWants)
  );
  
  Set<S> rewriteInSpace(S space, Collection<S> 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<S> 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<S> 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);
    }
  }
}

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: 418 / 1024
Version history: 30 change(s)
Referenced in: #1023195 - MultiSpaceReasoning1
#1023210 - I want you to be... [prelude spike v4, extended strings, OK]