Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

Commit

Permalink
Implement correct (albeit inefficient) reindexing, and stop cheating
Browse files Browse the repository at this point in the history
in the reindexing text.
  • Loading branch information
Tim Peters committed May 17, 2002
1 parent c70e654 commit 6e7888b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 3 additions & 1 deletion BaseIndex.py
Expand Up @@ -84,7 +84,9 @@ def get_words(self, docid):

# 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():
Expand Down
5 changes: 1 addition & 4 deletions tests/testZCTextIndex.py
Expand Up @@ -96,7 +96,7 @@ def testStopWords(self):
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()

Expand Down Expand Up @@ -131,9 +131,6 @@ def testDocUpdate(self):
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):

Expand Down

0 comments on commit 6e7888b

Please sign in to comment.