commited all contents created by participants

This commit is contained in:
Bachir Soussi Chiadmi
2017-12-21 18:12:40 +01:00
parent cefd1c2ad0
commit b936b1e616
2137 changed files with 1076319 additions and 730 deletions
@@ -0,0 +1,26 @@
from random import choice
from nltk.tokenize import sent_tokenize, word_tokenize
with open("dixit.txt") as article:
quotes = sent_tokenize(article.read())
text_in = ""
while text_in != "stop":
text_in = input("> ")
text_out = "> "
words_in = word_tokenize(text_in)
words_in.sort(key = lambda s: len(s))
print(words_in)
words_in.reverse()
quote_found = False
for word in words_in:
for quote in quotes:
if word in quote:
text_out += "À propos de %s, Einstein a dit un jour : \"%s\"." % (word, quote)
quote_found = True
break
if quote_found:
break
if not quote_found:
text_out += "RIEN TROUVÉ"
print(text_out);