# -*- 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')

f2=codecs.open('wrong-spellans2','r','utf-8')

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

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

	if('*' in ans):
		if(w in our): C+=1
		#else: I+=1
		count+=1
		print w
	else:
		ans= ans.strip("@(#) International Ispell Version 3.1.20(but really Aspell 0.60.7-20110707)"+'\n'+"&")
		try:
			no=ans.split(' ')[1]
		except:
			no=0
		#print no
		if no==0: continue
		an=ans.split(':')[1]
		#print an
		try:
			at=an.split(', ')
		except: at=[]	
		i=0
		flagi=0
		out=""
		for a in at:
			if(i<3):
				i+=1
				out+=a+' '
				'''out+=a+'a'''
				if(a.decode('utf-8') in our.strip('\n')):
					C+=1
					print 'c'+a.decode('utf-8')+'d'+our+'e'
				else:	
					flagi=1
		if(flagi==1): I+=1
		print out[1:]
		
print C, I
accuracy=float(C)/(float(C)+float(I))*100
print "accuracy="+str(accuracy)

