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

25
LINES

< > BotCompany Repo | #1028972 - Snippets Word Index [OK]

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

Uses 824K of libraries. Click here for Pure Java version (4043L/20K).

!7

cprint SnippetsWordIndex {
  transient WordIndex<S> wordIndex; // word to snippet ID

  start-thread {
    time "Make word index" {
      new WordIndex<S> wordIndex;
      for (virtual CSnippet sn : dm_allSnippets()) {
        S snippetID = (S) rcall snippetID(sn);
        S text = cast rcall text(sn);
        wordIndex.add(snippetID, text);
      }
      setField(+wordIndex);
    }
    print("Indexed " + nWords(wordIndex.numWords()));
  }
  
  // API
  
  // may return null (no pre-search result)
  Cl<S> snippetsContainingTextIC_preSearch(S query) {
    ret wordIndex_lookupString(wordIndex, query);
  }
}

Author comment

Began life as a copy of #1028945

download  show line numbers  debug dex   

Travelled to 5 computer(s): bhatertpkbcr, mqqgnosmbjvj, pzhvpgtvlbxg, tvejysmllsmz, xrpafgyirdlv

No comments. add comment

Snippet ID: #1028972
Snippet name: Snippets Word Index [OK]
Eternal ID of this version: #1028972/7
Text MD5: 497fc56a2d28ac67b2eb04c53ed0a751
Transpilation MD5: 561526dc93a785113154d16f6f450650
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-15 02:04:32
Source code size: 642 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 26 / 2172
Version history: 6 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1028972 & http://1028972.tinybrain.de