#Python v3.x
import codecs

true_positive=0
false_positive=0
false_negative=0

def compare(str1, str2, wordlen):
		fp=0
		fn=0
		tp=0
		np1=0
		np2=0
		global true_positive
		global false_positive
		global false_negative
		for i in range(0,wordlen):
			if str1[i+np1]=='+'and str2[i+np2]=='+':
				np1+=1		
				np2+=1
				tp+=1
			elif (str1[i+np1]=='+'and str2[i+np2]!='+'):
				np1+=1
				fp+=1
			elif (str1[i+np1]!='+'and str2[i+np2]=='+'):
				#print(i+np1,i+np1,len(str1),len(str2)) 
				np2+=1
				fn+=1
		true_positive+=tp
		false_positive+=fp
		false_negative+=fn
fp1=codecs.open('undivide_output.txt', 'r', encoding='utf-8')
f1=fp1.read()
fp1.close()
lines1=f1.split('\n')

fp2=codecs.open('hand1.txt', 'r', encoding='utf-8')
f2=fp2.read()
fp2.close()
lines2=f2.split('\n')

for i in enumerate(lines1):
	flag=0
	word1=lines1[i[0]].split(':')[-1]
	word2=lines2[i[0]].split(':')[-1]
	wordlen=min(len(lines1[i[0]].split(':')[0]),len(lines2[i[0]].split('\t')[0]))
	if word1 =='':
		continue
	compare(word1, word2, wordlen)

print("True Positive: "+str(true_positive))
print("False Positive: "+str(false_positive))
print("False Negative: "+str(false_negative))
