seg_pos_recall_sum = 0 line_list = test_file.readlines() for i in range(0, len(line_list), 3): #字符串 line = line_list[i].strip() seq_letter_list = line #结构串 struct_line = line_list[i + 1].strip() struct_letter_list = struct_line try: #standard_seg_list = stardard_seg.mp_seg(line).split(" ") my_seg_list = my_seg.mp_seg(seq_letter_list).split(" ") standard_seg_list = seg_stru.stu_seg(seq_letter_list, struct_letter_list).split(" ") #my_seg_list = seg_stru.stu_seg(seq_letter_list, struct_letter_list).split(" ") except Exception as e: print "line error", e, line continue #print standard_seg_list #print my_seg_list #准确率 (precison, recall) = get_pr(standard_seg_list, my_seg_list) #词边界的准确率 (seg_pos_precision, seg_pos_recall) = get_seg_pos_precision(standard_seg_list, my_seg_list) seg_pos_precision_sum += seg_pos_precision seg_pos_recall_sum += seg_pos_recall
seg_pos_recall_sum = 0 line_list = test_file.readlines() for i in range(0,len(line_list),3): #字符串 line = line_list[i].strip() seq_letter_list = line #结构串 struct_line = line_list[i+1].strip() struct_letter_list = struct_line try: #standard_seg_list = stardard_seg.mp_seg(line).split(" ") my_seg_list = my_seg.mp_seg(seq_letter_list).split(" ") standard_seg_list = seg_stru.stu_seg(seq_letter_list, struct_letter_list).split(" ") #my_seg_list = seg_stru.stu_seg(seq_letter_list, struct_letter_list).split(" ") except Exception as e: #print "line error",e,line continue #print " ".join(standard_seg_list) print " ".join(my_seg_list) #准确率 (precison, recall) = get_pr(standard_seg_list, my_seg_list) #词边界的准确率 (seg_pos_precision, seg_pos_recall) = get_seg_pos_precision(standard_seg_list, my_seg_list) seg_pos_precision_sum += seg_pos_precision seg_pos_recall_sum += seg_pos_recall #print seg_pos_precision #print precison, recall