Commit 9032867d authored by Tim Peters's avatar Tim Peters

Implement correct (albeit inefficient) reindexing, and stop cheating

in the reindexing text.
parent eebb1a61
......@@ -84,7 +84,9 @@ class BaseIndex(Persistent):
# A subclass may wish to extend or override this.
def index_doc(self, docid, text):
# XXX If docid is already known, do something smart.
if self._docwords.has_key(docid):
# XXX Do something smarter than this.
self.unindex_doc(docid)
wids = self._lexicon.sourceToWordIds(text)
wid2weight, docweight = self._get_frequencies(wids)
for wid, weight in wid2weight.items():
......
......@@ -96,7 +96,7 @@ class ZCIndexTestsBase:
self.assertEqual(len(self.index.get_words(1)), 1)
def testDocUpdate(self):
docid = 1
docid = 1 # doesn't change -- we index the same doc repeatedly
N = len(text)
stop = get_stopdict()
......@@ -131,9 +131,6 @@ class ZCIndexTestsBase:
for w in v:
nbest, total = self.zc_index.query(w)
self.assertEqual(total, 0, "did not expect to find %s" % w)
# XXX The next line is necessary because we're not yet reindexing
# XXX docs correctly.
self.zc_index.unindex_object(docid)
class CosineIndexTests(ZCIndexTestsBase, testIndex.CosineIndexTest):
......
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