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

23
LINES

< > BotCompany Repo | #1017366 // ai_buParser1_reconstructGrouping

JavaX fragment (include)

static void ai_buParser1_reconstructGrouping(AI_BottomUpParser1 parser, AI_BottomUpParser1.Word group, S category) {
  if (!group.isGroup()) ret;
  
  MultiMap<S> superClasses = reverseMultiMap(parser.subClasses);
  Set<S> classes = makeHull_optimized(superClasses, category);
  print("Starting class " + category + ", found classes: " + classes);
  
  // a + b = c
  for (S a : keys(parser.groupingsByA))
    for (PairS bAndC : parser.groupingsByA.get(a)) {
      S b = bAndC.a, c = bAndC.b;
      if (contains(classes, c)) {
        print("Possible production: " + a + " + " + b + " = " + c);
        for (L<AI_BottomUpParser1.Word> parts : group.constituents) {
          if (l(parts) != 2) continue; // shouldn't happen
          AI_BottomUpParser1.Word partA = first(parts), partB = second(parts);
          if (!contains(partA.classes, a)) continue;
          if (!contains(partB.classes, b)) continue;
          print("  Found grouping: " + partA.text + " + " + partB.text);
        }
      }
    }
}

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: #1017366
Snippet name: ai_buParser1_reconstructGrouping
Eternal ID of this version: #1017366/4
Text MD5: e70bb8bb3aa2b8494b23a4cf1e6dd9b8
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-18 13:45:21
Source code size: 1029 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 341 / 356
Version history: 3 change(s)
Referenced in: [show references]