def computeWordKLDivergenceWithByEddie(self, event): # this method calls the kl divergence computation by eddie's methods text1 = "" text2 = "" for element in self._event[self._element_type]: p = createElement(self._element_type, element) text1 += " " text1 += p.getText() if type(event) is not types.DictType: event = event.toDict() for element in event[self._element_type]: p = createElement(self._element_type, element) text2 += " " text2 += p.getText() return kldiv(tokenize(text1), tokenize(text2))
def computeWordKLDivergenceWithByEddie(self, event): # this method calls the kl divergence computation by eddie's methods text1 = '' text2 = '' for photo in self._event['photos']: p = Photo(photo) text1 += ' ' text1 += p.getCaption() if type(event) is types.DictType: pass else: event = event.toDict() for photo in event['photos']: p = Photo(photo) text2 += ' ' text2 += p.getCaption() return kldiv(tokenize(text1), tokenize(text2))
def computeWordKLDivergenceWithByEddie(self, event): # this method calls the kl divergence computation by eddie's methods text1 = '' text2 = '' for photo in self._event['photos']: p = Photo(photo) text1 += ' ' text1 += p.getCaption() if type(event) is types.DictType: pass else: event = event.toJSON() for photo in event['photos']: p = Photo(photo) text2 += ' ' text2 += p.getCaption() return kldiv(tokenize(text1), tokenize(text2))