Commit 4b9d6844 authored by Tim Peters's avatar Tim Peters

Factor out the code for unindexing a doc. OkapiIndex has very little

code left in it!
parent d398b7ba
......@@ -86,9 +86,12 @@ class BaseIndex(Persistent):
def index_doc(self, docid, text):
raise NotImplementedError
# Subclass must override.
# A subclass may wish to extend or override this.
def unindex_doc(self, docid):
raise NotImplementedError
for wid in self.get_words(docid):
self._del_wordinfo(wid, docid)
del self._docwords[docid]
del self._docweight[docid]
def search(self, term):
wids = self._lexicon.termToWordIds(term)
......
......@@ -81,12 +81,6 @@ class CosineIndex(BaseIndex):
self._add_undoinfo(docid, wids)
return len(wids)
def unindex_doc(self, docid):
for wid in self.get_words(docid):
self._del_wordinfo(wid, docid)
del self._docwords[docid]
del self._docweight[docid]
def _search_wids(self, wids):
if not wids:
return []
......
......@@ -72,14 +72,8 @@ class OkapiIndex(BaseIndex):
return len(wids)
def unindex_doc(self, docid):
for wid in WidCode.decode(self._docwords[docid]):
self._del_wordinfo(wid, docid)
del self._docwords[docid]
count = self._docweight[docid]
del self._docweight[docid]
self._totaldoclen -= count
self._totaldoclen -= self._docweight[docid]
BaseIndex.unindex_doc(self, docid)
# The workhorse. Return a list of (IIBucket, weight) pairs, one pair
# for each wid t in wids. The IIBucket, times the weight, maps D to
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment