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

27
LINES

< > BotCompany Repo | #1017549 // nlLogic_parseRule

JavaX fragment (include)

static IfThen nlLogic_parseRule(S s) {
  new IfThen rule;
  rule.originalText = s;
  L<S> tok = javaTokPlusBrackets2(s);
  if (isSquareBracketed(get(tok, 1))) {
    L<S> tokOptions = javaTokPlusBrackets2(deSquareBracket(get(tok, 1)));
    new Matches m;
    for (S option : tok_splitAtComma(tokOptions)) {
      if (startsWith_trim(option, "id: ", m))
        rule.globalID = m.rest();
      else
        rule.options = linkedHashSet_addWithAutoInit(rule.options, option);
    }
    tok = dropFirst(2, tok);
  }
  
  L<S> l = splitAtDoubleArrow(tok);
  if (l(l) > 2 || l(l) == 0) null;
  rule.out = nlLogic_parseExpression(last(l));
  rule.in = nlLogic_parseExpression(nextToLast(l));
  
  if (rule.globalID == null)
    //rule.globalID = aGlobalID();
    rule.globalID = textMD5ToGlobalID(str(rule));
    
  ret rule;
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1017549
Snippet name: nlLogic_parseRule
Eternal ID of this version: #1017549/11
Text MD5: ac460622b327823edc8abfad46116e14
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-23 15:12:37
Source code size: 846 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 398 / 495
Version history: 10 change(s)
Referenced in: [show references]