Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
emoUS-public
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
dsml
emoUS-public
Commits
0b357433
Commit
0b357433
authored
2 years ago
by
Hsien-Chin Lin
Browse files
Options
Downloads
Patches
Plain Diff
wip
parent
7bc4f213
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
convlab/policy/genTUS/evaluate.py
+25
-6
25 additions, 6 deletions
convlab/policy/genTUS/evaluate.py
with
25 additions
and
6 deletions
convlab/policy/genTUS/evaluate.py
+
25
−
6
View file @
0b357433
...
@@ -147,6 +147,14 @@ class Evaluator:
...
@@ -147,6 +147,14 @@ class Evaluator:
indent
=
2
)
indent
=
2
)
return
os
.
path
.
join
(
dir_name
,
"
nlg_eval.json
"
)
return
os
.
path
.
join
(
dir_name
,
"
nlg_eval.json
"
)
@staticmethod
def
_intent_domain
(
action
):
acts
=
[]
for
intent
,
domain
,
slot
,
value
in
action
:
if
[
intent
,
domain
]
not
in
acts
:
acts
.
append
([
intent
,
domain
])
return
acts
def
evaluation
(
self
,
input_file
=
None
,
generated_file
=
None
):
def
evaluation
(
self
,
input_file
=
None
,
generated_file
=
None
):
force_prediction
=
True
force_prediction
=
True
if
generated_file
:
if
generated_file
:
...
@@ -187,17 +195,28 @@ class Evaluator:
...
@@ -187,17 +195,28 @@ class Evaluator:
golden_acts
.
append
(
dialog
[
"
golden_acts
"
])
golden_acts
.
append
(
dialog
[
"
golden_acts
"
])
dialog_result
=
gen_file
[
'
dialog
'
]
dialog_result
=
gen_file
[
'
dialog
'
]
scores
=
{
"
precision
"
:
[],
"
recall
"
:
[],
"
f1
"
:
[],
"
turn_acc
"
:
[]}
scores
=
{
"
complete
"
:
{
"
precision
"
:
[],
"
recall
"
:
[],
"
f1
"
:
[],
"
turn_acc
"
:
[]},
"
intent_domain
"
:
{
"
precision
"
:
[],
"
recall
"
:
[],
"
f1
"
:
[],
"
turn_acc
"
:
[]}}
for
gen_act
,
golden_act
in
zip
(
gen_acts
,
golden_acts
):
for
gen_act
,
golden_act
in
zip
(
gen_acts
,
golden_acts
):
s
=
f1_measure
(
preds
=
gen_act
,
labels
=
golden_act
)
s
=
f1_measure
(
preds
=
gen_act
,
labels
=
golden_act
)
for
metric
in
scores
:
for
metric
in
scores
[
"
complete
"
]:
scores
[
metric
].
append
(
s
[
metric
])
scores
[
"
complete
"
][
metric
].
append
(
s
[
metric
])
s
=
f1_measure
(
preds
=
self
.
_intent_domain
(
gen_act
),
labels
=
self
.
_intent_domain
(
golden_act
))
for
metric
in
scores
[
"
intent_domain
"
]:
scores
[
"
intent_domain
"
][
metric
].
append
(
s
[
metric
])
result
=
{}
result
=
{}
for
metric
in
scores
:
# for metric in scores:
result
[
metric
]
=
sum
(
scores
[
metric
])
/
len
(
scores
[
metric
])
# result[metric] = sum(scores[metric])/len(scores[metric])
print
(
f
"
{
metric
}
:
{
result
[
metric
]
}
"
)
# print(f"{metric}: {result[metric]}")
for
metric_type
,
score
in
scores
.
items
():
result
[
metric_type
]
=
{}
for
m
,
s
in
score
.
items
():
result
[
metric_type
][
m
]
=
sum
(
s
)
/
len
(
s
)
print
(
f
"
{
metric_type
}
-
{
m
}
:
{
result
[
metric_type
][
m
]
}
"
)
result
[
"
dialog
"
]
=
dialog_result
result
[
"
dialog
"
]
=
dialog_result
basename
=
"
semantic_evaluation_result
"
basename
=
"
semantic_evaluation_result
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment