commited all contents created by participants
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#!/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:
|
||||
#list_sup = ["'", "-", "l ", "le ", "les ", "la ", "un ","une ", "des "]
|
||||
print(list_sup)
|
||||
texte = source.read()
|
||||
#print(texte)
|
||||
#enlever les traits d'union et les apostrophes
|
||||
texte = str.lower(texte)
|
||||
|
||||
# texte = texte.replace("'", " ")
|
||||
# texte = texte.replace("-", " ")
|
||||
# texte = texte.replace(" l ", " ")
|
||||
|
||||
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))
|
||||
Reference in New Issue
Block a user