Commit 455af8ce authored by Tim Peters's avatar Tim Peters

_get_undoinfo: Got rid of this everywhere. It was just a synonym for

get_words, and in calling contexts nothing but a list of wids could
possibly make sense.
parent 72ed10fe
......@@ -61,7 +61,7 @@ class BaseIndex(Persistent):
# across indices, and a query can contain a word some other
# index knows about but we don't). A word is in-vocabulary for
# this index if and only if _wordinfo.has_key(wid). Note that
# wid 0 most not be a key in _wordinfo.
# wid 0 must not be a key in _wordinfo.
self._wordinfo = IOBTree()
# docid -> WidCode'd list of wids
......@@ -194,10 +194,6 @@ class BaseIndex(Persistent):
map = new
self._wordinfo[wid] = map # Not redundant, because of Persistency!
# Used only by tests.
def _get_undoinfo(self, docid):
return WidCode.decode(self._docwords[docid])
def inverse_doc_frequency(term_count, num_items):
"""Return the inverse doc frequency for a term,
......
......@@ -97,7 +97,7 @@ class CosineIndex(BaseIndex):
return len(wids)
def unindex_doc(self, docid):
for wid in self._get_undoinfo(docid):
for wid in self.get_words(docid):
self._del_wordinfo(wid, docid)
del self._docwords[docid]
del self._docweight[docid]
......@@ -219,9 +219,6 @@ class CosineIndex(BaseIndex):
def _add_undoinfo(self, docid, wids):
self._docwords[docid] = WidCode.encode(wids)
def _get_undoinfo(self, docid):
return WidCode.decode(self._docwords[docid])
# The rest are helper methods to support unit tests
def _get_wdt(self, d, t):
......
......@@ -213,10 +213,6 @@ class OkapiIndex(BaseIndex):
map = new
self._wordinfo[wid] = map # Not redundant, because of Persistency!
# Used only by tests.
def _get_undoinfo(self, docid):
return WidCode.decode(self._docwords[docid])
def inverse_doc_frequency(term_count, num_items):
"""Return the inverse doc frequency for a term,
......
......@@ -48,7 +48,7 @@ class IndexTest(TestCase):
self.assertEqual(self.num_docs_known(), 1)
self.assertEqual(len(self.index._wordinfo), 5)
self.assertEqual(len(self.index._docwords), 1)
self.assertEqual(len(self.index._get_undoinfo(DOCID)), 5)
self.assertEqual(len(self.index.get_words(DOCID)), 5)
for map in self.index._wordinfo.values():
self.assertEqual(len(map), 1)
self.assert_(map.has_key(DOCID))
......@@ -70,7 +70,7 @@ class IndexTest(TestCase):
self.assertEqual(self.num_docs_known(), 2)
self.assertEqual(len(self.index._wordinfo), 8)
self.assertEqual(len(self.index._docwords), 2)
self.assertEqual(len(self.index._get_undoinfo(DOCID)), 4)
self.assertEqual(len(self.index.get_words(DOCID)), 4)
wids = self.lexicon.termToWordIds("document")
self.assertEqual(len(wids), 1)
document_wid = wids[0]
......@@ -91,7 +91,7 @@ class IndexTest(TestCase):
self.check_docid_known(DOCID)
self.assertEqual(len(self.index._wordinfo), 4)
self.assertEqual(len(self.index._docwords), 1)
self.assertEqual(len(self.index._get_undoinfo(DOCID)), 4)
self.assertEqual(len(self.index.get_words(DOCID)), 4)
for map in self.index._wordinfo.values():
self.assertEqual(len(map), 1)
self.assert_(map.has_key(DOCID))
......@@ -102,7 +102,7 @@ class IndexTest(TestCase):
self.check_docid_known(DOCID)
self.assertEqual(len(self.index._wordinfo), 5)
self.assertEqual(len(self.index._docwords), 1)
self.assertEqual(len(self.index._get_undoinfo(DOCID)), 7)
self.assertEqual(len(self.index.get_words(DOCID)), 7)
wids = self.lexicon.termToWordIds("repeat")
self.assertEqual(len(wids), 1)
repititive_wid = wids[0]
......
......@@ -94,7 +94,7 @@ class ZCIndexTestsBase:
if word != "question":
wids = self.lexicon.termToWordIds(word)
self.assertEqual(wids, [])
self.assertEqual(len(self.index._get_undoinfo(1)), 1)
self.assertEqual(len(self.index.get_words(1)), 1)
def testDocUpdate(self):
docid = 1
......
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