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)

static Set<S> ai_buParser_simplify(AI_BottomUpParser1 parser, AI_BottomUpParser1.Word group, S category, Map<T3<S>, S> simplifications) {
  new LinkedHashSet<S> out;
  if (group == null) ret out;
  L<T3<AI_BottomUpParser1.Word, AI_BottomUpParser1.Word, T3<S>>> groupings = ai_buParser1_reconstructedGroupings2(parser, group, category);
  print("Have " + n2(groupings, "grouping") + " for: " + group.text());
  pnl(groupings);
  for (T3<AI_BottomUpParser1.Word, AI_BottomUpParser1.Word, T3<S>> t : groupings) {
    T3<S> production = t.c;
    S simp = simplifications.get(production);
    if (eqOneOf(simp, "K", "L", "R")) {
      print("Simplifying: " + simp + " " + production);
      if (eq(simp, "L")) out.addAll(ai_buParser_simplify(parser, t.a, production.a, simplifications));
      else if (eq(simp, "R")) out.addAll(ai_buParser_simplify(parser, t.b, production.b, simplifications));
      else {
        // K
        //temp tempIndent();
        Set<S> l = ai_buParser_simplify(parser, t.a, production.a, simplifications);
        Set<S> r = ai_buParser_simplify(parser, t.b, production.b, simplifications);
        for (S ll : l)
          for (S rr : r)
            out.add(ll + " " + rr);
      }
    } else
      print("Unknown simplification for " + t.c + ": " + simp);
  }
  out.add(group.text);
  ret out;
}

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: 270 / 320
Version history: 11 change(s)
Referenced in: [show references]