Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tbp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Alexis Nasr
tbp
Commits
7c0fd548
Commit
7c0fd548
authored
4 years ago
by
Alexis Nasr
Browse files
Options
Downloads
Patches
Plain Diff
ajout de l'option v dans eval_mcf pour le calcul de la précision et du rappel pour chaque étiquette
parent
2d61f0d5
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/eval_mcf.py
+40
-6
40 additions, 6 deletions
src/eval_mcf.py
with
40 additions
and
6 deletions
src/eval_mcf.py
+
40
−
6
View file @
7c0fd548
...
@@ -13,6 +13,12 @@ refMcdFileName = sys.argv[3]
...
@@ -13,6 +13,12 @@ refMcdFileName = sys.argv[3]
hypMcdFileName
=
sys
.
argv
[
4
]
hypMcdFileName
=
sys
.
argv
[
4
]
lang
=
sys
.
argv
[
5
]
lang
=
sys
.
argv
[
5
]
if
len
(
sys
.
argv
)
==
7
:
verbose
=
True
else
:
verbose
=
False
#print('reading mcd from file :', refMcdFileName)
#print('reading mcd from file :', refMcdFileName)
refMcd
=
Mcd
(
refMcdFileName
)
refMcd
=
Mcd
(
refMcdFileName
)
...
@@ -44,6 +50,10 @@ hypWordBuffer.readAllMcfFile()
...
@@ -44,6 +50,10 @@ hypWordBuffer.readAllMcfFile()
govCorrect
=
0
govCorrect
=
0
labelCorrect
=
0
labelCorrect
=
0
hypTotal
=
{}
refTotal
=
{}
refInterHypTotal
=
{}
hypSize
=
hypWordBuffer
.
getLength
()
hypSize
=
hypWordBuffer
.
getLength
()
for
index
in
range
(
hypSize
):
for
index
in
range
(
hypSize
):
refWord
=
refWordBuffer
.
getWord
(
index
)
refWord
=
refWordBuffer
.
getWord
(
index
)
...
@@ -52,16 +62,40 @@ for index in range(hypSize):
...
@@ -52,16 +62,40 @@ for index in range(hypSize):
hypGov
=
hypWord
.
getFeat
(
"
GOV
"
)
hypGov
=
hypWord
.
getFeat
(
"
GOV
"
)
refLabel
=
refWord
.
getFeat
(
"
LABEL
"
)
refLabel
=
refWord
.
getFeat
(
"
LABEL
"
)
hypLabel
=
hypWord
.
getFeat
(
"
LABEL
"
)
hypLabel
=
hypWord
.
getFeat
(
"
LABEL
"
)
if
hypLabel
in
hypTotal
:
hypTotal
[
hypLabel
]
+=
1
else
:
hypTotal
[
hypLabel
]
=
1
if
refLabel
in
refTotal
:
refTotal
[
refLabel
]
+=
1
else
:
refTotal
[
refLabel
]
=
1
if
refGov
==
hypGov
:
if
refGov
==
hypGov
:
govCorrect
+=
1
govCorrect
+=
1
if
refLabel
==
hypLabel
:
if
refLabel
==
hypLabel
:
labelCorrect
+=
1
labelCorrect
+=
1
if
refLabel
in
refInterHypTotal
:
LAS
=
labelCorrect
/
hypSize
refInterHypTotal
[
refLabel
]
+=
1
UAS
=
govCorrect
/
hypSize
else
:
refInterHypTotal
[
refLabel
]
=
1
print
(
lang
,
LAS
,
UAS
)
LAS
=
100
*
labelCorrect
/
hypSize
UAS
=
100
*
govCorrect
/
hypSize
print
(
"
%s
\t
%.2f
\t
%.2f
"
%
(
lang
,
LAS
,
UAS
))
if
verbose
:
print
(
"
------------------------------
"
)
print
(
"
label
\t
prec
\t
rec
\t
fscore
"
)
print
(
"
------------------------------
"
)
for
label
in
refInterHypTotal
:
precision
=
refInterHypTotal
[
label
]
/
hypTotal
[
label
]
recall
=
refInterHypTotal
[
label
]
/
refTotal
[
label
]
fscore
=
2
*
precision
*
recall
/
(
precision
+
recall
)
print
(
"
%s
\t
%.2f
\t
%.2f
\t
%.2f
"
%
(
label
,
precision
,
recall
,
fscore
)
)
# print("REF GOV = ", refGov, "HYP GOV = ", hypGov, "REF LABEL = ", refLabel, "HYP LABEL = ", hypLabel)
# print("REF GOV = ", refGov, "HYP GOV = ", hypGov, "REF LABEL = ", refLabel, "HYP LABEL = ", hypLabel)
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