Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

33
LINES

< > BotCompany Repo | #1029043 // Snippets Deep Word Pair Index [dev.]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (6214L/31K).

1  
!7
2  
3  
cprint SnippetsDeepWordPairIndex {
4  
  transient DeepWordPairIndex<S> wordIndex; // string = snippet ID
5  
  switchable S regexp = "\\w+|\\S"; // a word or a non-space
6  
7  
  start-thread {
8  
    dm_reloadOnFieldChange regexp();
9  
    time "Make double word index" {
10  
      print("Making index");
11  
      new DeepWordPairIndex<S> wordIndex;
12  
      wordIndex.regexp = regexp;
13  
      wordIndex.useHashMaps(); // faster
14  
      for (virtual CSnippet sn : dm_allSnippets()) {
15  
        S snippetID = (S) rcall snippetID(sn);
16  
        S text = cast rcall text(sn);
17  
        wordIndex.add(snippetID, text);
18  
      }
19  
      setField(+wordIndex);
20  
    }
21  
    infoBox("Indexed " + nPairs(wordIndex.numPairs()));
22  
  }
23  
  
24  
  // API
25  
  
26  
  Iterable<Pair<S, Cl<Int>>> snippetPreSearch_withPositions(S query, O... _) {
27  
    Iterable<Pair<S, Cl<Int>>> l;
28  
    //time "lookup" {
29  
      l = wordIndex == null ? null : wordIndex.lookupString_withPositions(query, _);
30  
    //}
31  
    ret l;
32  
  }
33  
}

Author comment

Began life as a copy of #1029025

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: #1029043
Snippet name: Snippets Deep Word Pair Index [dev.]
Eternal ID of this version: #1029043/3
Text MD5: 89d5a1b22d0768b4d197c71040aba4d6
Transpilation MD5: 22c6aa8c3d182702230f4f886de5a9e9
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-17 16:25:37
Source code size: 976 bytes / 33 lines
Pitched / IR pitched: No / No
Views / Downloads: 130 / 301
Version history: 2 change(s)
Referenced in: [show references]