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

42
LINES

< > BotCompany Repo | #1014066 // simplifyMatchJob1

JavaX fragment (include)

1  
// uses ai_placeholderToList
2  
static S simplifyMatchJob1(MatchJob mj) {
3  
  if (empty(mj.input) || empty(mj.struct)) ret "Solved";
4  
  if (eqic(first(mj.input), first(mj.struct))) {
5  
    matchJob_apply(f dropFirst, mj);
6  
    ret "Simplified";
7  
  }
8  
  if (eqic(last(mj.input), last(mj.struct))) {
9  
    matchJob_apply(f dropLast, mj);
10  
    ret "Simplified";
11  
  }
12  
  
13  
  // Full match with category
14  
  if (l(mj.struct) == 1 && isAngleBracketed(first(mj.struct))) {
15  
    S placeholder = deAngleBracket(first(mj.struct));
16  
    S list = ai_placeholderToList().get(placeholder);
17  
    if (list != null) {
18  
      bool contained = mechList_containsTokens(list, mj.input);
19  
      if (contained) {
20  
        mj.vars.put(placeholder, joinWithSpace(mj.input));
21  
        mj.clear();
22  
        ret "Simplified";
23  
      }
24  
    }
25  
  }
26  
  
27  
  // Match leading category with first word
28  
  if (isAngleBracketed(first(mj.struct))) {
29  
    S placeholder = deAngleBracket(first(mj.struct));
30  
    S list = ai_placeholderToList().get(placeholder);
31  
    if (list != null) {
32  
      bool contained = mechList_containsTokens(list, ll(first(mj.input)));
33  
      if (contained) {
34  
        mj.vars.put(placeholder, first(mj.input));
35  
        matchJob_apply(f dropFirst, mj);
36  
        ret "Simplified";
37  
      }
38  
    }
39  
  }
40  
  
41  
  ret "Nothing to do";
42  
}

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: #1014066
Snippet name: simplifyMatchJob1
Eternal ID of this version: #1014066/1
Text MD5: d63c424f5d9c53bdce4887747828bb50
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-03-27 22:19:19
Source code size: 1314 bytes / 42 lines
Pitched / IR pitched: No / No
Views / Downloads: 306 / 347
Referenced in: [show references]