Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for displaying the time information of HTK lattice files #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion scripts/LatticeToDot.pl
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
my $end = "";
my $acoustic = "";
my $lm = "";
my $time = "";

my $i = 0;
my @chunks;
Expand All @@ -62,6 +63,7 @@
$end = "";
$acoustic = "";
$lm = "";
$time = "";

# Find any fields in this line of text
for ($i = 0; $i < scalar @chunks; $i++)
Expand Down Expand Up @@ -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
Expand All @@ -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
{
Expand All @@ -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="&gt;"
}
#replace > (smaller than sign aka start node) with the html code (otherwise problems with dot
#rendering)
elsif($word eq "<")
{
$word="&lt;"
}
#output the word with the time information. Print word bold and time smaller than the normal
#font
printf "\t$id [label = < <B>$word</B><br/><FONT POINT-SIZE='10'>t=$time</FONT> >];\n";
}
}
}

close IN;
Expand Down