static LinkedHashSet<S> ai_parseTree_simplifiedTexts(PTElement e) { new LinkedHashSet<S> out; ai_parseTree_simplifiedTexts_collect(e, out); ret out; } svoid ai_parseTree_simplifiedTexts_collect(PTElement e, LinkedHashSet<S> out) { if (e == null) ret; PTElement ee = ai_parseTree_descendToComposite(e); if (ee == null) ret with out.add(e.text()); e = ee; if (e instanceof ChoosePart) { ai_Reconstructed r = e/ChoosePart.reconstruction; WeightedProduction prod = r.production; //print("Hint: " + prod.simplificationHint + " in prod: " + sfu(prod)); //if (eq(prod.simplificationHint, "L")) out.add(r.a.text()); //else if (eq(prod.simplificationHint, "R")) out.add(r.b.text()); PTElement e1 = first(e.children), e2 = second(e.children); L<S> a = asList(ai_parseTree_simplifiedTexts(e1)); L<S> b = asList(ai_parseTree_simplifiedTexts(e2)); S hint = prod.simplificationHint; if (eqOneOf(hint, "L", "B")) insertFirst(b, ""); /*else XXX*/ if (eqOneOf(hint, "R", "B")) insertFirst(a, ""); //print("L " + className(e1) + " " + className(ai_parseTree_descendToComposite(e1)) + " " + r.a.text() + " => " + a); //print("R " + className(e2) + " " + className(ai_parseTree_descendToComposite(e2)) + " " + r.b.text() + " => " + b); /*for (S aa : a) for (S bb : b) out.add(trim(aa + " " + bb));*/ for (PairS p : combineZigZag(a, b)) out.add(trim(p.a + " " + p.b)); // Add full text too out.add(e/ChoosePart.word.text()); } }
Began life as a copy of #1017407
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: | #1017408 |
Snippet name: | ai_parseTree_simplifiedTexts |
Eternal ID of this version: | #1017408/22 |
Text MD5: | eb21f6e0c19a411271692dddc8663276 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-08-07 20:37:48 |
Source code size: | 1577 bytes / 39 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 400 / 462 |
Version history: | 21 change(s) |
Referenced in: | [show references] |