Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbojar <bojar@1f5c12ca-751b-0410-a591-d2e778427230>2010-02-03 17:35:21 +0300
committerbojar <bojar@1f5c12ca-751b-0410-a591-d2e778427230>2010-02-03 17:35:21 +0300
commit9b10946f108e00670e0a0e3f51242d10273d34a7 (patch)
tree6509fe4c8118de0eba50bc14bd82d65ac98f7baf /scripts/analysis
parent8891069ed80b49a33ffdb0bee65eb24767cd35b8 (diff)
fixed regexes to read current -osg format
verbose at bad lines git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@2850 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'scripts/analysis')
-rwxr-xr-xscripts/analysis/sg2dot.perl12
1 files changed, 9 insertions, 3 deletions
diff --git a/scripts/analysis/sg2dot.perl b/scripts/analysis/sg2dot.perl
index 1c5cf085d..f6a5dff49 100755
--- a/scripts/analysis/sg2dot.perl
+++ b/scripts/analysis/sg2dot.perl
@@ -26,8 +26,10 @@ $cpt = 0;
$line=<>; #skip first line (the empty hypothesis, no arc in fact)
+my $nr = 0;
while(($line=<>) )
{
+ $nr++;
$from = "";
$to = "";
$label = "";
@@ -40,7 +42,7 @@ while(($line=<>) )
#0 hyp=5 stack=1 back=0 score=-0.53862 transition=-0.53862 forward=181 fscore=-205.36 covered=0-0 out=I am , pC=-0.401291, c=-0.98555
#256 hyp=6566 stack=2 back=23 score=-2.15644 transition=-0.921959 recombined=6302 forward=15519 fscore=-112.807 covered=2-2 out=countries , , pC=-0.640574, c=-1.07215
- if($line =~ /hyp=(\d+).+stack=(\d+).+back=(\d+).+transition=([^ ]*).+recombined=(\d+).+out=(.*), pC/)
+ if($line =~ /hyp=(\d+).+stack=(\d+).+back=(\d+).+transition=([^ ]*).+recombined=(\d+).+out=(.*)(, pC|$)/)
{
#print STDERR "hyp=$1, stack=$2, from=$3, transition=$4, recombined=$5, out=$6\n";
$to = $1;
@@ -56,7 +58,7 @@ while(($line=<>) )
#$stack++;
#$stacks{$stack}{$recombined} = $recombined;
}
- elsif($line =~ /hyp=(\d+).+stack=(\d+).+back=(\d+).+transition=([^ ]*).+out=(.*), pC/)
+ elsif($line =~ /hyp=(\d+).+stack=(\d+).+back=(\d+).+transition=([^ ]*).+out=(.*)(, pC|$)/)
{
#print STDERR "hyp=$1, stack=$2, from=$3, transition=$4, out=$5\n";
$to = $1;
@@ -69,7 +71,9 @@ while(($line=<>) )
#$stack++;
#$stacks{$stack}{$to} = $to;
}
- else{ print STDERR "Bad file format ..."; exit(); }
+ else{
+ die "$nr:Bad line: $line\n";
+ }
$o =~ s/\"/\\"/g ;
#print STDERR "out = $o after regexp\n";
@@ -94,3 +98,5 @@ if ($organize_to_stacks) {
}
print STDOUT "\n}\n";
+
+print STDERR "Converted $nr lines.\n";