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

35
LINES

< > BotCompany Repo | #1001513 // Synonyms (with include)

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

Libraryless. Click here for Pure Java version (676L/5K/17K).

!747
!multi-line strings

m {
  !include #1001509 // rules & statements
  !include #1001512 // Synonyms
  
  static new Synonyms syn;
  
  p {
    statements.add("one is a synonym of 1.");
    statements.add("\"eins\" is a synonym of 1.");
    statements.add("two is a synonym of 2.");
    
    makeSynMap();
    
    ask([[what are the synonyms of 1?]]);
    ask([[what are the synonyms of 2?]]);
  }
  
  static void makeSynMap() {
    for (Map<S, S> m : matchStatements("$1 is a synonym of $2"))
      syn.addSynonym(unquote(m.get("$1")), unquote(m.get("$2")));
  }
  
  static void ask(S q) {
    print("? " + q);
    
    new Map<S, S> map;
    if (match4("what are the synonyms of $1?", q, map))
      print("  => " + structure(syn.getSynonyms(map.get("$1"))));
    else
      print("dunno.");
  }
}

Author comment

Began life as a copy of #1001511

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1001513
Snippet name: Synonyms (with include)
Eternal ID of this version: #1001513/1
Text MD5: 4b86cd9877345af00e3a7b5557cd05bc
Transpilation MD5: 660aa073c56d3c52b4caee26325e6aed
Author: stefan
Category:
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-10-21 16:35:20
Source code size: 839 bytes / 35 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 636 / 691
Referenced in: [show references]