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

25
LINES

< > BotCompany Repo | #1017388 // ai_buParser1_reconstructedProductions

JavaX fragment (include)

static L<ai_Reconstructed> ai_buParser1_reconstructedProductions(AI_BottomUpParser1 parser, L<WeightedProduction> productions, AI_BottomUpParser1.Word group, S category) {
  L<ai_Reconstructed> l = new L;
  if (group == null) ret l;
  
  for (WeightedProduction prod : productions)
    if (eq(category, prod.c)) {
      //print("Matching prod: " + sfu(prod));
      if (prod.b == null) {
        if (group.hasClass(prod.a))
          l.add(ai_Reconstructed(prod, group));
        continue;
      }
        
      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, prod.a)) continue;
        if (!contains(partB.classes, prod.b)) continue;
        l.add(ai_Reconstructed(prod, partA, partB));
        //print("  Found grouping: " + partA.text + " + " + partB.text);
      }
    }

  ret l;
}

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: #1017388
Snippet name: ai_buParser1_reconstructedProductions
Eternal ID of this version: #1017388/13
Text MD5: 9f3dae3a4777ff539eff4b8460f71b9a
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 19:39:35
Source code size: 996 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 340 / 378
Version history: 12 change(s)
Referenced in: [show references]