1 | static L<WeightedProduction> ai_buParser_parseWeightedProductions() { |
2 | ret ai_buParser_parseWeightedProductions(mL_raw(ai_language() + " bottom-up groupings")); |
3 | } |
4 | |
5 | static L<WeightedProduction> ai_buParser_parseWeightedProductions(S text) { |
6 | new L<WeightedProduction> l; |
7 | for (S s : tlftj(text)) { |
8 | s = trim(javaDropAllComments(s)); |
9 | L<S> meta = trimAll(tok_splitAtComma(trailingAngleBracketStuff(s))); |
10 | s = dropTrailingAngleBracketStuff(s); |
11 | //print("s=" + s +", meta=" + meta); |
12 | L<S> tok = javaTokWithAngleBracketsC(s); |
13 | WeightedProduction p = null; |
14 | double weight = 1.0; |
15 | S f = null; |
16 | for (S met : meta) |
17 | if (startsWithDigit(met)) |
18 | weight = parseDouble(met); |
19 | else if (startsWith(met, "ai")) |
20 | f = met; |
21 | if (l(tok) == 5) |
22 | p = WeightedProduction(tok.get(0), tok.get(2), tok.get(4), weight); |
23 | else if (l(tok) == 3) |
24 | p = WeightedProduction(tok.get(0), tok.get(2), weight); |
25 | |
26 | if (p != null) { |
27 | p.plausibilityFunction = f; |
28 | for (S met : meta) |
29 | if (eqOneOf(met, "L", "R", "B")) { |
30 | //print("Have simplification hint: " + met); |
31 | p.simplificationHint = met; |
32 | } |
33 | l.add(p); |
34 | } |
35 | } |
36 | ret l; |
37 | } |
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: | #1017390 |
Snippet name: | ai_buParser_parseWeightedProductions |
Eternal ID of this version: | #1017390/15 |
Text MD5: | f6d219047ded5700debd0f898bdcd34e |
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-20 11:59:14 |
Source code size: | 1246 bytes / 37 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 449 / 497 |
Version history: | 14 change(s) |
Referenced in: | [show references] |