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

77
LINES

< > BotCompany Repo | #1007881 // Testing new englishToConceptLanguage_xyz [dev.]

JavaX source code (desktop) [tags: archive use-pretranspiled] - run with: x30.jar

Download Jar. Uses 4489K of libraries. Click here for Pure Java version (13297L/95K).

!7

!include #1007880

sS theRiddle = [[
  What did Magnus Carlsen eat for breakfast?
]];

sS theFacts = [[
  Magnus Carlsen lives in Norway.
  In Norway, they eat fish.
  Jan Gustafsson lives in Germany.
  John Doe lives in Germany.
  In Germany, they eat Bratwurst.
  
  (Q: What did X eat for breakfast?) and (X lives in Y.) and (In Y, they eat Z.) => (A: Probably Z!)
]];

sS concepts = [[
  ["vouwrrhtmajsgaby", "Q: X"],
  ["nywfcwkkcknzhmdy", "A: X"],
  ["zlydvmmyckgcyrak", "Magnus Carlsen"],
  ["verqumbshvchuquw", "Norway"],
  ["wvqzrhdaqnygqgll", "Fish"],
  ["bzvabitchqhqkldm", "In X, they eat Y."],
  ["pizxszvxocdluica", "What did X eat for Y?"],
  ["fhsukilpoasgkvcs", "X lives in Y."],
  ["oceicdfeiyftxuwi", "Probably X!"],
  ["eijdjqhyzheusetj", "(X) and (Y) and (Z) => (AA)"],
]];

svoid createWeb(Web web, Lisp riddle) {}

svoid calc(Web web, Lisp riddle) {
  //print("Vars: " + vars);
  for (LispStatement ls : lispStatementsByHead("eijdjqhyzheusetj")) {
    Lisp rule = ls.term;
    L<Lisp> conditions = dropLast(rule.args);
    Lisp out = last(rule.args);
    
    new Map<S, Lisp> matches;
    if (matchConditions(conditions, matches, riddle)) {
      //print("Yo! " + struct(matches));
      web.node(lispReplaceVars(out, matches));
    }
  }
}

static bool matchConditions(L<Lisp> conditions, Map<S, Lisp> m, Lisp riddle) {
  if (empty(conditions)) true;
  Lisp cond = first(conditions);
  for (Lisp fact : concatLists(ll(riddle), facts)) {
    Map<S, Lisp> m2 = cloneMap(m);
    if (lispMatchIC_sub(cond, fact, vars, m2)) {
      if (matchConditions(dropFirst(conditions), m2, riddle)) {
        m.putAll(m2);
        true;
      }
    }
  }
  false;
}

sS getAnswer(Web web) {
  Lisp l = web_nodeByHead(web, "nywfcwkkcknzhmdy");
  if (l != null)
    ret crazyEnglishFixing(conceptLanguageToEnglish_rec(l.get(0)));
  null;
}

p {
  set englishToConceptLanguage_xyz_debug;
  setConsoleInput(firstLineFullTrim(theRiddle));
  pConsoleThoughtMachine();
}

!include #1007815 // Console Thought Machine

Author comment

Began life as a copy of #1007814

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): cfunsshuasjs, mqqgnosmbjvj, tvejysmllsmz

No comments. add comment

Snippet ID: #1007881
Snippet name: Testing new englishToConceptLanguage_xyz [dev.]
Eternal ID of this version: #1007881/2
Text MD5: 37813a5fc3603e2c5600ab32f8b8b5d1
Transpilation MD5: d353562a7949fbee87d222237923783d
Author: stefan
Category: javax
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): Yes
Created/modified: 2017-04-13 17:29:49
Source code size: 2098 bytes / 77 lines
Pitched / IR pitched: No / No
Views / Downloads: 502 / 880
Version history: 1 change(s)
Referenced in: [show references]