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

27
LINES

< > BotCompany Repo | #1017382 // ai_buParser1_reconstructedGroupings2 - with productions

JavaX fragment (include)

1  
static L<T3<AI_BottomUpParser1.Word, AI_BottomUpParser1.Word, T3<S>>> ai_buParser1_reconstructedGroupings2(AI_BottomUpParser1 parser, AI_BottomUpParser1.Word group, S category) {
2  
  L<T3<AI_BottomUpParser1.Word, AI_BottomUpParser1.Word, T3<S>>> l = new L;
3  
  if (group == null || !group.isGroup()) ret l;
4  
  
5  
  MultiMap<S> superClasses = reverseMultiMap(parser.subClasses);
6  
  Set<S> classes = makeHull_optimized(superClasses, category);
7  
8  
  // a + b = c
9  
  for (S a : keys(parser.groupingsByA))
10  
    for (PairS bAndC : parser.groupingsByA.get(a)) {
11  
      S b = bAndC.a, c = bAndC.b;
12  
      if (contains(classes, c)) {
13  
        //print("Possible production: " + a + " + " + b + " = " + c);
14  
        for (L<AI_BottomUpParser1.Word> parts : group.constituents) {
15  
          if (l(parts) != 2) continue; // shouldn't happen
16  
          AI_BottomUpParser1.Word partA = first(parts), partB = second(parts);
17  
          if (!contains(partA.classes, a)) continue;
18  
          if (!contains(partB.classes, b)) continue;
19  
          T3<S> production = t3(a, b, c);
20  
          l.add(t3(partA, partB, production));
21  
          //print("  Found grouping: " + partA.text + " + " + partB.text);
22  
        }
23  
      }
24  
    }
25  
  
26  
  ret l;
27  
}

Author comment

Began life as a copy of #1017377

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: #1017382
Snippet name: ai_buParser1_reconstructedGroupings2 - with productions
Eternal ID of this version: #1017382/3
Text MD5: 162cbc529b17846e0766320bd80985ff
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 16:09:21
Source code size: 1222 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 262 / 299
Version history: 2 change(s)
Referenced in: [show references]