home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / MacPerl 5.0.3 / MacPerl Source ƒ / Perl5 / eg / unuc < prev    next >
Encoding:
Text File  |  1994-12-26  |  2.8 KB  |  38 lines  |  [TEXT/MPS ]

  1. #!/usr/bin/perl
  2.  
  3. print STDERR "Loading proper nouns...\n";
  4. open(DICT,"/usr/dict/words") || die "Can't find /usr/dict/words: $!\n";
  5. while (<DICT>) {
  6.     if (/^[A-Z]/) {
  7.     chop;
  8.     ($lower = $_) =~ y/A-Z/a-z/;
  9.     $proper{$lower} = $_;
  10.     }
  11. }
  12. close DICT;
  13. print STDERR "Loading exceptions...\n";
  14.  
  15. $prog = <<'EOT';
  16. while (<>) {
  17.     next if /[a-z]/;
  18.     y/A-Z/a-z/;
  19.     s/(\w+)/$proper{$1} ? $proper{$1} : $1/eg;
  20.     s/^(\s*)([a-z])/$1 . (($tmp = $2) =~ y:a-z:A-Z:,$tmp)/e;
  21.     s/([-.?!]["']?(\n\s*|  \s*)["']?)([a-z])/$1 . (($tmp = $3) =~ y:a-z:A-Z:,$tmp)/eg;
  22.     s/\b([b-df-hj-np-tv-xz]+)\b/(($tmp = $1) =~ y:a-z:A-Z:,$tmp)/eg;
  23.     s/([a-z])'([SDT])\b/$1 . "'" . (($tmp = $2) =~ y:A-Z:a-z:,$tmp)/eg;
  24. EOT
  25. while (<DATA>) {
  26.     chop;
  27.     next if /^$/;
  28.     next if /^#/;
  29.     if (! /;$/) {
  30.     $foo = $_;
  31.     $foo =~ y/A-Z/a-z/;
  32.     print STDERR "Dup $_\n" if $proper{$foo};
  33.     $foo =~ s/([^\w ])/\\$1/g;
  34.     $foo =~ s/ /(\\s+)/g;
  35.     $foo = "\\b" . $foo if $foo =~ /^\w/;    # XXX till patch 9
  36.     $foo .= "\\b" if $foo =~ /\w$/;
  37.     $i = 0;
  38.     ($bar = $_) =~ s/ /