[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndexNG - TextIndexNG.py:1.2.2.17
Andreas Jung
andreas@digicool.com
Mon, 21 Jan 2002 15:45:18 -0500
Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndexNG
In directory cvs.zope.org:/tmp/cvs-serv3616
Modified Files:
Tag: ajung-textindexng-branch
TextIndexNG.py
Log Message:
code cleanup
added support for normalizer
=== Zope/lib/python/Products/PluginIndexes/TextIndexNG/TextIndexNG.py 1.2.2.16 => 1.2.2.17 ===
from queryparser.queryparser import QueryParser
-import Stemmer
-import Proximity
-import Thesaurus, StopWords
+import Stemmer, Proximity
+import Thesaurus, StopWords, Normalizer
import time
@@ -138,6 +137,12 @@
# Thesaurus: either filename or StopWord object
self.thesaurus = getattr(extra,'thesaurus', None) or None
+ # Thesaurus: either filename or StopWord object
+ self.thesaurus = getattr(extra,'thesaurus', None) or None
+
+ # Normalizer: characterMapping
+ self.charMapping = getattr(extra,'characterMapping', None) or None
+
if not self.nearSearch in (None,'internal','documentLookup'):
raise ValueError,'nearSearch must be either None, "internal"'\
' or "documentLookup"'
@@ -158,6 +163,16 @@
self._thesaurus = Thesaurus.Thesaurus(self.thesaurus)
elif isinstance(self.thesaurus, InstanceType):
self._thesaurus = self.thesaurus
+ else:
+ self._thesaurus = None
+
+ # Normalizer
+ if isinstance(self.charMapping, StringType):
+ self._normalizer = Normalizer.Normalizer(self.charMapping)
+ elif isinstance(self.thesaurus, Normalizer.Normalizer):
+ self._normalizer = self._normalizer
+ else:
+ self._normalizer = None
# StopWords