Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9655c7c

Browse files
add evaluation function for seg, including recall and precision
1 parent 4d05a97 commit 9655c7c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

‎utils.py‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,34 @@ def read_sogou_report():
5656

5757
return sentences
5858

59+
def estimate_cws(current_labels,correct_labels):
60+
cor_dict = {}
61+
curt_dict = {}
62+
curt_start = 0
63+
cor_start = 0
64+
for label_index,(curt_label,cor_label) in enumerate(zip(current_labels,correct_labels)):
65+
if cor_label == 0:
66+
cor_dict[label_index] = label_index + 1
67+
elif cor_label == 1:
68+
cor_start = label_index
69+
elif cor_label == 3:
70+
cor_dict[cor_start] = label_index + 1
71+
72+
if curt_label == 0:
73+
curt_dict[label_index] = label_index + 1
74+
elif curt_label == 1:
75+
curt_start = label_index
76+
elif curt_label == 3:
77+
curt_dict[curt_start] = label_index + 1
78+
79+
cor_count = 0
80+
recall_length = len(curt_dict)
81+
prec_length = len(cor_dict)
82+
for curt_start in curt_dict.keys():
83+
if curt_start in cor_dict and curt_dict[curt_start] == cor_dict[curt_start]:
84+
cor_count += 1
85+
86+
return cor_count,prec_length,recall_length
5987

6088
if __name__ == '__main__':
6189
sentences = read_sogou_report()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /