Uses 911K of libraries. Click here for Pure Java version (5846L/29K).
1 | !7 |
2 | |
3 | cprint SnippetsDeepBitSetWordIndex { |
4 | transient DeepBitSetWordIndex<S> wordIndex; // string = snippet ID |
5 | switchable S regexp = "\\w+"; |
6 | |
7 | start-thread { |
8 | dm_reloadOnFieldChange regexp(); |
9 | time "Make bit-set word index" { |
10 | print("Making index"); |
11 | new DeepBitSetWordIndex<S> wordIndex; |
12 | wordIndex.regexp = regexp; |
13 | for (virtual CSnippet sn : dm_allSnippets()) { |
14 | S snippetID = (S) rcall snippetID(sn); |
15 | S text = cast rcall text(sn); |
16 | wordIndex.add(snippetID, text); |
17 | } |
18 | wordIndex.doneAdding(); |
19 | setField(+wordIndex); |
20 | } |
21 | infoBox("Indexed " + nWords(wordIndex.numWords())); |
22 | } |
23 | |
24 | // API |
25 | |
26 | Iterable<S> snippetPreSearch(S query, O... _) { |
27 | long nanos = nanoTime(); |
28 | Iterable<S> l; |
29 | //time "lookup" { |
30 | l = wordIndex == null ? null : wordIndex.preSearch(query, _); |
31 | //} |
32 | //print((nanoTime()-nanos) + " nanos in pre"); |
33 | ret l; |
34 | } |
35 | } |
Began life as a copy of #1029073
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: | #1029084 |
Snippet name: | Snippets Deep BitSet Word Index |
Eternal ID of this version: | #1029084/1 |
Text MD5: | 5460122caa1f7daaae5f4ab1898cb220 |
Transpilation MD5: | 8aba4657a58348fb27e7ea7db1a73760 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-07-19 02:20:41 |
Source code size: | 964 bytes / 35 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 190 / 307 |
Referenced in: | [show references] |