Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
fa449c72
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看板
提交
fa449c72
编写于
11月 06, 2019
作者:
1024的传说
提交者:
pkpk
11月 06, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix dialogue_general_understanding python3 (#3887)
上级
9a10a366
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
73 addition
and
67 deletion
+73
-67
PaddleNLP/PaddleDialogue/dialogue_general_understanding/dgu/evaluation.py
...Dialogue/dialogue_general_understanding/dgu/evaluation.py
+73
-67
未找到文件。
PaddleNLP/PaddleDialogue/dialogue_general_understanding/dgu/evaluation.py
浏览文件 @
fa449c72
...
...
@@ -22,6 +22,7 @@ class EvalDA(object):
"""
evaluate da testset, swda|mrda
"""
def
__init__
(
self
,
task_name
,
pred
,
refer
):
"""
predict file
...
...
@@ -67,6 +68,7 @@ class EvalATISIntent(object):
"""
evaluate da testset, swda|mrda
"""
def
__init__
(
self
,
pred
,
refer
):
"""
predict file
...
...
@@ -112,6 +114,7 @@ class EvalATISSlot(object):
"""
evaluate atis slot
"""
def
__init__
(
self
,
pred
,
refer
):
"""
pred file
...
...
@@ -143,7 +146,7 @@ class EvalATISSlot(object):
for
i
in
range
(
len
(
refer_label
)):
num
=
len
(
refer_label
[
i
])
refer_label_equal
.
extend
(
refer_label
[
i
])
pred_label
[
i
]
=
pred_label
[
i
][:
num
]
pred_label
[
i
]
=
pred_label
[
i
][:
num
]
pred_label_equal
.
extend
(
pred_label
[
i
])
return
pred_label_equal
,
refer_label_equal
...
...
@@ -197,6 +200,7 @@ class EvalUDC(object):
"""
evaluate udc
"""
def
__init__
(
self
,
pred
,
refer
):
"""
predict file
...
...
@@ -230,8 +234,8 @@ class EvalUDC(object):
calculate precision in recall n
"""
pos_score
=
data
[
ind
][
0
]
curr
=
data
[
ind
:
ind
+
m
]
curr
=
sorted
(
curr
,
key
=
lambda
x
:
x
[
0
],
reverse
=
True
)
curr
=
data
[
ind
:
ind
+
m
]
curr
=
sorted
(
curr
,
key
=
lambda
x
:
x
[
0
],
reverse
=
True
)
if
curr
[
n
-
1
][
0
]
<=
pos_score
:
return
1
...
...
@@ -249,7 +253,7 @@ class EvalUDC(object):
p_at_2_in_10
=
0.0
p_at_5_in_10
=
0.0
length
=
len
(
data
)
/
10
length
=
int
(
len
(
data
)
/
10
)
for
i
in
range
(
0
,
length
):
ind
=
i
*
10
...
...
@@ -269,6 +273,7 @@ class EvalDSTC2(object):
"""
evaluate dst testset, dstc2
"""
def
__init__
(
self
,
task_name
,
pred
,
refer
):
"""
predict file
...
...
@@ -357,7 +362,9 @@ def evaluate(task_name, pred_file, refer_file):
print
(
"JOINT ACC: %s"
%
eval_metrics
[
0
])
print
(
"OVERALL ACC: %s"
%
eval_metrics
[
1
])
else
:
print
(
"task name not in [udc|swda|mrda|atis_intent|atis_slot|dstc2|dstc2_asr|multi-woz]"
)
print
(
"task name not in [udc|swda|mrda|atis_intent|atis_slot|dstc2|dstc2_asr|multi-woz]"
)
if
__name__
==
"__main__"
:
...
...
@@ -368,5 +375,4 @@ if __name__ == "__main__":
pred_file
=
sys
.
argv
[
2
]
refer_file
=
sys
.
argv
[
3
]
evaluate
(
task_name
,
pred_file
,
refer_file
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录