summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/perl/eg/unuc
blob: ae5c65285db294e8a34ed97afa4aa1c33eac7113 (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/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/ /'$' . ++$i/eg;
	$_ = "s/$foo/$bar/gi;";
    }
    $prog .= '    ' . $_ . "\n";
}
$prog .= "}\ncontinue {\n    print;\n}\n";

$/ = '';
#print $prog;
eval $prog; die $@ if $@;
__END__
A.M.
Air Force
Air Force Base
Air Force Station
American
Apr.
Ariane
Aug.
August
Bureau of Labor Statistics
CIT
Caltech
Cape Canaveral
Challenger
China
Corporation
Crippen
Daily News in Brief
Daniel Quayle
Dec.
Discovery
Edwards
Endeavour
Feb.
Ford Aerospace
Fri.
General Dynamics
George Bush
Headline News
HOTOL
I
II
III
IV
IX
Institute of Technology
JPL
Jan.
Jul.
Jun.
Kennedy Space Center
LDEF
Long Duration Exposure Facility
Long March
Mar.
March
Martin
Martin Marietta
Mercury
Mon.
in May
s/\bmay (\d)/May $1/g;
s/\boffice of (\w)/'Office of ' . (($tmp = $1) =~ y:a-z:A-Z:,$tmp)/eg;
National Science Foundation
NASA Select
New Mexico
Nov.
OMB
Oct.
Office of Management and Budget
President
President Bush
Richard Truly
Rocketdyne
Russian
Russians
Sat.
Sep.
Soviet
Soviet Union
Soviets
Space Shuttle
Sun.
Thu.
Tue.
U.S.
Union of Soviet Socialist Republics
United States
VI
VII
VIII
Vice President
Vice President Quayle
Wed.
White Sands
Kaman Aerospace
Aerospace Daily
Aviation Week
Space Technology
Washington Post
Los Angeles Times
New York Times
Aerospace Industries Association
president of
Johnson Space Center
Space Services
Inc.
Co.
Hughes Aircraft
Company
Orbital Sciences
Swedish Space
Arnauld
Nicogosian
Magellan
Galileo
Mir
Jet Propulsion Laboratory
University
Department of Defense
Orbital Science
OMS
United Press International
United Press
UPI
Associated Press
AP
Cable News Network
Cape York
Zenit
SYNCOM
Eastern
Western
Test Range
Jcsat
Japanese Satellite Communications
Defence Ministry
Defense Ministry
Skynet
Fixed Service Structure
Launch Processing System
Asiasat
Launch Control Center
Earth
CNES
Glavkosmos
Pacific
Atlantic