[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndexNG - BaseStopWords.py:1.1.2.2
Andreas Jung
andreas@zope.com
Mon, 7 Jan 2002 15:46:00 -0500
Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndexNG
In directory cvs.zope.org:/tmp/cvs-serv7469
Modified Files:
Tag: ajung-textindexng-branch
BaseStopWords.py
Log Message:
- changed internal storage to OOBTree()
- code cleanup
=== Zope/lib/python/Products/PluginIndexes/TextIndexNG/BaseStopWords.py 1.1.2.1 => 1.1.2.2 ===
from types import DictType, StringType
from defaultStopWords import stop_word_dict
-
+from BTrees.OOBTree import OOBTree
class BaseStopWords:
def __init__(self, words=stop_word_dict):
- if isinstance(words,DictType):
+ self._words = OOBTree()
- self._words = words.copy()
+ if isinstance(words,DictType):
+ self._words.update(words)
elif isinstance(words,StringType):
-
- self._words = self.readStopWords(words)
+ self._words.update (self.readStopWords(words) )
else:
raise ValueError
@@ -36,8 +36,9 @@
self.has_key= self._words.has_key
self.get = self._words.get
-
- def __len__(self): return len(self._words)
+
+ def __del__(self,k): del self._word[k]
+ def __len__(self): return len(self._words)
def readStopWords(self, fname):
@@ -51,7 +52,5 @@
if l:
d[ l ] = None
- return d.copy()
-
-
+ return d