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

25
LINES

< > BotCompany Repo | #1017814 // nlLogic_setScriptID

JavaX fragment (include)

svoid nlLogic_setScriptID(L<IfThen> rules, fS scriptID) {
  final Set<S> ids = collectAsHashSet(rules, 'globalID);
  for (IfThen rule : rules) {
    rule.globalID = scriptID + rule.globalID;
    mapIntoSameCollection(rule.options, func(S s) -> S {
      new Matches m;
      for (S pat : splitAtVerticalBar("trumps *|conflicts with"))
        if (match(pat, s, m))
          ret format(pat, scriptID + $1);
      ret s;
    });
    nlLogic_visit(rule, voidfunc(O o) {
      S name;
      if (o cast Func) {
        if (eq(o.name, 'followingUpOn)) {
          L<S> tok = javaTok(nlLogic_text(o.arg));
          if (ids.contains(_get(tok, 1))) {
            tok.set(1, scriptID + tok.get(1));
            o.arg = Sentence2(join(tok));
          }
        }
      }
    });
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1017814
Snippet name: nlLogic_setScriptID
Eternal ID of this version: #1017814/8
Text MD5: 0936befcda06bf8699343d03cc6fbee9
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-08-14 21:44:19
Source code size: 800 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 338 / 374
Version history: 7 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)