This commit is contained in:
REDNBLACK 2017-01-04 21:50:01 +03:00
parent 4ec83e79bd
commit a8e2dd8309
1 changed files with 5 additions and 0 deletions

View File

@ -58,10 +58,15 @@ class ReplyGenerator:
key = self.separator.join(words[1:] + [next_word])
# Append last word, if it not already in the list
last_word = key.split(self.separator)[-1]
if last_word not in gen_words:
gen_words.append(last_word)
# Keep only one word, if all words in list are the same
if all(w == gen_words[0] for w in gen_words):
gen_words = [gen_words[0]]
gen_words = list(filter(lambda w: w != self.stop_word, gen_words))
sentence = ' '.join(gen_words).strip()
if sentence[-1:] not in self.end_sentence: