Warning: session_start(): open(/var/lib/php/sessions/sess_b6lm1v8geeie5pg88hah9uj11s, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
srecord noeq Entry(
S snippetID,
int[] indices // where in the text does the word occur
) {}}
cprint SnippetsDoubleWordIndex {
transient DoubleWordIndex wordIndex;
start-thread {
time "Make double word index" {
new DoubleWordIndex wordIndex;
for (virtual CSnippet sn : dm_allSnippets()) {
S snippetID = (S) rcall snippetID(sn);
S text = cast rcall text(sn);
MultiMap positions = ciMultiMap();
for (IntRange r : wordIndex.wordRange(text))
positions.put(substring(text, r), r.start);
for (S word, L indices : asMap())
wordIndex.addWord(word, new Entry(text, toIntArray(indices)));
}
setField(+wordIndex);
}
print("Indexed " + nWords(wordIndex.numWords()));
}
// API
// may return null (no pre-search result)
Cl snippetsContainingTextIC_preSearch(S query) {
ret doubleWordIndex_lookupString(wordIndex, query);
}
}