import re import matplotlib.pyplot as plt f = open('testi/collodi_pinocchio.txt', mode='r', encoding='iso-8859-1') testo = f.read() testo=testo[1704:] # istruzioni per l'affinamento della tokenizzazione testo=re.sub("'","' ", testo) testo=re.sub("([^\.]+)([\.,;:\!-]+)","\g<1> \g<2>", testo) testo=testo.lower() # fine istruzioni per l'affinamento della tokenizzazione testo=testo.split() fd=[testo.count(i) for i in set(testo)] fd.sort(reverse=True) plt.plot(range(1,51),fd[0:50],'.') plt.show()