static int fullPhraseCache_longestPhraseLength(FullPhraseCache cache, LS tok) { ret fullPhraseCache_longestPhraseLength(cache, tok, 1); } // returns index of C token in tok after longest match static int fullPhraseCache_longestPhraseLength(FullPhraseCache cache, LS tok, int idx) { if (cache == null || tok == null) ret -1; int longest = -1; if (nempty(cache.phrases)) longest = idx; while (idx < l(tok)-1) { ifdef fullPhraseCache_longestPhraseLength_debug print("longest=" + longest + ", idx=" + idx + ", phrases=" + cache.phrases + ", next token= " + quote(tok.get(idx))); endifdef cache = mapGet(cache.byFirstWord, tok.get(idx)); if (cache == null) break; idx += 2; if (nempty(cache.phrases)) longest = idx; } ret longest; } static int fullPhraseCache_longestPhraseLength(FullPhraseCache cache, S s) { if (cache == null || s == null) ret -1; ret fullPhraseCache_longestPhraseLength(cache, javaTokNPunctuation_cached(s)); }
Began life as a copy of #1022306
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: | #1022307 |
Snippet name: | fullPhraseCache_longestPhraseLength - returns C index after longest match |
Eternal ID of this version: | #1022307/12 |
Text MD5: | 13ef1d5f5f10fa7004490f78a5ef416c |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-01-02 13:54:19 |
Source code size: | 999 bytes / 25 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 328 / 350 |
Version history: | 11 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |