home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-12-26 | 2.8 KB | 38 lines | [TEXT/MPS ] |
- #!/usr/bin/perl
-
- print STDERR "Loading proper nouns...\n";
- open(DICT,"/usr/dict/words") || die "Can't find /usr/dict/words: $!\n";
- while (<DICT>) {
- if (/^[A-Z]/) {
- chop;
- ($lower = $_) =~ y/A-Z/a-z/;
- $proper{$lower} = $_;
- }
- }
- close DICT;
- print STDERR "Loading exceptions...\n";
-
- $prog = <<'EOT';
- while (<>) {
- next if /[a-z]/;
- y/A-Z/a-z/;
- s/(\w+)/$proper{$1} ? $proper{$1} : $1/eg;
- s/^(\s*)([a-z])/$1 . (($tmp = $2) =~ y:a-z:A-Z:,$tmp)/e;
- s/([-.?!]["']?(\n\s*| \s*)["']?)([a-z])/$1 . (($tmp = $3) =~ y:a-z:A-Z:,$tmp)/eg;
- s/\b([b-df-hj-np-tv-xz]+)\b/(($tmp = $1) =~ y:a-z:A-Z:,$tmp)/eg;
- s/([a-z])'([SDT])\b/$1 . "'" . (($tmp = $2) =~ y:A-Z:a-z:,$tmp)/eg;
- EOT
- while (<DATA>) {
- chop;
- next if /^$/;
- next if /^#/;
- if (! /;$/) {
- $foo = $_;
- $foo =~ y/A-Z/a-z/;
- print STDERR "Dup $_\n" if $proper{$foo};
- $foo =~ s/([^\w ])/\\$1/g;
- $foo =~ s/ /(\\s+)/g;
- $foo = "\\b" . $foo if $foo =~ /^\w/; # XXX till patch 9
- $foo .= "\\b" if $foo =~ /\w$/;
- $i = 0;
- ($bar = $_) =~ s/ /