1 | sclass FullPhraseCache { |
2 | L<LS> phrases; // different spellings of full phrase |
3 | Map<S, FullPhraseCache> byFirstWord; |
4 | |
5 | Map<S, FullPhraseCache> byFirstWord_init() { |
6 | if (byFirstWord == null) |
7 | byFirstWord = ciMap(); |
8 | ret byFirstWord; |
9 | } |
10 | |
11 | void add(S phrase) { |
12 | LS tok = javaTokNPunctuation_cached(phrase); |
13 | if (l(tok) == 1) ret; |
14 | add(tok, 1); |
15 | } |
16 | |
17 | void add(LS tok, int idx) { |
18 | if (idx >= l(tok)-1) |
19 | ret with phrases = createOrAddToList(phrases, tok); |
20 | FullPhraseCache subCache = getOrCreate(byFirstWord_init(), tok.get(idx), FullPhraseCache); |
21 | subCache.add(tok, idx+2); |
22 | } |
23 | } |
Began life as a copy of #1022266
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1022303 |
Snippet name: | FullPhraseCache - as tree over words |
Eternal ID of this version: | #1022303/7 |
Text MD5: | 6bbcb3934a581292adcaf198b4703d87 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-03-13 05:31:30 |
Source code size: | 640 bytes / 23 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 307 / 768 |
Version history: | 6 change(s) |
Referenced in: | [show references] |