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

!7

sS questions = [[
  Do you ship to Norway? => Yes
  Do you ship to Oslo? => Yes
  Do you ship to Australia? => Sorry, we cannot ship there.
  Do you ship to Melbourne? => Sorry, we cannot ship there.
]];

sS facts = [[
  We ship to Norway
  We don't ship to Australia
  
  Melbourne is in Australia
  Oslo is in Norway
]];

sS rules = [[
  Q: Do you ship to X?
    (We ship to X) => A: Yes
    (We don't ship to X) => A: Sorry, we cannot ship there.
    (We ship to X for a fee of Y) => A: Yes, for a fee of Y we will ship to X.
    (X is in Y) => Replace question with: Do you ship to Y?
    
  Always: (Replace question with: X) => Q: X
  
  lvjqbruihqmsgckd - Do you ship to X?
  aileauajpxpgymdj - We ship to X
  siacyutikdvksvwp - We don't ship to X
  zlrmmqtlczxnjabk - Sorry, we cannot ship there.
  vzfbivkrprmgghhp - Replace question with: X
  wmwqvagqbsfenmtf - X is in Y
]];

p {
  rules = rules_unfoldIndented(rules, "Always: ");
  print(rules);
  myTruthNonPersist(facts + standardConcepts() + rules);
  lispCheckQuestionsVerbose(questions);
  lispBot();
}

static Lisp englishToLisp_best(S s) {
  s = trim(s);
  S x = dropPunctuationAtEnd(s);
  ret englishToLisp_bestParse(s, endsWith(s, "?") ? null : s + "?",
    x, endsWith(x, "?") ? null : x + "?");
}

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: 518 / 635
Version history: 5 change(s)
Referenced in: [show references]