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

1  
!747
2  
!multi-line strings
3  
4  
m {
5  
  !include #1001509 // rules & statements
6  
  !include #1001512 // Synonyms
7  
  
8  
  static new Synonyms syn;
9  
  
10  
  p {
11  
    statements.add("one is a synonym of 1.");
12  
    statements.add("\"eins\" is a synonym of 1.");
13  
    statements.add("two is a synonym of 2.");
14  
    
15  
    makeSynMap();
16  
    
17  
    ask([[what are the synonyms of 1?]]);
18  
    ask([[what are the synonyms of 2?]]);
19  
  }
20  
  
21  
  static void makeSynMap() {
22  
    for (Map<S, S> m : matchStatements("$1 is a synonym of $2"))
23  
      syn.addSynonym(unquote(m.get("$1")), unquote(m.get("$2")));
24  
  }
25  
  
26  
  static void ask(S q) {
27  
    print("? " + q);
28  
    
29  
    new Map<S, S> map;
30  
    if (match4("what are the synonyms of $1?", q, map))
31  
      print("  => " + structure(syn.getSynonyms(map.get("$1"))));
32  
    else
33  
      print("dunno.");
34  
  }
35  
}

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: 637 / 694
Referenced in: [show references]