import re letters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y', 'z'] symbols = ['"','#','`','%','&','\'','(',')','*','+',',','-','.','/', '\n'] errDict = {'á': 'à', 'í': 'ì', 'ó': 'ò', 'ú': 'ù', 'É': 'È'} # printl = print ('what') def main (filename): # you could write better things with open (filename, "r") as f: wordsAll = f.read () # with open (filename + '.corretto.md' , "w") as f: with open (filename , "w") as f: for w in wordsAll.split (' '): # á ó é ú í # check verbo essere try: if w[0] == 'é': w.replace ('é', 'è') if w[0] == 'e' and w[1] == '`': w.replace ('e`', 'è') w = w[1:] except: pass try: # check vocali gravi w = [e if e not in errDict else errDict[e] for e in w] w = ''.join (w) except: # ugly, check len pass if 'pò' in w: w = w.replace ('pò', 'po\'') f.write (w + ' ') # print (w + ' ', end='') f.write ('\n') if __name__ == '__main__': import sys for arg in sys.argv[1:]: main (arg)