[Checkins] SVN: zope.index/trunk/src/zope/index/text/baseindex.py Backport non-insane version of _del_wordinfo from Zope2 version of textindex.
Chris McDonough
chrism at plope.com
Thu Feb 19 18:26:53 EST 2009
Log message for revision 96803:
Backport non-insane version of _del_wordinfo from Zope2 version of textindex.
Changed:
U zope.index/trunk/src/zope/index/text/baseindex.py
-=-
Modified: zope.index/trunk/src/zope/index/text/baseindex.py
===================================================================
--- zope.index/trunk/src/zope/index/text/baseindex.py 2009-02-19 22:14:05 UTC (rev 96802)
+++ zope.index/trunk/src/zope/index/text/baseindex.py 2009-02-19 23:26:52 UTC (rev 96803)
@@ -292,21 +292,14 @@
self._wordinfo[wid] = doc2score # not redundant: Persistency!
self.wordCount.change(new_word_count)
-
def _del_wordinfo(self, wid, docid):
doc2score = self._wordinfo[wid]
del doc2score[docid]
- numdocs = len(doc2score)
- if numdocs == 0:
+ if doc2score:
+ self._wordinfo[wid] = doc2score # not redundant: Persistency!
+ else:
del self._wordinfo[wid]
self.wordCount.change(-1)
- return
- if numdocs == self.DICT_CUTOFF:
- new = {}
- for k, v in doc2score.items():
- new[k] = v
- doc2score = new
- self._wordinfo[wid] = doc2score # not redundant: Persistency!
def inverse_doc_frequency(term_count, num_items):
"""Return the inverse doc frequency for a term,
More information about the Checkins
mailing list