import pickle import re # preparazione del testo f=open('testi/collodi_pinocchio.txt', mode='r', encoding='iso-8859-1') testo=f.read() testo=testo[1758:] testo=re.sub("'","' ", testo) testo=re.sub('[\.,;:\-?!]{1}','',testo) testo=testo.lower() testo=testo.split() # salvataggio del testo with open('testi/collodi_pinocchio.pkl','wb') as f: pickle.dump(testo,f)