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

48
LINES

< > BotCompany Repo | #1008342 // Do you ship to...? [WORKS, v2, improved parsing]

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

Libraryless. Click here for Pure Java version (11426L/80K/262K).

1  
!7
2  
3  
sS questions = [[
4  
  Do you ship to Norway? => Yes
5  
  Do you ship to Oslo? => Yes
6  
  Do you ship to Australia? => Sorry, we cannot ship there.
7  
  Do you ship to Melbourne? => Sorry, we cannot ship there.
8  
]];
9  
10  
sS facts = [[
11  
  We ship to Norway
12  
  We don't ship to Australia
13  
  
14  
  Melbourne is in Australia
15  
  Oslo is in Norway
16  
]];
17  
18  
sS rules = [[
19  
  Q: Do you ship to X?
20  
    (We ship to X) => A: Yes
21  
    (We don't ship to X) => A: Sorry, we cannot ship there.
22  
    (We ship to X for a fee of Y) => A: Yes, for a fee of Y we will ship to X.
23  
    (X is in Y) => Replace question with: Do you ship to Y?
24  
    
25  
  Always: (Replace question with: X) => Q: X
26  
  
27  
  lvjqbruihqmsgckd - Do you ship to X?
28  
  aileauajpxpgymdj - We ship to X
29  
  siacyutikdvksvwp - We don't ship to X
30  
  zlrmmqtlczxnjabk - Sorry, we cannot ship there.
31  
  vzfbivkrprmgghhp - Replace question with: X
32  
  wmwqvagqbsfenmtf - X is in Y
33  
]];
34  
35  
p {
36  
  rules = rules_unfoldIndented(rules, "Always: ");
37  
  print(rules);
38  
  myTruthNonPersist(facts + standardConcepts() + rules);
39  
  lispCheckQuestionsVerbose(questions);
40  
  lispBot();
41  
}
42  
43  
static Lisp englishToLisp_best(S s) {
44  
  s = trim(s);
45  
  S x = dropPunctuationAtEnd(s);
46  
  ret englishToLisp_bestParse(s, endsWith(s, "?") ? null : s + "?",
47  
    x, endsWith(x, "?") ? null : x + "?");
48  
}

Author comment

Began life as a copy of #1008320

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1008342
Snippet name: Do you ship to...? [WORKS, v2, improved parsing]
Eternal ID of this version: #1008342/6
Text MD5: 412ad764f44babcded01d4550194c6c0
Transpilation MD5: f76e4bcb72b745b2d41f3b12f5dae78a
Author: stefan
Category: javax / a.i.
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-08-13 20:33:11
Source code size: 1320 bytes / 48 lines
Pitched / IR pitched: No / No
Views / Downloads: 426 / 506
Version history: 5 change(s)
Referenced in: [show references]