未验证 提交 7109fadc 编写于 作者: Z zhoujun 提交者: GitHub

Merge pull request #4971 from LDOUBLEV/sdmgr

fix win
...@@ -291,7 +291,7 @@ class KieLabelEncode(object): ...@@ -291,7 +291,7 @@ class KieLabelEncode(object):
def __init__(self, character_dict_path, norm=10, directed=False, **kwargs): def __init__(self, character_dict_path, norm=10, directed=False, **kwargs):
super(KieLabelEncode, self).__init__() super(KieLabelEncode, self).__init__()
self.dict = dict({'': 0}) self.dict = dict({'': 0})
with open(character_dict_path, 'r') as fr: with open(character_dict_path, 'r', encoding='utf-8') as fr:
idx = 1 idx = 1
for line in fr: for line in fr:
char = line.strip() char = line.strip()
......
...@@ -48,7 +48,7 @@ class RecMetric(object): ...@@ -48,7 +48,7 @@ class RecMetric(object):
self.norm_edit_dis += norm_edit_dis self.norm_edit_dis += norm_edit_dis
return { return {
'acc': correct_num / all_num, 'acc': correct_num / all_num,
'norm_edit_dis': 1 - norm_edit_dis / all_num 'norm_edit_dis': 1 - norm_edit_dis / (all_num + 1e-3)
} }
def get_metric(self): def get_metric(self):
...@@ -58,8 +58,8 @@ class RecMetric(object): ...@@ -58,8 +58,8 @@ class RecMetric(object):
'norm_edit_dis': 0, 'norm_edit_dis': 0,
} }
""" """
acc = 1.0 * self.correct_num / self.all_num acc = 1.0 * self.correct_num / (self.all_num + 1e-3)
norm_edit_dis = 1 - self.norm_edit_dis / self.all_num norm_edit_dis = 1 - self.norm_edit_dis / (self.all_num + 1e-3)
self.reset() self.reset()
return {'acc': acc, 'norm_edit_dis': norm_edit_dis} return {'acc': acc, 'norm_edit_dis': norm_edit_dis}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册