This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 5.002_01: lib/File/Basename.pm
[perl5.git] / eg / unuc
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/ /'$' . ++$i/eg;
39         $_ = "s/$foo/$bar/gi;";
40     }
41     $prog .= '    ' . $_ . "\n";
42 }
43 $prog .= "}\ncontinue {\n    print;\n}\n";
44
45 $/ = '';
46 #print $prog;
47 eval $prog; die $@ if $@;
48 __END__
49 A.M.
50 Air Force
51 Air Force Base
52 Air Force Station
53 American
54 Apr.
55 Ariane
56 Aug.
57 August
58 Bureau of Labor Statistics
59 CIT
60 Caltech
61 Cape Canaveral
62 Challenger
63 China
64 Corporation
65 Crippen
66 Daily News in Brief
67 Daniel Quayle
68 Dec.
69 Discovery
70 Edwards
71 Endeavour
72 Feb.
73 Ford Aerospace
74 Fri.
75 General Dynamics
76 George Bush
77 Headline News
78 HOTOL
79 I
80 II
81 III
82 IV
83 IX
84 Institute of Technology
85 JPL
86 Jan.
87 Jul.
88 Jun.
89 Kennedy Space Center
90 LDEF
91 Long Duration Exposure Facility
92 Long March
93 Mar.
94 March
95 Martin
96 Martin Marietta
97 Mercury
98 Mon.
99 in May
100 s/\bmay (\d)/May $1/g;
101 s/\boffice of (\w)/'Office of ' . (($tmp = $1) =~ y:a-z:A-Z:,$tmp)/eg;
102 National Science Foundation
103 NASA Select
104 New Mexico
105 Nov.
106 OMB
107 Oct.
108 Office of Management and Budget
109 President
110 President Bush
111 Richard Truly
112 Rocketdyne
113 Russian
114 Russians
115 Sat.
116 Sep.
117 Soviet
118 Soviet Union
119 Soviets
120 Space Shuttle
121 Sun.
122 Thu.
123 Tue.
124 U.S.
125 Union of Soviet Socialist Republics
126 United States
127 VI
128 VII
129 VIII
130 Vice President
131 Vice President Quayle
132 Wed.
133 White Sands
134 Kaman Aerospace
135 Aerospace Daily
136 Aviation Week
137 Space Technology
138 Washington Post
139 Los Angeles Times
140 New York Times
141 Aerospace Industries Association
142 president of
143 Johnson Space Center
144 Space Services
145 Inc.
146 Co.
147 Hughes Aircraft
148 Company
149 Orbital Sciences
150 Swedish Space
151 Arnauld
152 Nicogosian
153 Magellan
154 Galileo
155 Mir
156 Jet Propulsion Laboratory
157 University
158 Department of Defense
159 Orbital Science
160 OMS
161 United Press International
162 United Press
163 UPI
164 Associated Press
165 AP
166 Cable News Network
167 Cape York
168 Zenit
169 SYNCOM
170 Eastern
171 Western
172 Test Range
173 Jcsat
174 Japanese Satellite Communications
175 Defence Ministry
176 Defense Ministry
177 Skynet
178 Fixed Service Structure
179 Launch Processing System
180 Asiasat
181 Launch Control Center
182 Earth
183 CNES
184 Glavkosmos
185 Pacific
186 Atlantic