[Zope-CVS] CVS: Products/ZCTextIndex - BaseIndex.py:1.7 CosineIndex.py:1.14 OkapiIndex.py:1.20
Tim Peters
tim.one@comcast.net
Fri, 17 May 2002 02:19:09 -0400
Update of /cvs-repository/Products/ZCTextIndex
In directory cvs.zope.org:/tmp/cvs-serv11315
Modified Files:
BaseIndex.py CosineIndex.py OkapiIndex.py
Log Message:
Factor out the code for unindexing a doc. OkapiIndex has very little
code left in it!
=== Products/ZCTextIndex/BaseIndex.py 1.6 => 1.7 ===
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)
=== Products/ZCTextIndex/CosineIndex.py 1.13 => 1.14 ===
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 []
=== Products/ZCTextIndex/OkapiIndex.py 1.19 => 1.20 ===
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