1 | static LinkedHashSet<S> ai_parseTree_simplifiedTexts(PTElement e) { |
2 | new LinkedHashSet<S> out; |
3 | ai_parseTree_simplifiedTexts_collect(e, out); |
4 | ret out; |
5 | } |
6 | |
7 | svoid ai_parseTree_simplifiedTexts_collect(PTElement e, LinkedHashSet<S> out) { |
8 | if (e == null) ret; |
9 | PTElement ee = ai_parseTree_descendToComposite(e); |
10 | if (ee == null) ret with out.add(e.text()); |
11 | e = ee; |
12 | if (e instanceof ChoosePart) { |
13 | ai_Reconstructed r = e/ChoosePart.reconstruction; |
14 | WeightedProduction prod = r.production; |
15 | //print("Hint: " + prod.simplificationHint + " in prod: " + sfu(prod)); |
16 | //if (eq(prod.simplificationHint, "L")) out.add(r.a.text()); |
17 | //else if (eq(prod.simplificationHint, "R")) out.add(r.b.text()); |
18 | |
19 | PTElement e1 = first(e.children), e2 = second(e.children); |
20 | L<S> a = asList(ai_parseTree_simplifiedTexts(e1)); |
21 | L<S> b = asList(ai_parseTree_simplifiedTexts(e2)); |
22 | |
23 | S hint = prod.simplificationHint; |
24 | if (eqOneOf(hint, "L", "B")) insertFirst(b, ""); |
25 | /*else XXX*/ if (eqOneOf(hint, "R", "B")) insertFirst(a, ""); |
26 | |
27 | //print("L " + className(e1) + " " + className(ai_parseTree_descendToComposite(e1)) + " " + r.a.text() + " => " + a); |
28 | //print("R " + className(e2) + " " + className(ai_parseTree_descendToComposite(e2)) + " " + r.b.text() + " => " + b); |
29 | |
30 | /*for (S aa : a) |
31 | for (S bb : b) |
32 | out.add(trim(aa + " " + bb));*/ |
33 | for (PairS p : combineZigZag(a, b)) |
34 | out.add(trim(p.a + " " + p.b)); |
35 | |
36 | // Add full text too |
37 | out.add(e/ChoosePart.word.text()); |
38 | } |
39 | } |
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: | 402 / 465 |
Version history: | 21 change(s) |
Referenced in: | [show references] |