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

25
LINES

< > BotCompany Repo | #1027551 // mmo_consistencyCheck

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3876L/25K).

1  
srecord MMOConsistencyError(int idx, S error) {}
2  
3  
// items: pairs of example inputs (line-separated) + pattern
4  
static L<MMOConsistencyError> mmo_consistencyCheck(LPairS items) {
5  
  new L<MMOConsistencyError> errors;
6  
  for i over items:
7  
    mmo_checkLocalConsistency(i, items.get(i), errors);
8  
  ret errors;
9  
}
10  
11  
svoid mmo_checkLocalConsistency(int idx, PairS qa, L<MMOConsistencyError> errors) {
12  
  LS questions = tlft(qa.a);
13  
  for (S q : questions)
14  
    if (!mmo_match_parsedPattern(qa.b, q))
15  
      errors.add(MMOConsistencyError(idx, "Example " + quote(q) + " not matched by patterns " + quote(qa.b)));
16  
}
17  
18  
svoid mmo_checkGlobalConsistency(int idx, PairS qa, LPairS items, L<MMOConsistencyError> errors) {
19  
  LS questions = tlft(qa.a);
20  
  for (S q : tlft(qa.a)) {
21  
    int idxFound = mmo_indexOfFirstMatch(q, pairsB_lazy(items));
22  
    if (idxFound >= 0 && idxFound != idx)
23  
      errors.add(new MMOConsistencyError(idx, "Example " + quote(q) + " (index " + (idx+1) + ") shadowed by patterns " + quote(items.get(idxFound).b) + " (item " + (idxFound+1) + ")");
24  
  }
25  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027551
Snippet name: mmo_consistencyCheck
Eternal ID of this version: #1027551/5
Text MD5: 2289507d66bdf2d686ed2ac675b6e92e
Transpilation MD5: f3d1125bf79b30839e51f95fff7cc388
Author: stefan
Category: javax / linux
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-03-23 20:21:06
Source code size: 1078 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 254 / 350
Version history: 4 change(s)
Referenced in: [show references]