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

27
LINES

< > BotCompany Repo | #1017377 // ai_buParser1_reconstructedGroupings

JavaX fragment (include)

static L<Pair<AI_BottomUpParser1.Word>> ai_buParser1_reconstructedGroupings(AI_BottomUpParser1 parser, AI_BottomUpParser1.Word group, S category) {
  L<Pair<AI_BottomUpParser1.Word>> l = new L;
  if (group == null || !group.isGroup()) ret l;
  
  // add subclasses of outer category
  MultiMap<S> finerClasses = reverseMultiMap(parser.subClasses);
  Set<S> classes = makeHull_optimized(finerClasses, category);

  // 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;
          l.add(pair(partA, partB));
          //print("  Found grouping: " + partA.text + " + " + partB.text);
        }
      }
    }
  
  ret l;
}

Author comment

Began life as a copy of #1017366

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: #1017377
Snippet name: ai_buParser1_reconstructedGroupings
Eternal ID of this version: #1017377/4
Text MD5: 844fea17330cd3adfb5906882d03ffb0
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 17:12:36
Source code size: 1147 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 284 / 348
Version history: 3 change(s)
Referenced in: [show references]