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
+31
View File
@@ -0,0 +1,31 @@
#!/usr/bin/env python
# coding: utf8
#pour installer nltk stopWords tout là : http://www.nltk.org/data.html
import re
from nltk.tokenize import sent_tokenize, word_tokenize
from nltk.corpus import stopwords
with open("mirabeau.txt", "r") as source:
texte = source.read()
texte = str.lower(texte)
print(texte)
#enlever les traits d'union et les apostrophes
texte = texte.replace("'", " ")
texte = texte.replace("-", " ")
#print(texte)
liste_phrase = texte.split(" ")
print("liste des mots originaux séparés:", liste_phrase)
liste_reduit = []
stopWords = set(stopwords.words('french'))
for w in liste_phrase:
if w not in stopWords:
liste_reduit.append(w)
#print("liste des mots réduit :", liste_reduit)
poeme_reduit = (" ".join(liste_reduit))
print("version réduite du poeme :", poeme_reduit)
with open("mirabeau_reduit.txt", "w") as destination :
destination.write(" ".join(liste_reduit))