Commit 401492ef authored by Tres Seaver's avatar Tres Seaver

LP #142478: normalize terms passed to ``PLexicon.queryLexicon``

o Use the lexicon's pipeline (e.g., case flattening, stop word removal, etc.).
parent 2db2bcf3
......@@ -8,6 +8,12 @@ http://docs.zope.org/zope2/releases/.
2.12.5 (unreleased)
-------------------
Bugs Fixed
++++++++++
- LP #142478: normalize terms passed to ``PLexicon.queryLexicon`` using
the lexicon's pipeline (e.g., case flattening, stop word removal, etc.)
2.12.4 (2010-04-05)
-------------------
......
......@@ -358,7 +358,7 @@ class PLexicon(Lexicon, Implicit, SimpleItem):
"""
if words:
wids = []
for word in words:
for word in self.parseTerms(words):
wids.extend(self.globToWordIds(word))
words = [self.get_word(wid) for wid in wids]
else:
......
......@@ -691,6 +691,21 @@ class PLexiconTests(unittest.TestCase):
self.assertEqual(list(info['page_range']), [0])
self.assertEqual(info['page_columns'], [['aaa', 'bbb']])
def test_queryLexicon_uses_pipeline_for_normalization(self):
from Products.ZCTextIndex.Lexicon import CaseNormalizer
WORDS = 'aaa bbb ccc ddd eee fff ggg'.split()
lexicon = self._makeOne('test', 'Testing', CaseNormalizer())
lexicon.sourceToWordIds(WORDS)
info = lexicon.queryLexicon(REQUEST=None, words=['AA*', 'Bbb*'])
self.assertEqual(info['page'], 0)
self.assertEqual(info['rows'], 20)
self.assertEqual(info['cols'], 4)
self.assertEqual(info['start_word'], 1)
self.assertEqual(info['end_word'], 2)
self.assertEqual(info['word_count'], 2)
self.assertEqual(list(info['page_range']), [0])
self.assertEqual(info['page_columns'], [['aaa', 'bbb']])
def test_suite():
s = unittest.TestSuite()
......
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