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

28
LINES

< > BotCompany Repo | #1017383 // ai_buParser_simplify (old)

JavaX fragment (include)

1  
static Set<S> ai_buParser_simplify(AI_BottomUpParser1 parser, AI_BottomUpParser1.Word group, S category, Map<T3<S>, S> simplifications) {
2  
  new LinkedHashSet<S> out;
3  
  if (group == null) ret out;
4  
  L<T3<AI_BottomUpParser1.Word, AI_BottomUpParser1.Word, T3<S>>> groupings = ai_buParser1_reconstructedGroupings2(parser, group, category);
5  
  print("Have " + n2(groupings, "grouping") + " for: " + group.text());
6  
  pnl(groupings);
7  
  for (T3<AI_BottomUpParser1.Word, AI_BottomUpParser1.Word, T3<S>> t : groupings) {
8  
    T3<S> production = t.c;
9  
    S simp = simplifications.get(production);
10  
    if (eqOneOf(simp, "K", "L", "R")) {
11  
      print("Simplifying: " + simp + " " + production);
12  
      if (eq(simp, "L")) out.addAll(ai_buParser_simplify(parser, t.a, production.a, simplifications));
13  
      else if (eq(simp, "R")) out.addAll(ai_buParser_simplify(parser, t.b, production.b, simplifications));
14  
      else {
15  
        // K
16  
        //temp tempIndent();
17  
        Set<S> l = ai_buParser_simplify(parser, t.a, production.a, simplifications);
18  
        Set<S> r = ai_buParser_simplify(parser, t.b, production.b, simplifications);
19  
        for (S ll : l)
20  
          for (S rr : r)
21  
            out.add(ll + " " + rr);
22  
      }
23  
    } else
24  
      print("Unknown simplification for " + t.c + ": " + simp);
25  
  }
26  
  out.add(group.text);
27  
  ret out;
28  
}

Author comment

Began life as a copy of #1017382

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: #1017383
Snippet name: ai_buParser_simplify (old)
Eternal ID of this version: #1017383/12
Text MD5: 45db63e58af251d437539ce91d65f3be
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-07-19 21:35:25
Source code size: 1349 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 344 / 391
Version history: 11 change(s)
Referenced in: [show references]