From db6407b415ae5efef968c50cfa79cb2a56d0b64d Mon Sep 17 00:00:00 2001 From: nwf Date: Fri, 29 Aug 2008 16:07:12 -0400 Subject: [PATCH] Minor updates to huffgen.pl utility darcs-hash:20080829200712-4d648-9dd281c4810c541106fb01dbc1772711df2d378b.gz --- huffgen.pl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/huffgen.pl b/huffgen.pl index f639efb..5a82f59 100644 --- a/huffgen.pl +++ b/huffgen.pl @@ -3,7 +3,7 @@ $Data::Dumper::Indent = 0; my $DEBUG = 1; my $PROGRESS = 1; -my $NARY=6; +my $NARY=5; my %count; my %icount; @@ -18,7 +18,7 @@ while (<>) { $totalcount++; print STDERR " Consumed $totalcount symbols...\r" - if $PROGRESS and ($totalcount % 1000 == 0); + if $PROGRESS and ($totalcount % 10000 == 0); } } @@ -75,6 +75,10 @@ while (numleft() > 1) { my $cv = 0; my @cs = (); + if ( numleft() < $NARY ) { + warn "Incomplete toplevel tree with ",numleft()," nodes \n"; + } + while ($i < $NARY and numleft() > 0) { my ($nn, $nv) = @{grabnext()}; @@ -92,7 +96,11 @@ while (numleft() > 1) { print STDERR "GROUPING ($cn)\@$cv\n" if $DEBUG; - push @secondary, ["($cn)", $cv]; + if (length $cn == 5) { + push @secondary, [" \"$cn\" ", $cv]; + } else { + push @secondary, [" [ $cn ] ", $cv]; + } } print @{$secondary[0]}[0]."\n"; -- 2.50.1