plusieurs sources, plusieurs phrases

This commit is contained in:
2026-02-05 16:02:30 +01:00
parent b4182cb71f
commit ccba64ed35

View File

@@ -2,17 +2,19 @@ from collections import defaultdict
from random import choice, randrange
suivants = defaultdict(list)
for path in (
"fra_wikipedia_2021_10K-sentences.txt",
):
with open(path, "r", encoding="utf-8") as fichier:
for phrase in fichier:
antepenultieme, penultieme = "", ""
for word in phrase.split():
suivants[(antepenultieme, penultieme)].append(word)
antepenultieme, penultieme = penultieme, word
with open("fra_wikipedia_2021_10K-sentences.txt", "r", encoding="utf-8") as fichier:
for phrase in fichier:
antepenultieme, penultieme = "", ""
for word in phrase.split():
suivants[(antepenultieme, penultieme)].append(word)
antepenultieme, penultieme = penultieme, word
def parle():
def parle(nb_phrases=1):
phrases = []
for _ in range(randrange(1, 4)):
for _ in range(nb_phrases):
antepenultieme, penultieme = "", ""
phrase = []
while mots_possibles := suivants[(antepenultieme, penultieme)]: