Blame view
egs/sprakbanken/s5/local/dict/add_counts.pl
680 Bytes
8dcb6dfcb first commit |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
#!/usr/bin/env perl # Add counts to an oovlist. # Reads in counts as output by uniq -c, and # an oovlist, and prints out the counts of the oovlist. (@ARGV == 1 || @ARGV == 2) || die "Usage: add_counts.pl count_file [oovlist] "; $counts = shift @ARGV; open(C, "<$counts") || die "Opening counts file $counts"; while(<C>) { @A = split(" ", $_); @A == 2 || die "Bad line in counts file: $_"; ($count, $word) = @A; $count =~ m:^\d+$: || die "Bad count $A[0] "; $counts{$word} = $count; } while(<>) { chop; $w = $_; $w =~ m:\S+: || die "Bad word $w"; defined $counts{$w} || die "Word $w not present in counts file"; print "\t$counts{$w}\t$w "; } |