|
|
@@ -5,25 +5,25 @@ def get_freq(nom_fich): |
|
|
|
contenu=fich.read() |
|
|
|
liste_frag=contenu.split() # coupe sur 'espace' et \ |
|
|
|
liste_mot=list() |
|
|
|
for fragment in liste_frag: |
|
|
|
for fragment in liste_frag: |
|
|
|
fragment_min=fragment.lower() |
|
|
|
frag_clean=clean(fragment_min) |
|
|
|
liste_mot.append(frag_clean) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return liste_mot |
|
|
|
|
|
|
|
|
|
|
|
def clean(fragment): |
|
|
|
|
|
|
|
|
|
|
|
result="" |
|
|
|
for c in fragment: |
|
|
|
if c.isalpha(): |
|
|
|
result+=c |
|
|
|
|
|
|
|
|
|
|
|
return result |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def tri(d): |
|
|
|
list_tuples=list() |
|
|
|
for clé, valeur in d.items(): |
|
|
@@ -35,7 +35,3 @@ def tri(d): |
|
|
|
nom_fich="ruffin.txt" |
|
|
|
f=get_freq(nom_fich) |
|
|
|
print(f) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|