Skip to content
Snippets Groups Projects
Commit d65a4f60 authored by Franck Dary's avatar Franck Dary
Browse files

Improved latex tab generator

parent f6d89f91
No related branches found
No related tags found
No related merge requests found
......@@ -2,28 +2,31 @@
import sys
metrics = []
def toIgnore(model) :
return "bt2" in model
def modelName(model) :
if "bt1" in model.lower() :
return "RL_BT1"
return "RL\_BT1"
if "no" in model.lower() :
return "RL_NOBT"
return "RL\_NOBT"
if "oracle" in model.lower() :
return "SUPERVISED"
return "SL"
print("ERROR %s not found"%model)
exit(1)
return "NOT FOUND"
def nicePValue(p) :
if p == "_" :
return p
return "\_"
return "%.3f"%p
for line in open(sys.argv[1]) :
for filename in sys.argv[1:] :
metrics = []
for line in open(filename) :
line = line.strip()
if len(line) == 0 :
if len(line) == 0 or "------" in line :
continue
splited = line.split()
if len(splited) == 1 :
......@@ -36,7 +39,7 @@ for line in open(sys.argv[1]) :
if len(splited) == 9 :
metrics[-1][1][-1].append(splited[8].split('=')[-1])
else :
metrics[-1][1][-1].append("_")
metrics[-1][1][-1].append("\_")
asTab = [["\\textbf{Model}"] + ["\\textbf{%s}"%[m[0],"p"][i] for m in metrics for i in [0,1]]]
models = {}
......@@ -52,13 +55,17 @@ for model in models :
asTab.append([modelName(model)])
asTab[-1] += [models[model][i][0][j] for i in range(len(metrics)) for j in [0,2]]
print("""\\begin{table}[]
\\begin{tabular}{|l|l|l|l|}
print("""\\begin{table}
\centering
\\tabcolsep=0.8mm
\\begin{tabular}{|l|l|l|l|l|}
\hline""")
for line in asTab :
print(" & ".join(line), "\\\\ \hline")
print("""\end{tabular}
\caption{}
\label{tab:my-table}
\end{table}""")
\caption{%s on UD\_French-GSD}
\label{tab:res_%s}
\end{table}
"""%(filename.split('.')[0],filename.split('.')[0]))
......@@ -8,6 +8,12 @@ def toIgnore(model) :
return "bt2" in model
def modelName(model) :
if "tagger" in model.lower() :
return "TAGGER"
if "tagparser" in model.lower() :
return "TAPARSER"
if "parser" in model.lower() :
return "PARSER"
if "bt1" in model.lower() :
return "RL\_BT1"
if "no" in model.lower() :
......@@ -34,10 +40,10 @@ targetValues = {"nbActions" : ("\#Actions",prettyInt),
"nbBack" : ("\#Backs",prettyInt),
"backPrecision" : ("bPrec",percent),
"backRecall" : ("bRec",percent),
"nbRedoneCorrectCorrect" : ("\%C$\\rightarrow$C",percent),
"nbRedoneErrErr" : ("\%E$\\rightarrow$E",percent),
"nbRedoneCorrectErr" : ("\%C$\\rightarrow$E",percent),
"nbRedoneErrCorrect" : ("\%E$\\rightarrow$C",percent)}
"nbRedoneCorrectCorrect" : ("C$\\rightarrow$C",percent),
"nbRedoneErrErr" : ("E$\\rightarrow$E",percent),
"nbRedoneCorrectErr" : ("C$\\rightarrow$E",percent),
"nbRedoneErrCorrect" : ("E$\\rightarrow$C",percent)}
for t in targetValues :
old = targetValues[t]
targetValues[t] = ("\\texttt{%s}"%old[0],old[1])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment