diff --git a/scripts/LatticeToDot.pl b/scripts/LatticeToDot.pl old mode 100644 new mode 100755 index 112484f..2ebc184 --- a/scripts/LatticeToDot.pl +++ b/scripts/LatticeToDot.pl @@ -46,6 +46,7 @@ my $end = ""; my $acoustic = ""; my $lm = ""; +my $time = ""; my $i = 0; my @chunks; @@ -62,6 +63,7 @@ $end = ""; $acoustic = ""; $lm = ""; + $time = ""; # Find any fields in this line of text for ($i = 0; $i < scalar @chunks; $i++) @@ -90,6 +92,10 @@ { $lm = substr($chunks[$i], 2); } + elsif ($chunks[$i] =~ m/t=/) + { + $time = substr($chunks[$i], 2); + } } # Now determine if we had a node line or an edge line @@ -98,7 +104,7 @@ # Discard emtpy start and end tags (otherwise graphviz throws an error) if(($start eq "") && ($end eq "")) { - printf STDERR "Discarding a edge line, because the start AND end label are empty\n"; + printf STDERR "Discarding an edge line, because the start AND end label is empty\n"; } else { @@ -109,8 +115,29 @@ else { # Node line + if($time eq "") + { printf "\t$id [label = \"$word\"];\n"; } + else + { + #replace > (greater than sign aka end node) with the html code (otherwise problems with dot + #rendering) + if($word eq ">") + { + $word=">" + } + #replace > (smaller than sign aka start node) with the html code (otherwise problems with dot + #rendering) + elsif($word eq "<") + { + $word="<" + } + #output the word with the time information. Print word bold and time smaller than the normal + #font + printf "\t$id [label = < $word
t=$time >];\n"; + } + } } close IN;