I am building a trigram tagging decodes with a pre-trained model I have a file that contains on each line (feature,weight) for tag features or trigram features. I need to build two dictionaries to access those values from my main program, the main program will loop through features and look-up the weights to use them in calculations in a Viterbi algorithm. The code below runs ( I inserted print statements, etc) but when it ends, IDLE says not responding and I have to break with control C. The file has 613 pages in Word and a total of 32K data pairs. Why is the program not responding? is there a more efficient way of doing this?
def tag_tri_form():
f_tag=open('tag.model','r')
tag_dic={}
trigram_dic={}
for line in f_tag:
lines=line.split()
if 'TAG' in lines[0]:
tag_dic[lines[0]]=lines[1]
else:
trigram_dic[lines[0]]=lines[1]
return tag_dic,trigram_dic