[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndexNG - BaseProximityLexicon.py:1.1.2.5
Andreas Jung
andreas@digicool.com
Thu, 10 Jan 2002 21:45:33 -0500
Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndexNG
In directory cvs.zope.org:/tmp/cvs-serv7526
Modified Files:
Tag: ajung-textindexng-branch
BaseProximityLexicon.py
Log Message:
fixed a bug where a word got called twice with the proximity function.
Good to have unittests !
=== Zope/lib/python/Products/PluginIndexes/TextIndexNG/BaseProximityLexicon.py 1.1.2.4 => 1.1.2.5 ===
return [ self.getWordId(word) for word in words]
+
def getWordId(self, word):
""" return the word id of 'word' """
@@ -79,8 +80,6 @@
def assignWordId(self, word):
"""Assigns a new word id to the provided word and returns it."""
- word = self._v_proximity(word)
-
# First make sure it's not already in there
if self._lexicon.has_key(word):
@@ -96,6 +95,7 @@
self._lexicon[intern(word)] = wid
else:
self._lexicon[word] = wid
+
return wid
@@ -103,6 +103,8 @@
def get(self, key, default=None):
"""Return the matched word against the key."""
+ key = self._v_proximity(key)
+
r=IISet()
wid=self._lexicon.get(key, default)
if wid is not None: r.insert(wid)
@@ -124,23 +126,3 @@
def __call__(self,word):
return self._v_proximity(word)
-
-def test():
-
- for a in ('metaphone','soundex'):
- print 'Algorithm:',a
-
- PL = BaseProximityLexicon(a)
-
- words = 'the quick brown fox jumps over the '\
- 'lazy dog brown fox'.split()
-
- for w in words:
-
- wid = PL.getWordId(w)
- word = PL.getWord(wid)
- print w,wid,word
-
-
-if __name__ == '__main__':
- test()