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

Commit

Permalink
clear(): was ignoring the index_factory passed to the constructor,
Browse files Browse the repository at this point in the history
reinitializing to the global Index even if that wasn't how the object
was constructed.
  • Loading branch information
Tim Peters committed May 16, 2002
1 parent 00afc05 commit a1156e7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ZCTextIndex.py
Expand Up @@ -61,7 +61,8 @@ def __init__(self, id, extra, caller, index_factory=Index):
% lexicon.getId()

self.lexicon = lexicon
self.index = index_factory(self.lexicon)
self._index_factory = index_factory
self.clear()

## Pluggable Index APIs ##

Expand Down Expand Up @@ -103,7 +104,7 @@ def query(self, query, nbest=10):
chooser = NBest(nbest)
chooser.addmany(results.items())
return chooser.getbest(), len(results)

def numObjects(self):
"""Return number of object indexed"""
return self.index.length()
Expand All @@ -119,7 +120,7 @@ def getEntryForObject(self, documentId, default=None):

def clear(self):
"""reinitialize the index"""
self.index = Index(self.lexicon)
self.index = self._index_factory(self.lexicon)

def _get_object_text(self, obj):
x = getattr(obj, self._fieldname)
Expand Down

0 comments on commit a1156e7

Please sign in to comment.