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

1  
!7
2  
3  
!include #1007880
4  
5  
sS theRiddle = [[
6  
  What did Magnus Carlsen eat for breakfast?
7  
]];
8  
9  
sS theFacts = [[
10  
  Magnus Carlsen lives in Norway.
11  
  In Norway, they eat fish.
12  
  Jan Gustafsson lives in Germany.
13  
  John Doe lives in Germany.
14  
  In Germany, they eat Bratwurst.
15  
  
16  
  (Q: What did X eat for breakfast?) and (X lives in Y.) and (In Y, they eat Z.) => (A: Probably Z!)
17  
]];
18  
19  
sS concepts = [[
20  
  ["vouwrrhtmajsgaby", "Q: X"],
21  
  ["nywfcwkkcknzhmdy", "A: X"],
22  
  ["zlydvmmyckgcyrak", "Magnus Carlsen"],
23  
  ["verqumbshvchuquw", "Norway"],
24  
  ["wvqzrhdaqnygqgll", "Fish"],
25  
  ["bzvabitchqhqkldm", "In X, they eat Y."],
26  
  ["pizxszvxocdluica", "What did X eat for Y?"],
27  
  ["fhsukilpoasgkvcs", "X lives in Y."],
28  
  ["oceicdfeiyftxuwi", "Probably X!"],
29  
  ["eijdjqhyzheusetj", "(X) and (Y) and (Z) => (AA)"],
30  
]];
31  
32  
svoid createWeb(Web web, Lisp riddle) {}
33  
34  
svoid calc(Web web, Lisp riddle) {
35  
  //print("Vars: " + vars);
36  
  for (LispStatement ls : lispStatementsByHead("eijdjqhyzheusetj")) {
37  
    Lisp rule = ls.term;
38  
    L<Lisp> conditions = dropLast(rule.args);
39  
    Lisp out = last(rule.args);
40  
    
41  
    new Map<S, Lisp> matches;
42  
    if (matchConditions(conditions, matches, riddle)) {
43  
      //print("Yo! " + struct(matches));
44  
      web.node(lispReplaceVars(out, matches));
45  
    }
46  
  }
47  
}
48  
49  
static bool matchConditions(L<Lisp> conditions, Map<S, Lisp> m, Lisp riddle) {
50  
  if (empty(conditions)) true;
51  
  Lisp cond = first(conditions);
52  
  for (Lisp fact : concatLists(ll(riddle), facts)) {
53  
    Map<S, Lisp> m2 = cloneMap(m);
54  
    if (lispMatchIC_sub(cond, fact, vars, m2)) {
55  
      if (matchConditions(dropFirst(conditions), m2, riddle)) {
56  
        m.putAll(m2);
57  
        true;
58  
      }
59  
    }
60  
  }
61  
  false;
62  
}
63  
64  
sS getAnswer(Web web) {
65  
  Lisp l = web_nodeByHead(web, "nywfcwkkcknzhmdy");
66  
  if (l != null)
67  
    ret crazyEnglishFixing(conceptLanguageToEnglish_rec(l.get(0)));
68  
  null;
69  
}
70  
71  
p {
72  
  set englishToConceptLanguage_xyz_debug;
73  
  setConsoleInput(firstLineFullTrim(theRiddle));
74  
  pConsoleThoughtMachine();
75  
}
76  
77  
!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: 667 / 1334
Version history: 1 change(s)
Referenced in: [show references]