Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RL-Parsing
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
Releases
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Franck Dary
RL-Parsing
Commits
44403c5a
Commit
44403c5a
authored
3 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
Added script to convert results to latex
parent
db2d2863
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
results2latex.py
+116
-0
116 additions, 0 deletions
results2latex.py
with
116 additions
and
0 deletions
results2latex.py
0 → 100755
+
116
−
0
View file @
44403c5a
#! /usr/bin/env python3
import
sys
import
argparse
def
formatScore
(
score
)
:
return
score
.
replace
(
"
%
"
,
""
)
def
formatLang
(
lang
)
:
return
lang
.
split
(
'
-
'
)[
0
]
def
formatMetric
(
metric
)
:
return
metric
def
formatModel
(
model
)
:
return
model
if
__name__
==
"
__main__
"
:
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"
resultFile
"
,
type
=
str
,
help
=
"
File produced by macaon_data printResults.py
"
)
parser
.
add_argument
(
"
--caption
"
,
default
=
""
,
help
=
"
Caption
"
)
parser
.
add_argument
(
"
--label
"
,
default
=
"
tab:a
"
,
help
=
"
Label
"
)
parser
.
add_argument
(
"
--sota
"
,
default
=
False
,
action
=
"
store_true
"
,
help
=
"
Includes sota results.
"
)
args
=
parser
.
parse_args
()
resPerLang
=
{}
metrics
=
[
"
UPOS
"
,
"
UAS
"
]
models
=
[
"
tagger
"
,
"
eager
"
,
"
tagparser
"
]
regimes
=
[
"
sul
"
,
"
rl
"
,
"
rlb
"
]
mustIgnore
=
True
for
line
in
open
(
args
.
resultFile
,
"
r
"
)
:
line
=
line
.
strip
()
if
len
(
line
)
==
0
:
continue
if
"
-----
"
in
line
:
mustIgnore
=
False
continue
if
mustIgnore
:
continue
lang
,
metric
,
score
,
model
=
line
.
split
()
score
=
formatScore
(
score
)
lang
=
formatLang
(
lang
)
metric
=
formatMetric
(
metric
)
model
=
formatModel
(
model
)
if
lang
not
in
resPerLang
:
resPerLang
[
lang
]
=
{}
if
model
not
in
resPerLang
[
lang
]
:
resPerLang
[
lang
][
model
]
=
{}
resPerLang
[
lang
][
model
][
metric
]
=
score
# Bold for best values
for
lang
in
resPerLang
:
for
model
in
models
:
for
metric
in
metrics
:
highestValue
=
None
for
regime
in
regimes
:
modelName
=
"
%s_incr_%s
"
%
(
model
,
regime
)
if
metric
not
in
resPerLang
[
lang
][
modelName
]
:
continue
value
=
resPerLang
[
lang
][
modelName
][
metric
]
if
highestValue
is
None
or
float
(
value
)
>
float
(
highestValue
)
:
highestValue
=
value
for
regime
in
regimes
:
modelName
=
"
%s_incr_%s
"
%
(
model
,
regime
)
if
metric
not
in
resPerLang
[
lang
][
modelName
]
:
continue
if
resPerLang
[
lang
][
modelName
][
metric
]
==
highestValue
:
resPerLang
[
lang
][
modelName
][
metric
]
=
"
\\
bf{%s}
"
%
resPerLang
[
lang
][
modelName
][
metric
]
print
(
r
"
\begin{table}[htb]
"
)
print
(
r
"
\tabcolsep=0.8mm
"
)
print
(
r
"
\centering
"
)
print
(
r
"
\begin{tabular}{@{}lrrrr@{}} \toprule
"
)
columns
=
2
*
metrics
print
(
"
& TAGGER & PARSER & \multicolumn{2}{c}{TAGPARSER}
\\\\
"
)
print
(
"
Regime & %s
\\\\
\midrule
"
%
(
"
&
"
.
join
(
columns
)))
for
lang
in
[
"
French
"
,
"
English
"
,
"
German
"
,
"
Romanian
"
,
"
Russian
"
,
"
Arabic
"
,
"
Chinese
"
]
:
print
(
"
\multicolumn{5}{c}{%s}
\\\\
"
%
lang
)
for
regime
in
regimes
:
print
(
"
\%s%s{}
"
%
(
regime
,
"
t
"
if
regime
==
"
rlb
"
else
""
),
end
=
""
)
for
model
in
models
:
modelName
=
"
%s_incr_%s
"
%
(
model
,
regime
)
for
metric
in
metrics
:
if
metric
in
resPerLang
[
lang
][
modelName
]
:
print
(
"
& %s
"
%
resPerLang
[
lang
][
modelName
][
metric
],
end
=
""
)
print
(
"
\\\\
"
)
if
args
.
sota
:
sota
=
resPerLang
[
lang
][
"
sota
"
]
print
(
"
\sota{}
"
,
end
=
""
)
for
metric
in
2
*
metrics
:
if
metric
in
sota
:
print
(
"
& %s
"
%
sota
[
metric
],
end
=
""
)
else
:
print
(
"
& \_
"
,
end
=
""
)
print
(
"
\\\\
"
)
print
(
r
"
\bottomrule
"
)
print
(
r
"
\end{tabular}
"
)
print
(
"
\caption{%s}
"
%
args
.
caption
)
print
(
"
\label{tab:%s}
"
%
args
.
label
)
print
(
r
"
\end{table}
"
)
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