#-*-Mode: perl;-*- eval "\$opt_$1=\$2" while $ARGV[0] =~ /^(\w+)=(.*)/ && shift; print " Frequency of codas

Frequency of codas of English monomorphemic monosyllables

Words are from the Random House Dictionary, 2nd ed. Word frequencies are weighted by the frequencies in the Brown corpus (Francis & Kucera). "; if (defined($opt_zero)) { printf("

Counting 0 freqs in Brown as $opt_zero\n"); } $vowels = "aAcCeEioORuUVWyY"; while ($line = ) { ($pr, $sp, $freq) = split(/\t/, $line); next if $pr eq ''; if (!$freq && defined($opt_zero)) {$freq = $opt_zero;} ($coda) = $pr =~ /[$vowels]([^$vowels]*)$/o; if (!defined($coda)) {$coda = '';} &bump(*types, $coda, 1); &bump(*tokens, $coda, $freq); &eg(*eg, $coda); } &reportTable(*types, *tokens, *eg, 'coda'); sub reportTable { local(*types, *tokens, *eg, $name) = @_; @inventory = sort keys %types; $nTypes = @inventory; print "

$nTypes different $name.\n\n"; print "

\n"; print "\n"; print "\n"; for $item (@inventory) { printf("\n", $item, $types{$item}, $tokens{$item}); } print "
Number of instances of each $name
VowelWord TypesWord TokensExamples
%s%d%.1f$eg{$item}
\n"; print "\n"; } sub bump { local(*table, $key, $value) = @_; if (defined($table{$key})) { $table{$key} += $value; } else { $table{$key} = $value; } } sub eg { local(*table, $key) = @_; if (!defined($table{$key})) {$table{$key} = $sp;} else { $examples = "$table{$key},$sp"; if (length($examples) < 50) {$table{$key} = $examples;} } } print "

This report was generated by a Perl programme. ";