file = open(str1,"r") ref = [ x.strip() for x in file.readlines() if x.strip() ] file.close() str1 = "" for x in hypo: str1 = str1 + x + " " hypo = str1 str1 = "" for x in ref: str1 = str1 + x + " " ref = str1.decode('ascii', 'ignore') str1 = "" ref_texts = {'A':ref} summary_text = hypo try: score = rouge.score_summary(summary_text, ref_texts) except: ck-=1 print "Error at ", k+1 k+=1 continue for x in jsonvals.keys(): jsonvals[x]+=score[x] k+=1 print str(k)+"/"+str(ck) # if k==10: # break print "\n\n" for x in jsonvals.keys():