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

60
LINES

< > BotCompany Repo | #1021599 // "Big Mac" Demo [Prelude]

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

Download Jar. Libraryless. Click here for Pure Java version (10423L/76K).

1  
!7
2  
3  
sS data = [[
4  
5  
  User: Today I bought a {Big Mac} for 1 €
6  
  Bot: Wow... that's cheap! Usually they cost like... how much?
7  
  User: 5 €
8  
  Bot: Yes, yes. So that's 80% off!
9  
  
10  
  ---- Test
11  
  
12  
  User: Today I bought a car for 50 €
13  
  Bot: Wow... that's cheap! Usually they cost like... how much?
14  
  User: 5000 €
15  
  Bot: Yes, yes. So that's 99% off!
16  
17  
]];
18  
19  
p-exp {
20  
  consoleWidthCenter(1000);
21  
  
22  
  SS sections = minusSignSections(data);
23  
  F1<S, LS> tokenize = f<S, LS> javaTokWithBrackets;
24  
  LPair<S> pairs = assertNotNull(zipTwoLists_strict(
25  
    tlft(sections.get("")),
26  
    tlft(sections.get("Test"))));
27  
  pnl(pairs);
28  
  
29  
  SS map = ciMap();
30  
  for (PairS p : pairs) {
31  
    LS tokA = callF(tokenize, p.a), tokB = callF(tokenize, p.b);
32  
    if (l(tokA) != l(tokB))
33  
      continue with print("Mismatched token count, skipping: " + p);
34  
    SS map2 = gazelle_zipTwoTokenizationsToMap(tokA, tokB);
35  
    if (map2 == null) continue with warn("line not matchable: " + p);
36  
    printIndent(map2);
37  
    Set<S> newVars = setMinusSet(keys(map2), keys(map));
38  
    print("New vars: " + newVars);
39  
    print("  Rule: " + p.b + " => " + joinWithComma(map joinPairWithSpacedEquals(mapBoth optCurly(mapToPairs(map2)))));
40  
    if (!putAllStrictlyIC(map, map2)) warn("failure to merge maps");
41  
  }
42  
  print(map);
43  
  LS numberKeys = filter isInteger(keys(map));
44  
  L<Double> numbers = map parseDouble(numberKeys);
45  
  S numFunc = null;
46  
  if (l(numbers) > 1) {
47  
    numFunc = ai_findNumberCalculationFunction1(numbers);
48  
    if (numFunc != null) {
49  
      print("Found number function: " + numFunc);
50  
      LS numberValues = filter isInteger(values(map));
51  
      L<Double> numbers2 = map parseDouble(numberValues);
52  
      if (ai_checkNumberCalculationFunction1(numFunc, numbers2))
53  
        print("Number function verifies.");
54  
      else {
55  
        print("Number function doesn't verify.");
56  
        numFunc = null;
57  
      }
58  
    }
59  
  }
60  
}

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: #1021599
Snippet name: "Big Mac" Demo [Prelude]
Eternal ID of this version: #1021599/23
Text MD5: 3329109ea4b448d770ffe6545ca7f832
Transpilation MD5: 48cdb60aa9c90ab28dc20bf0f3b6dbaa
Author: stefan
Category: javax / a.i.
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-02-22 10:58:33
Source code size: 1947 bytes / 60 lines
Pitched / IR pitched: No / No
Views / Downloads: 608 / 1666
Version history: 22 change(s)
Referenced in: [show references]