1 | static L<S dropSuffixUsingWordTree_all(L<S> tok, Map<S, O> tree) { |
2 | |
3 | } |
4 | |
5 | // tok = CNC |
6 | // returns [(index, tree leaf)] |
7 | static LPair<Int, O> matchEndUsingWordTree_all(L<S> tok, Map<S, O> tree) { |
8 | O best = null; // best leaf |
9 | int bestIndex = 0; // best index |
10 | |
11 | int j = l(tok)-2; |
12 | LPair<Int, O> out = new L; |
13 | while (j > 0) { |
14 | O def = tree.get("<default>"); |
15 | if (def != null) { best = def; bestIndex = j; } |
16 | |
17 | O t = tree.get(tok.get(j)); |
18 | if (t == null) break; |
19 | if (!t instanceof Map) break with addPair(out, j, t); // leaf! |
20 | j -= 2; |
21 | tree = (Map) t; |
22 | } |
23 | |
24 | if (best != null) addPair(out, bestIndex, best); |
25 | ret out; |
26 | } |
Began life as a copy of #1018103
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1018104 |
Snippet name: | dropSuffixUsingWordTree_all [dev.] |
Eternal ID of this version: | #1018104/1 |
Text MD5: | 60353334bfd444bbd225f16374fa6111 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-09-02 13:09:48 |
Source code size: | 671 bytes / 26 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 284 / 320 |
Referenced in: | [show references] |