from hinspell import *

#f = open("hi-spell1.txt", "r", encoding="utf-8")
f = open("hi-spell.txt", "r", encoding="utf-8")
#f = open("hi-spell2.txt", "r", encoding="utf-8")
#f = open("test", "r", encoding="utf-8")
tt = open("corrected.txt", "w", encoding="utf-8")

for line in f:
    words = line.split("\n")
    words = words[0].replace("("," ").replace("-"," ").replace("."," ").replace("!"," ").replace("/"," ").replace("'"," ").replace("\""," ").replace(")"," ").replace("?"," ").replace("0"," ").replace("1"," ").replace("2"," ").replace("3"," ").replace("4"," ").replace("5"," ").replace("6"," ").replace("7"," ").replace("8"," ").replace("9"," ").replace("०"," ").replace("१"," ").replace("२"," ").replace("३"," ").replace("४"," ").replace("५"," ").replace("६"," ").replace("७"," ").replace("८"," ").replace("९"," ").replace(":"," ").split()
    print (line)
    for word in words:
        if(word != ''):
            correction = correct(word)
            if correction == None:
                print(word,end=" ")
                tt.write(word)
                tt.write(" ")
            else:
                print(correction,end=" ")
                tt.write(correction)
                tt.write(" ")
    print("\n")
    tt.write("\n")
