Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Alexis Nasr
tbp
Commits
7c0fd548
Commit
7c0fd548
authored
Nov 06, 2020
by
Alexis Nasr
Browse files
ajout de l'option v dans eval_mcf pour le calcul de la précision et du rappel pour chaque étiquette
parent
2d61f0d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/eval_mcf.py
View file @
7c0fd548
...
...
@@ -13,6 +13,12 @@ refMcdFileName = sys.argv[3]
hypMcdFileName
=
sys
.
argv
[
4
]
lang
=
sys
.
argv
[
5
]
if
len
(
sys
.
argv
)
==
7
:
verbose
=
True
else
:
verbose
=
False
#print('reading mcd from file :', refMcdFileName)
refMcd
=
Mcd
(
refMcdFileName
)
...
...
@@ -44,6 +50,10 @@ hypWordBuffer.readAllMcfFile()
govCorrect
=
0
labelCorrect
=
0
hypTotal
=
{}
refTotal
=
{}
refInterHypTotal
=
{}
hypSize
=
hypWordBuffer
.
getLength
()
for
index
in
range
(
hypSize
):
refWord
=
refWordBuffer
.
getWord
(
index
)
...
...
@@ -52,16 +62,40 @@ for index in range(hypSize):
hypGov
=
hypWord
.
getFeat
(
"GOV"
)
refLabel
=
refWord
.
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
:
govCorrect
+=
1
if
refLabel
==
hypLabel
:
labelCorrect
+=
1
LAS
=
labelCorrect
/
hypSize
UAS
=
govCorrect
/
hypSize
print
(
lang
,
LAS
,
UAS
)
if
refLabel
in
refInterHypTotal
:
refInterHypTotal
[
refLabel
]
+=
1
else
:
refInterHypTotal
[
refLabel
]
=
1
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)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment