kaust="/home/juku/oma/23/05/asendused/tekstivaljund_src_min3/" import os spellerid=["etnc19_reference_corpus_6000000_web_2019_600000", "etnc19_reference_corpus_6000000_lines", "etnc19_web_2019"] #spellerid=["etnc19_reference_corpus_model_6000000_lines"] #spellerid=["etnc19_reference_corpus_6000000_web_2019_600000"] #spellerid=["etnc19_web_2019"] #for gk in os.listdir(kaust): # for snimi in spellerid: # os.mkdir(kaust+gk+"/"+snimi) import jamspell corrector=jamspell.TSpellCorrector() for snimi in spellerid: print(snimi) corrector.LoadLangModel(snimi+".bin") #speller = spelling.Spelling(snimi+"/"+snimi+".bin") #for gk in os.listdir(kaust): # print(gk) os.makedirs(kaust+"korrektoriga3/"+snimi+"/") for fnimi in os.listdir(kaust): if fnimi.endswith(".txt"): print(fnimi) f1=open(kaust+fnimi, encoding="utf-8") f2=open(kaust+"korrektoriga3/"+snimi+"/"+fnimi, "w", encoding="utf-8") for rida in f1: # request = Request(text=rida.strip(), language='et') # response=speller.process_request(request) # print(response.corrected_text, file=f2) print(corrector.FixFragment(rida.strip()), file=f2) f2.close() f1.close()