summaryrefslogtreecommitdiff
path: root/report
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-03 21:56:25 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-03 21:56:25 +0000
commit250f75706e4de1470163e0b4c791035bc9822fb6 (patch)
tree5436f71d74bbac897db7e85642e6616d1c10e6c8 /report
parent2fd80bbceadd625b74f8cbd989c945ce24a60fcc (diff)
graph
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@470 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'report')
-rwxr-xr-xreport/prune_results/do.sh7
-rwxr-xr-xreport/prune_results/graph.sh102
-rwxr-xr-xreport/prune_results/merge-columns.pl20
3 files changed, 129 insertions, 0 deletions
diff --git a/report/prune_results/do.sh b/report/prune_results/do.sh
new file mode 100755
index 00000000..d541ee93
--- /dev/null
+++ b/report/prune_results/do.sh
@@ -0,0 +1,7 @@
+title="In multipass (TM -> TM+3gram), tuning for 1st pass -> BLEU (y) lost to pruning (x)." \
+ n4="tuned_unigram" \
+ n3="tuned_without_lm" \
+ n2="2ndpass_weights_without_lm" \
+ xlbl="post-pruning fraction of edges kept" \
+ obase=compare.1stpass.tune \
+ ./graph.sh space.2pass- hdt hdt0 hdt1
diff --git a/report/prune_results/graph.sh b/report/prune_results/graph.sh
new file mode 100755
index 00000000..ffd1dec8
--- /dev/null
+++ b/report/prune_results/graph.sh
@@ -0,0 +1,102 @@
+# see do.sh for usage
+d=$(dirname `readlink -f $0`)
+
+plboth() {
+ local o=$1
+ local oarg="-landscape"
+ [ "$portrait" ] && oarg=
+ shift
+ pl -png -o $o.png "$@"
+ pl -ps -o $o.ps $oarg "$@"
+ ps2pdf $o.ps $o.pdf
+}
+
+graph3() {
+ local y=$1
+ local ylbl="$2"
+ local y2=$3
+ local ylbl2="$4"
+ local y3=$5
+ local ylbl3="$6"
+ local ylbldistance=${7:-'0.7"'}
+ local name=${name:-$data}
+ local obase=${obase:-$opre$name.x_`filename_from $xlbl`.$y.`filename_from $ylbl`.$y2.`filename_from $ylbl2`.$y3.`filename_from $ylbl3`}
+ local of=$obase.png
+ local ops=$obase.ps
+ #yrange=0
+ #pointsym=none pointsym2=none
+ title=${title:-$ylbl $ylbl2 $ylbl3 vs. $xlbl}
+ xlbl=${xlbl:=x}
+ showvars_required obase xlbl ylbl ylbl2 ylbl3
+ require_files $data
+ plboth $obase -prefab lines data=$data x=1 y=$y name="$ylbl" y2=$y2 name2="$ylbl2" y3=$y3 name3="$ylbl3" ylbldistance=$ylbldistance xlbl="$xlbl" title="$title" ystubfmt '%4g' ystubdet="size=6" linedet2="style=1" linedet3="style=3" -scale ${scale:-1.4}
+ echo $of
+}
+
+pre() {
+ local pre=$1
+ shift
+ local f
+ for f in "$@"; do
+ echo $pre$f
+ done
+}
+
+main() {
+ files=( $(pre "$@") )
+ data=${data:-compare.$(filename_from $*)}
+ xlbl=${xlbl:-space}
+ showvars_required files data xlbl
+ require_files ${files[*]}
+ $d/merge-columns.pl ${files[*]} > $data
+ preview $data
+ graph3 2 "${n2:-$2}" 3 "${n3:-$3}" 4 "${n4:-$4}"
+ exit
+}
+
+echo2() {
+ echo "$@" 1>&2
+}
+
+errorq() {
+ echo2 ERROR: "$@"
+}
+
+error() {
+ errorq "$@"
+ return 2
+}
+
+showvars_required() {
+ echo2 $0 RUNNING WITH REQUIRED VARIABLES:
+ local k
+ for k in "$@"; do
+ eval local v=\$$k
+ echo2 $k=$v
+ if [ -z "$v" ] ; then
+ errorq "required (environment or shell) variable $k not defined!"
+ return 1
+ fi
+ done
+ echo2
+}
+
+require_files() {
+ local f
+ [ "$*" ] || error "require_files called with empty args list"
+ for f in "$@"; do
+ if ! have_file "$f" ; then
+ error "missing required file: $f"
+ return 1
+ fi
+ done
+ return 0
+}
+
+have_file() {
+ [ "$1" -a -f "$1" -a \( -z "$2" -o "$1" -nt "$2" \) -a \( -z "$require_nonempty" -o -s "$1" \) ]
+}
+
+if ! [ "$nomain" ] ; then
+ main "$@";exit
+fi
diff --git a/report/prune_results/merge-columns.pl b/report/prune_results/merge-columns.pl
new file mode 100755
index 00000000..07b02a92
--- /dev/null
+++ b/report/prune_results/merge-columns.pl
@@ -0,0 +1,20 @@
+#!/usr/bin/perl -w
+use strict;
+my $T="\t";
+my %d;
+sub info {
+ local $,=' ';
+ print STDERR @_,"\n";
+}
+for my $n (0..$#ARGV) {
+ open F,'<',$ARGV[$n];
+ info($n,$ARGV[$n]);
+ while(<F>) {
+ my ($x,$f,$r)=split ' ',$_,3;
+ $d{$x}->[$n]=$f
+ }
+}
+for (sort keys %d) {
+ my @f=map { $T.(defined($_)?$_:'x') } @{$d{$_}};
+ print $_,@f,"\n";
+}