# -*- coding: utf-8 -*-
import codecs,sys
import re, string, random, glob, operator, heapq
from collections import defaultdict
import sys
from collections import Counter
from math import log10
import os
writefile2 = 'aspellans'
w2 = codecs.open(writefile2,'w','utf-8')


readfile1 = 'wrongspellin2'
r1 = codecs.open(readfile1,'r','utf-8')

def test(verbose=None):
    """Run some tests, taken from the chapter.
    Since the hillclimbing algorithm is randomized, some tests may fail."""
    import doctest
    print 'Running tests...'
    doctest.testfile('ngrams-test.txt', verbose=verbose)



def corrections(text): 
    ret=""
    sendtext=text.split(' ')
    for a in sendtext:
	print a
	if a:	ret+=commands.getoutput("echo "+a.encode('utf-8')+" | aspell --lang='hi' -a")
    return ret 

for w in r1:
	w=w.strip('\n')
	cmd='echo '+w.encode('utf-8')+' | aspell --lang="hi" -a'
	ans=os.popen(cmd).read()
	print ans
	#print "done=",ans
