def _convertBTrees(self, threshold=200): if type(self._lexicon) is type(''): # Turn the name reference into a hard reference. self._lexicon=self.getLexicon() if type(self._index) is IOBTree: return from BTrees.convert import convert _index=self._index self._index=IOBTree() def convertScores(scores, type=type, TupleType=TupleType, IIBTree=IIBTree ): if type(scores) is not TupleType and type(scores) is not IIBTree(): scores=IIBTree(scores) return scores convert(_index, self._index, threshold, convertScores) _unindex=self._unindex self._unindex=IOBTree() convert(_unindex, self._unindex, threshold)
def _convertBTrees(self, threshold=200): if type(self._index) is OOBTree: return from BTrees.convert import convert _index=self._index self._index=OOBTree() def convertSet(s, IITreeSet=IITreeSet, IntType=type(0), type=type, len=len, doneTypes = (IntType, IITreeSet)): if type(s) in doneTypes: return s if len(s) == 1: try: return s[0] # convert to int except: pass # This is just an optimization. return IITreeSet(s) convert(_index, self._index, threshold, convertSet) _unindex=self._unindex self._unindex=IOBTree() convert(_unindex, self._unindex, threshold) self.__len__=BTrees.Length.Length(len(_index))
def _convertBTrees(self, threshold=200): if type(self._lexicon) is type(''): # Turn the name reference into a hard reference. self._lexicon = self.getLexicon() if type(self._index) is IOBTree: return from BTrees.convert import convert _index = self._index self._index = IOBTree() def convertScores(scores, type=type, TupleType=TupleType, IIBTree=IIBTree): if type(scores) is not TupleType and type(scores) is not IIBTree(): scores = IIBTree(scores) return scores convert(_index, self._index, threshold, convertScores) _unindex = self._unindex self._unindex = IOBTree() convert(_unindex, self._unindex, threshold)
def _convertBTrees(self, threshold=200): Lexicon._convertBTrees(self, threshold) if type(self._digrams) is OOBTree: return from BTrees.convert import convert _digrams=self._digrams self._digrams=OOBTree() self._digrams._p_jar=self._p_jar convert(_digrams, self._digrams, threshold, IITreeSet)
def _convertBTrees(self, threshold=200): Lexicon._convertBTrees(self, threshold) if type(self._digrams) is OOBTree: return from BTrees.convert import convert _digrams = self._digrams self._digrams = OOBTree() self._digrams._p_jar = self._p_jar convert(_digrams, self._digrams, threshold, IITreeSet)
def _convertBTrees(self, threshold=200): if (type(self._lexicon) is OIBTree and type(getattr(self, '_inverseLex', None)) is IOBTree): return from BTrees.convert import convert lexicon=self._lexicon self._lexicon=OIBTree() self._lexicon._p_jar=self._p_jar convert(lexicon, self._lexicon, threshold) try: inverseLex=self._inverseLex self._inverseLex=IOBTree() except AttributeError: # older lexicons didn't have an inverse lexicon self._inverseLex=IOBTree() inverseLex=self._inverseLex self._inverseLex._p_jar=self._p_jar convert(inverseLex, self._inverseLex, threshold)
def _convertBTrees(self, threshold=200): from BTrees.convert import convert if type(self.data) is not IOBTree: data=self.data self.data=IOBTree() convert(data, self.data, threshold) self.__len__=BTrees.Length.Length(len(data)) uids=self.uids self.uids=OIBTree() convert(uids, self.uids, threshold) paths=self.paths self.paths=IOBTree() convert(paths, self.paths, threshold) for index in self.indexes.values(): if hasattr(index, '__of__'): index=index.__of__(self) index._convertBTrees(threshold)