!7 cprint SnippetsDeepWordIndex { transient DeepWordIndex wordIndex; // string = snippet ID start-thread { time "Make double word index" { print("Making index"); new DeepWordIndex 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 Iterable>> snippetPreSearch_withPositions(S query, O... _) { Iterable>> l; time "lookup" { l = wordIndex == null ? null : wordIndex.lookupString_withPositions(query, _); } ret l; } }