Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
a07b251c
M
models
项目概览
PaddlePaddle
/
models
大约 2 年 前同步成功
通知
232
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
a07b251c
编写于
7月 05, 2018
作者:
Y
Yibing Liu
提交者:
GitHub
7月 05, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1035 from kuke/fix_cer_scoring
Handle the special tokens in scoring cer
上级
ef85159a
a45e38f9
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
13 addition
and
1 deletion
+13
-1
fluid/DeepASR/score_error_rate.py
fluid/DeepASR/score_error_rate.py
+13
-1
未找到文件。
fluid/DeepASR/score_error_rate.py
浏览文件 @
a07b251c
...
...
@@ -16,10 +16,18 @@ def parse_args():
default
=
'cer'
,
choices
=
[
'cer'
,
'wer'
],
help
=
"Error rate type. (default: %(default)s)"
)
parser
.
add_argument
(
'--special_tokens'
,
type
=
str
,
default
=
'<SPOKEN_NOISE>'
,
help
=
"Special tokens in scoring CER, seperated by space. "
"They shouldn't be splitted and should be treated as one special "
"character. Example: '<SPOKEN_NOISE> <bos> <eos>' "
"(default: %(default)s)"
)
parser
.
add_argument
(
'--ref'
,
type
=
str
,
required
=
True
,
help
=
"The ground truth text."
)
parser
.
add_argument
(
'--hyp'
,
type
=
str
,
required
=
True
,
help
=
"The decoding result."
)
'--hyp'
,
type
=
str
,
required
=
True
,
help
=
"The decoding result
text
."
)
args
=
parser
.
parse_args
()
return
args
...
...
@@ -31,6 +39,8 @@ if __name__ == '__main__':
sum_errors
,
sum_ref_len
=
0.0
,
0
sent_cnt
,
not_in_ref_cnt
=
0
,
0
special_tokens
=
args
.
special_tokens
.
split
(
" "
)
with
open
(
args
.
ref
,
"r"
)
as
ref_txt
:
line
=
ref_txt
.
readline
()
while
line
:
...
...
@@ -51,6 +61,8 @@ if __name__ == '__main__':
continue
if
args
.
error_rate_type
==
'cer'
:
for
sp_tok
in
special_tokens
:
sent
=
sent
.
replace
(
sp_tok
,
'
\0
'
)
errors
,
ref_len
=
char_errors
(
ref_dict
[
key
].
decode
(
"utf8"
),
sent
.
decode
(
"utf8"
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录