Uses 911K of libraries. Click here for Pure Java version (5880L/30K).
1 | !7 |
2 | |
3 | cprint SnippetsDeepBitSetWordIndex { |
4 | transient ChunkedDeepBitSetWordIndex<S> wordIndex; // string = snippet ID |
5 | switchable S regexp = "\\w+"; |
6 | switchable int chunkSize = 16384; |
7 | |
8 | start-thread { |
9 | dm_reloadOnFieldChange("regexp", "chunkSize"); |
10 | time "Make bit-set word index" { |
11 | print("Making index"); |
12 | new ChunkedDeepBitSetWordIndex<S> wordIndex; |
13 | wordIndex.chunkLength = chunkSize; |
14 | wordIndex.regexp = regexp; |
15 | for (virtual CSnippet sn : dm_allSnippets()) { |
16 | S snippetID = (S) rcall snippetID(sn); |
17 | S text = cast rcall text(sn); |
18 | wordIndex.add(snippetID, text); |
19 | } |
20 | wordIndex.doneAdding(); |
21 | setField(+wordIndex); |
22 | } |
23 | infoBox("Indexed " + nWords(wordIndex.numWords())); |
24 | } |
25 | |
26 | // API |
27 | |
28 | Iterable<S> snippetPreSearch(S query, O... _) { |
29 | long nanos = nanoTime(); |
30 | Iterable<S> l; |
31 | //time "lookup" { |
32 | l = wordIndex == null ? null : wordIndex.preSearch(query, _); |
33 | //} |
34 | //print((nanoTime()-nanos) + " nanos in pre"); |
35 | ret l; |
36 | } |
37 | } |
Began life as a copy of #1029084
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: | #1029089 |
Snippet name: | Snippets Chunked Deep BitSet Word Index |
Eternal ID of this version: | #1029089/5 |
Text MD5: | 73fb311e260dd974bad0243c7886c7ee |
Transpilation MD5: | 70a8952c080c474d52e4023bcfc216fa |
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 03:20:41 |
Source code size: | 1071 bytes / 37 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 164 / 359 |
Version history: | 4 change(s) |
Referenced in: | [show references] |