train = open("finalSegmentation.txt").read()
test = open("segmentationSelf_Vishal.txt").read()

f = open('vishal_segmented.txt', 'w')
print f
train = train.decode("utf-8")
train = train.replace(':','\n').split('\n')
test = test.decode("utf-8")
test = test.replace(':','\n').split('\n')
#test = test.split('\n')
print test
for i in range(0,len(test)):
	for j in range(0,len(train)-1):
		if (j%2==0 & i%2==0):
			if  (train[j]==test[i]):
				#x = ':'.join([train[j].encode("utf=8"),train[j+1].encode("utf=8")])
				x = train[j+1].encode("utf=8")
				y = test[i+1].encode("utf=8")
				print ':'.join([train[j].encode("utf=8"),train[j+1].encode("utf=8")])
				f.write(x+' \t' +y + '\n')
		

