-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathresults2tex.pl
80 lines (68 loc) · 1.94 KB
/
results2tex.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/perl
##-------------------------------------------------------------------##
## Report evaluation results in a tabular form: ##
## ##
## Takes as input the file name of results (usually a .csv file) ##
## and creates a .tex file, which is compiled into a .pdf file ##
## using "pdflatex". ##
## Author: Elias Iosif ##
##-------------------------------------------------------------------##
## Input args
##-----------
$results_file = $ARGV[0]; chomp($results_file); ## File of evaluation results
## Consts
##-------
$amb = '&';
$nln = '\\\\';
$hln = '\hline';
## Output file
##--------------
$tex_file = $results_file.".tex"; ## Output: .tex file
open (I,"$results_file") || die "Can not open $results_file\n";
open (O,">$tex_file") || die "Can not write $tex_file\n";
print O <<'P1';
\documentclass[a4paper,10pt]{article}
\usepackage[utf8x]{inputenc}
\begin{document}
\scriptsize
\begin{center}
\begin{tabular}{|c||c|c|c||c|c|}
\hline
&Exact&Under&Over& & \\
Rule&Induction&Induction&Induction&Precision&Recall\\
&Ratio&Ratio&Ratio& & \\
\hline
\hline
P1
$r = <I>;
$r = <I>;
while ($r ne "")
{
chomp($r);
($f1,$f2,$f3,$f4,$f5,$f6) = split(/,/,$r);
$f1 =~ s/</\$<\$/g;
$f1 =~ s/>/\$>\$/g;
$f1 =~ s/_/\-/g;
print ($f1,$amb,$f2,$amb,$f3,$amb,$f4,$amb,$f5,$amb,$f6," ",$nln,"\n");
print ($hln,"\n");
if (($f1 =~ /ALL/) && ($f1 =~ /RULES/))
{
print O ($hln,"\n");
print O ($f1,$amb,$f2,$amb,$f3,$amb,$f4,$amb,$f5,$amb,$f6," ",$nln,"\n");
print O ($hln,"\n");
}
else
{
print O ($f1,$amb,$f2,$amb,$f3,$amb,$f4,$amb,$f5,$amb,$f6," ",$nln,"\n");
print O ($hln,"\n");
}
$r = <I>;
}
close (I);
print O <<'PFINAL';
\end{tabular}
\end{center}
\end{document}
PFINAL
close (O);
system ("pdflatex $tex_file"); ## Output: compile a .pdf file based on the .tex file