Libraryless. Click here for Pure Java version (3871L/24K).
// returns a prefiltered list of elements; you still need to do a // full-text search on those. // If it returns null, you have to search all elements static <A> Cl<A> wordIndex_lookupString(WordIndex<A> index, S query) { L<IntRange> ranges = index.wordRanges(query); if (empty(ranges)) null; new L<Set<A>> sets; for (IntRange r : ranges) { // go through words in query S word = substring(query, r); Set<A> l; if (r.start == 0) if (r.end == l(query)) l = msmGetAllAsSet(index.index, containingIC(index.words(), word)); else l = msmGetAllAsSet(index.index, endingWithIC(index.words(), word)); else if (r.end == l(query)) l = msmGetAllAsSet(index.index, prefixSubSet(index.words(), word)); else l = index.get(word); if (empty(l)) ret l; sets.add(l); } Set<A> smallest = smallestCollection(sets), out = smallest; for (Set<A> set : sets) { if (set == smallest) continue; new Set<A> out2; for (A a : out) if (set.contains(a)) out2.add(a); out = out2; } ret out; }
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: | #1028973 |
Snippet name: | wordIndex_lookupString |
Eternal ID of this version: | #1028973/12 |
Text MD5: | 2122ffc37290d0a75f35ff1d27fe436a |
Transpilation MD5: | 016383dfc319861b4032be792faf4fb5 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-07-15 13:33:53 |
Source code size: | 1110 bytes / 34 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 266 / 402 |
Version history: | 11 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1029005 - doubleWordIndex_lookupString |