def update_with_sentences(self, parsed_user): # Check user input for names, focus appropriately for word in parsed_user.split(' '): base, pos = parse_utils.split_parsed(word) if (pos == 'NNP'): self.focus_on(base) self.step()
def update_with_sentences(self, parsed_combined): char_count = 0; last_state_update = 0 for word in parsed_combined.split(' '): char_count += len(word) base, pos = parse_utils.split_parsed(word) if (pos == 'JJ'): base = base.lower() if base in adjective_to_vector_map: last_state_update = char_count new_topic_vector = adjective_to_vector_map[base] # Combine vectors in EWMA like way self.topic = [self.topic_old_weight * old * 0.5 ** ((char_count - last_state_update) / self.topic_half_life) \ + new * (1 - self.topic_old_weight) for old, new in zip(self.topic, new_topic_vector)] # Decay for all remaining characters self.topic = [x * 0.5 ** ((char_count - last_state_update) / self.topic_half_life) for x in self.topic]