Debian Codegraph @

contrib/aspell

raw
1 From: [email protected] (Wayne Davison)
2 Date: Thu, 19 Apr 90 13:47:07 PST
3 To: [email protected]
4 Subject: Our spelling checker installation
5
6 * An advanced front-end to ispell written in perl!
7 * Your shell/kernel must handle the #! control.
8 * Also look over the script if your ispell and perl is not in
9 * /usr/local/bin.
10 *
11 * To use this code, you will need to put it somewhere suitable and
12 * set the variable 'spell-checker' to the full path of this program,
13 * e.g.
14 * set spell-checker /usr/local/bin/aspell
15 *
16 * ++Kim
17
18
19 I also created a perl script to disect the article before sending it to the
20 spelling checker -- it separates the header and the signature from the body,
21 PLUS it includes the Subject, Keywords, and Summmary lines in the article to
22 be checked. After the checking is complete, it removes the .bak file, and
23 reconstructs the article using the various pieces.
24
25 The source for aspell follow.
26
27 \ /| / /|\/ /| /(_) <--flip monitor over for neato effect!
28 (_)/ |/ /\|/ / |/ \
29 (W A Y N e)
30
31 ----8<------8<------8<------8<-----cut here----->8------>8------>8------>8----
32 #! /usr/local/bin/perl
33 if ($#ARGV != $[) {
34 print "Usage: aspell filename\n";
35 exit 1;
36 }
37 $FILE = shift; # get filename of file to check
38 $BODY = "/tmp/aspell$$";
39 open(FILE,$FILE); # open file for input
40 open(BODY,">$BODY"); # open output file that we'll check
41 while (<FILE>) { # read a line
42 last unless /^([ \t]|[^ \t]*:)(.*)/; # quit at end of header
43 $header[$#header+1] = $_; # save header in array
44 sw1: { # write certain headers to output file
45 /^Subject:(.*)/ && do {print BODY; last sw1;};
46 /^Keywords:(.*)/ && do {print BODY; last sw1;};
47 /^Summary:(.*)/ && do {print BODY; last sw1;};
48 }
49 }
50 print BODY; # write blank line to output file
51 while (<FILE>) { # keep reading if not @ EOF
52 last if /^-- $/; # quit if we find the signature
53 print BODY; # write line to output file
54 }
55 do {
56 $sig[$#sig+1] = $_; # save signature in array (if there)
57 } while (<FILE>); # until EOF
58 close(BODY);
59 close(FILE);
60
61 system "/usr/local/bin/ispell", "$BODY"; # run ispell
62 unlink "${BODY}.bak"; # rm .bak file
63
64 open(FILE,">$FILE"); # open original file for output
65 open(BODY,$BODY); # open body of article for input
66 for ($i = 0; $i <= $#header; $i++) {
67 $_ = $header[$i]; # grab a header line
68 sw2: { # substitute spelling-checked versions
69 /^Subject:(.*)/ && ($_ = <BODY>, last sw2);
70 /^Keywords:(.*)/ && ($_ = <BODY>, last sw2);
71 /^Summary:(.*)/ && ($_ = <BODY>, last sw2);
72 }
73 print FILE; # re-write header
74 }
75 while(<BODY>) {
76 print FILE; # re-write body
77 }
78 for ($i = 0; $i <= $#sig; $i++) {
79 print FILE $sig[$i]; # re-write signature (if present)
80 }
81 unlink "$BODY"; # clean up