\n";
for(my $i = 0; $i < scalar(@{$sentenceData[0]}); $i++)
{
if($i > 0) {print "
Average Phrase Length: " . sprintf("%.3lf", $sentenceData[2]->[$i]) . "
![](\"$imgdir/$i.png\")
\n";
}
print "";
############################################################################################################################################
#2-argument
sub max
{
my ($a, $b) = @_;
return ($a > $b) ? $a : $b;
}
#N-argument
sub maxN
{
die "maxN(): empty array!\n" if scalar(@_) == 0;
my $max = shift @_;
map {$max = $_ if $_ > $max;} @_;
return $max;
}
#arguments: image, startX, arrayref of y-coords for writing, arrayref of arrayrefs of factor strings, font, color
sub writeFactoredStringGD
{
my ($img, $startX, $ys, $factors, $font, $color) = @_;
foreach my $word (@$factors)
{
for(my $i = 0; $i < scalar(@$ys); $i++)
{
$img->string($font, $startX, $ys->[$i], $word->[$i], $color);
}
$startX += $font->width * (maxN(map {length($_)} @$word) + 1);
}
}