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

44
LINES

< > BotCompany Repo | #1002524 // Wildcard Thesaurus Bot (LIVE)

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

Libraryless. Click here for Pure Java version (1723L/11K/38K).

1  
!759
2  
3  
static new Map<S, S> thesaurusMap;
4  
5  
p {
6  
  load("thesaurusMap");
7  
}
8  
9  
synchronized answer {
10  
  if "add thesaurus2 * *" {
11  
    S key = m.unq(0), value = m.unq(1);
12  
    if (match(key, value))
13  
      ret "You nasty rascal, don't do the endless loop!";
14  
    thesaurusMap.put(key, value);
15  
    save("thesaurusMap");
16  
    ret "OK, saved! Thesaurus size now: " + l(thesaurusMap);
17  
  }
18  
  
19  
  if "remove thesaurus2 *" {
20  
    S key = m.unq(0);
21  
    ret thesaurusMap.remove(key) != null ? "Removed." : "Not found...";
22  
  }
23  
  
24  
  if "thesaurus2 size"
25  
    ret lstr(thesaurusMap);
26  
  
27  
  if "list thesaurus2"
28  
    ret structure(thesaurusMap);
29  
  
30  
  for (S key : keys(thesaurusMap))
31  
    if (match(key, s, m)) {
32  
      S a = askSelf(rewrite(thesaurusMap.get(key), m));
33  
      if (nempty(a)) {
34  
        getInvolvedBots().add(formatSnippetID(programID()));
35  
        ret a;
36  
      }
37  
    }
38  
}
39  
40  
static S rewrite(S pattern, Matches m) {
41  
  for (int i = 0; i < l(m.m); i++)
42  
    m.m[i] = unquote(m.m[i]);
43  
  ret format(pattern, m.m);
44  
}

Author comment

Began life as a copy of #1002480

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: #1002524
Snippet name: Wildcard Thesaurus Bot (LIVE)
Eternal ID of this version: #1002524/1
Text MD5: 6a8323678fa37863109b6169a79aac28
Transpilation MD5: a1a0fb42c5454b98c90ff0ab25a13ad7
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-04-16 18:21:21
Source code size: 1032 bytes / 44 lines
Pitched / IR pitched: No / No
Views / Downloads: 660 / 1157
Referenced in: [show references]