[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndexNG - TextIndexNG.py:1.2.2.53 GlobbingLexiconNG.py:1.1.2.8 TextOperators.py:NONE

Andreas Jung andreas@digicool.com
Tue, 12 Mar 2002 18:13:44 -0500


Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndexNG
In directory cvs.zope.org:/tmp/cvs-serv14068

Modified Files:
      Tag: ajung-textindexng-branch
	TextIndexNG.py GlobbingLexiconNG.py 
Removed Files:
      Tag: ajung-textindexng-branch
	TextOperators.py 
Log Message:
removed another old TextIndex cruft: TextOperator.py


=== Zope/lib/python/Products/PluginIndexes/TextIndexNG/TextIndexNG.py 1.2.2.52 => 1.2.2.53 ===
 
 from types import IntType, StringType, UnicodeType, InstanceType, DictType, ListType
-from TextOperators import *
 from TextIndexCommon import *
 
 from queryparser.queryparser import QueryParser
@@ -209,7 +208,6 @@
     def clear(self):
 
         self.WordDocStorage           = WordIdDocumentIdStorage()
-        self.SimilarityWordDocStorage = WordIdDocumentIdStorage()
 
         self._thesaurus  = None
         self._stopwords  = None
@@ -247,7 +245,8 @@
         # Similarity
 
         if self.useSimilarity:
-            self._SIMILARITY_LEXICON    = SimilarityLexicon(algorithm=self.useSimilarity)
+            self._similarity_lexicon  = SimilarityLexicon(algorithm=self.useSimilarity)
+            self.SimilarityWordDocStorage = WordIdDocumentIdStorage()
 
             # the selection of the Similarity function must be more general
             # in the future. This requires some more work on the Python
@@ -259,13 +258,13 @@
         if self.lexicon:
 
             # try to get lexicon through acquisition
-            self._LEXICON = getattr(self,self.lexicon)
+            self._lexicon = getattr(self,self.lexicon)
 
         else:
 
             if self.useGlobbing:
 
-                self._LEXICON = GlobbingLexiconNG()
+                self._lexicon = GlobbingLexiconNG()
                 debug('created new globbing lexicon')
 
                 if self.useStemmer:
@@ -273,7 +272,7 @@
                     self.useStemmer= None
 
             else:
-                self._LEXICON = LexiconNG()
+                self._lexicon = LexiconNG()
                 debug('created new lexicon')
 
 
@@ -281,10 +280,10 @@
     def createShortcuts(self):
         """ create some aliases for some functions """
 
-        self._v_getWordIdList  = self._LEXICON.getWordIdList
-        self._v_getWordId      = self._LEXICON.getWordId
-        self._v_getWordById    = self._LEXICON.getWord
-        self._v_getIdByWord    = self._LEXICON.get
+        self._v_getWordIdList  = self._lexicon.getWordIdList
+        self._v_getWordId      = self._lexicon.getWordId
+        self._v_getWordById    = self._lexicon.getWord
+        self._v_getIdByWord    = self._lexicon.get
 
 
     def __nonzero__(self):
@@ -365,7 +364,7 @@
 
         if self.useSimilarity:
             Similarity_words =  self._v_Similarityfunc(words)
-            Similarity_widList = self._SIMILARITY_LEXICON.getWordIdList(Similarity_words)
+            Similarity_widList = self._similarity_lexicon.getWordIdList(Similarity_words)
             assert len(Similarity_words)==len(Similarity_widList)
 
             self.SimilarityWordDocStorage(Similarity_widList, documentId)
@@ -415,7 +414,7 @@
        
 
     def getLexicon(self):
-        return self._LEXICON
+        return self._lexicon
 
 
     def _apply_index(self, request, cid=''): 


=== Zope/lib/python/Products/PluginIndexes/TextIndexNG/GlobbingLexiconNG.py 1.1.2.7 => 1.1.2.8 ===
 from BTrees.OOBTree import OOBTree
 
-from TextOperators import Or,Op
-
 
 class GlobbingLexiconNG(LexiconNG):
     """Lexicon which supports basic globbing function ('*' and '?').
@@ -53,7 +51,7 @@
     eow       = '$'
 
     wc_set = [multi_wc, single_wc]
-    glob_reg = re.compile(r'[?*]')
+    glob_reg = re.compile(r'[?*]',re.UNICODE)
 
     def __init__(self):
         self.clear()
@@ -204,35 +202,6 @@
     def __getitem__(self, word):
         """ """
         return self.get(word)
-
-
-    def query_hook(self, q):
-        """expand wildcards"""
-
-        i = len(q) - 1
-
-        while i >= 0:
-            e = q[i]
-            if isinstance(e, ListType):
-                self.query_hook(e)
-            elif isinstance(e, Op):
-                pass
-            elif ( (self.multi_wc in e) or
-                   (self.single_wc in e) ):
-                wids = self.get(e)
-                words = []
-                for wid in wids:
-                    if words:
-                        words.append(Or)
-                    words.append(wid)
-                if not words:
-                    # if words is empty, return something that will make
-                    # textindex's __getitem__ return an empty result list
-                    words.append('')
-                q[i] = words
-            i = i - 1
-
-        return q
 
 
     def createRegex(self, pat):

=== Removed File Zope/lib/python/Products/PluginIndexes/TextIndexNG/TextOperators.py ===