def add2bow(self, doc): docbow = r.entry2bow(doc) self.bow = [(e, f + h) for e, f in self.bow for g, h in docbow if e == g] es = [e for e, _ in self.bow] self.bow += filter(lambda (g, h): not g in es, docbow) if self.bow != [] else docbow
def subfrombow(self, doc): docbow = r.entry2bow(doc) self.bow = [(e, f - h) for e, f in self.bow for g, h in docbow if e == g] self.bow = filter(lambda (e, f): f > 0, self.bow)
def subfrombow(self, doc): docbow = r.entry2bow(doc) self.bow = [(e,f-h) for e,f in self.bow for g,h in docbow if e == g] self.bow = filter(lambda (e,f): f > 0, self.bow)
def add2bow(self, doc): docbow = r.entry2bow(doc) self.bow = [(e,f+h) for e,f in self.bow for g,h in docbow if e == g] es = [e for e,_ in self.bow] self.bow += filter(lambda (g,h): not g in es, docbow) if self.bow != [] else docbow