static WithChoices<LS> greedySplitIntoWordsCI_withChoices(S s, Cl<S> words) { TreeSet<S> wordsSet = asCISet(words); int i = 0, last = 0; new LS out; while (i < l(s)) { int longest = l(longestPrefixInCISet(substring(s, i), wordsSet)); for (int j = l(s); j > i; j--) if (contains(wordsSet, substring(s, i, j))) { S word = prefixesInCISet(, wordsSet); if (nempty(word)) { addIfNempty(out, substring(s, last, i)); out.add(substring(s, i, i+l(word)); last = i = i+l(word); } else ++i; } addIfNempty(out, substring(s, last, i)); ret out; }
Began life as a copy of #1028147
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1028149 |
Snippet name: | greedySplitIntoWordsCI_withChoices [dev.] |
Eternal ID of this version: | #1028149/1 |
Text MD5: | e9e13080f56c1700c4766d807c17a270 |
Author: | stefan |
Category: | javax / stefan's os / nlp |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-05-23 16:42:44 |
Source code size: | 612 bytes / 18 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 207 / 219 |
Referenced in: | -