def _insert(self,term,docId, _isInstance= isinstance, _IntType= IntType): '''index *docId* under *term*.''' index= self._index dl= index.get(term) if dl is None: index[term]= docId; self.__len__.change(1) if self.ReverseOrder: self._reverseOrder.insert(reverseOrder(term)) return if _isInstance(dl,_IntType): dl= index[term]= IITreeSet((dl,)) dl.insert(docId)
def _insert(self, term, docId, _isInstance=isinstance, _IntType=IntType): '''index *docId* under *term*.''' index = self._index dl = index.get(term) if dl is None: index[term] = docId self.__len__.change(1) if self.ReverseOrder: self._reverseOrder.insert(reverseOrder(term)) return if _isInstance(dl, _IntType): dl = index[term] = IITreeSet((dl, )) dl.insert(docId)
def _remove(self,term,docId, _isInstance= isinstance, _IntType= IntType): '''unindex *docId* under *term*.''' index= self._index dl= index.get(term); isInt= _isInstance(dl,_IntType) if dl is None or isInt and dl != docId: raise ValueError('Attempt to remove nonexisting document %s from %s' % (docId, self.id) ) if isInt: dl = None else: dl.remove(docId) if not dl: del index[term]; self.__len__.change(-1) if self.ReverseOrder: self._reverseOrder.remove(reverseOrder(term))
def _remove(self, term, docId, _isInstance=isinstance, _IntType=IntType): '''unindex *docId* under *term*.''' index = self._index dl = index.get(term) isInt = _isInstance(dl, _IntType) if dl is None or isInt and dl != docId: raise ValueError( 'Attempt to remove nonexisting document %s from %s' % (docId, self.id)) if isInt: dl = None else: dl.remove(docId) if not dl: del index[term] self.__len__.change(-1) if self.ReverseOrder: self._reverseOrder.remove(reverseOrder(term))