[comp.sources.misc] v08i065: cz text to PostScript system, part 01 of 14

allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc) (10/01/89)

Posting-number: Volume 8, Issue 65
Submitted-by: howard@dahlbeck.ericsson.se (Howard Gayle)
Archive-name: cz/part01

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then feed it
# into a shell via "sh file" or similar.  To overwrite existing files,
# type "sh file -c".
# The tool that generated this appeared in the comp.sources.unix newsgroup;
# send mail to comp-sources-unix@uunet.uu.net if you want that tool.
# If this archive is complete, you will see the following message at the end:
#		"End of archive 1 (of 14)."
# Contents:  README 78.1 78.h 78code.h 78code2c.c 78common.h 78diff.c
#   78freq2tt.c 78meanFreq.c 8859-1.p4 FREEZE
# Wrapped by howard@dahlbeck on Mon Sep 25 07:15:10 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(8620 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
X$Header: README,v 1.1 89/09/23 16:59:26 howard Exp $
X
X      DESCRIPTION
X
XThe cz system converts text files in any "context-free
Xoctet-based" character set into PostScript.  By octet-based, I
Xmean that each character in the character set is represented by
Xa sequence of one or more 8-bit bytes.  By "context-free" I mean
Xthat only the octets of a character determine what the character
Xis, not any other octets in the file.  This excludes character
Xsets that use locking shift sequences, for example (complete)
XISO 2022.
X
XCurrently, cz can handle the ISO 8859/1 character set, also
Xknown as Latin-1.  This is a superset of ASCII, with characters
Xfor all major Western European languages.  cz can also handle
Xseveral national versions of ISO 646, including ASCII and
X"SWASCII," the Swedish national versions.  SWASCII is the
Xcharacter set that uses vertical bar (|) for o with umlaut,
Xetc.  cz can also handle most of CCITT T.61, the teletext
Xcharacter set also used for X.400 mail.  T.61 is (almost) a
Xsubset of ISO 6937/2.
X
Xcz is completely table-driven, and it is easy to get cz to emit
Xthe PostScript for other character sets.  The hard part is
Xfiguring out what PostScript cz should emit.
X
XAn optional heuristic attempts to guess when certain ISO 646 bit
Xcodes represent ASCII (e.g. right curly brace) and when they
Xrepresent SWASCII (e.g. a with ring.)  The measured error rate
Xof this heuristic is less than 3% on real swnet (Swedish news
Xgroup hierarchy) news articles.  There is also a heuristic for
XDanish, and tools and documentation for writing heuristics for
Xother languages.  These heuristics can be used for other
Xpurposes than printing text files, e.g. in mail and news
Xreaders.
X
Xcz is very flexible.  It can use any font available on the
Xoutput device.  You have complete control over font sizes, paper
Xsize, page layout, number of columns, line numbers, portrait or
Xlandscape mode, page reversal, leading (line spacing), tab
Xexpansion, and x- or y-axis adjustments to handle misaligned
Xprinters.  cz handles the same typographic units as TeX, e.g.
Xmillimeters, inches, points, etc.
X
XFor GNU Emacs users, there are functions cz-buffer and cz-region
Xanalogous to lpr-buffer and lpr-region.  These print ISO 8859/1
Xby default, but the character set can be changed by changing the
Xelisp variable cz-CommandFile.  The elisp variables
Xcz-FixedWidth and cz-AutoLandscape can be set to control the
Xbody font and format, and the variable cz-output can be modified
Xto output to a different printer.
X
XIf you read mail with the RMAIL mode of GNU Emacs, you can print
Xa copy of any message with the function rmail-cz.  This is by
Xdefault bound to the "L" (Laser) key.
X
XIf you read mail with Sun's mailtool, you can set the printmail
Xvariable in your .mailrc file to the command cz-news.  This will
Xprint the current message when you click the print button.
X
XIf you read news with the Gnews mode of GNU Emacs, you can print
Xa copy of any article with the function Gnews-cz.  This is by
Xdefault bound to the "L" (Laser) key.
X
XIf you read news with rn or rrn, you can define macros in your
X.rnmac file to call the command cz-news.
X
XThe cz system has three mechanisms for handling long lines.
XAutoColumn can be used to reduce the number of page columns if a
Xline exceeds a certain length.  For example, you can specify
Xtwo-column mode by default, but switch automatically to
Xsingle-column mode in case a long line is encountered.
X
XAutoLandscape can be used to switch automatically from portrait
Xmode to landscape mode if a long line is encountered.
X
XBoth AutoColumn and AutoLandscape can operate on either a
Xpage-by-page or a whole file basis.  For example, AutoLandscape
Xin the page-by-page mode prints pages containing long lines in
Xlandscape mode, and other pages in portrait mode.
X
XLong lines can also be folded, i.e. broken across several output
Xlines.  The line breaks are marked by a special symbol, and the
Xcontinuation lines are indented.
X
XPaper margins can be specified separately for landscape and
Xportrait mode.  For example, it is easy to have a 10 mm top
Xmargin in portrait mode and a 20 mm top margin in landscape
Xmode.
X
XAn option places a control-D at the end of the PostScript
Xoutput, for printers that need one.
X
XLandscape rotation can be either positive or negative, i.e.
Xwith paper with holes, you can have the holes at the top or the
Xbottom of the page.
X
XThe line number of the last line in a file is always printed, if
Xline number printing is enabled.  This makes it easy to see how
Xmany lines are in a file.  Turning off line number printing does
Xnot change the left margin.
X
X
X      PREREQUISITES
X
XYou must have my library of C functions and shell scripts.  This
Xis distributed separately.  All of its prerequisites are also
Xneeded for cz.
X
XThe test text files have octets with the high-order bit set.
XThey are encoded with Brad Templeton's abe system, which was
Xposted to comp.sources.misc on 4 June 1989 as volume 7, issues 1
Xand 2, archive name abe.  If you want to test cz on these files,
Xyou must have the dabe command.
X
X
X      INSTALLATION
X
XIt will be much easier to understand the installation if you
Xfirst read my report "Sharing software in a network of
Xheterogeneous UNIX hosts."  This comes with my C library.
X
XFigure out where you want to install various files.  Here I'll
Xassume a separate directory for everything, but it's easy to
Xmake a different choice.  I discuss an alternative example
Xbelow.
X
XIn the master source directory, which I'll call $DD, extract the
Xtest texts:
X   % cd $DD
X   % dabe test.abe
X
XCreate a directory for compiling on this machine type.  I'll
Xcall it /usr/local/free/cz.
X
XFind out the version.  Look at the Header line (typically the
Xfirst line) of the FREEZE file.  The version is the first
Xnumber, and ends at the period.  The first externally released
Xversion was version 2.
X
XCreate a subdirectory for this version. e.g.
X/usr/local/free/cz/2.
X
XCreate the following subdirectories for results:
X   bin       Installed executables.
X   el        Byte-compiled elisp.
X   lib       Command files, PostScript, trigram tables, etc.
X   man/man1  Manual entries.
X   man/cat1  On-line formatted manual entries,
X   test      Test text & PostScript.
X
XFor example:
X   % cd /usr/local/free/cz/2
X   % mkdir bin el lib man man/{cat,man}1 test
X   
XCreate a subdirectory for doing the actual compilations.  I'll
Xcall it sun34:
X   % mkdir sun34
X   % cd sun34
X
XCreate an mk shell file.  Make it executable.  Here's a starting
Xpoint for SunOS 4.x:
X  
XDD=/usr/local/free-dist/cz/2/dist
XSRCS=`cd $DD; echo *`
XRM='rm -f'
Xexport DD SRCS RM
Xmake -f uMakefile
Xexec make \
X   CATMAN=catman \
X   FMTLATEX=mkLaTeXPS \
X   FMTMAN=mkManPS \
X   $*
X
XIf you don't have a catman command, drop that line.  FMTLATEX
Xshould be the name of a command to turn LaTeX source into
Xwhatever your printer prints; if you don't have one just drop
Xit.  Likewise, FMTMAN should be the name of a command to turn
Xmanual entries into printable form.  Add any local changes you
Xneed here.  If your C compiler doesn't understand different
Xoptimization levels, add CFLAGS=-O as an argument to the last
Xmake.  If lpr is not the command to print files on your system,
Xadd BDEFS='l=PRINT' where PRINT is what it takes to print a file
Xon a PostScript printer on your system.
X
XHere is an alternate mk file for a system using GCC, and with
Xresults installed in more conventional places.  The print
Xcommand on this system is lp.
X  
XDD=/usr/local/free-dist/cz/2/dist
XSRCS=`cd $DD; echo *`
XCC=gcc
XCFLAGS='-g -O -traditional'
XINCLUDES=-I/usr/local/include
XRM='rm -f'
Xexport DD SRCS CC CFLAGS INCLUDES RM
Xmake -f uMakefile
Xexec make \
X   BDEFS='l=lp' \
X   BID=/usr/local/bin \
X   CATMAN=catman \
X   CID=/usr/local/bin \
X   CODEID=/usr/local/lib \
X   ELID=/usr/local/lisp \
X   LIBPATH='-L/usr/local/lib' \
X   MID=/usr/local/man \
X   PSID=/usr/local/lib \
X   RCID=/usr/local/lib \
X   TID=/usr/local/lib \
X   TPSID=/usr/local/lib \
X   TTID=/usr/local/lib \
X   $*
X
XGet MakeCommon and uMakefile from the master source directory,
Xe.g.
X   % mkDistI MakeCommon $DD
X   % mkDistI uMakefile  $DD
X
XRun mk.
X
XRun "mk install" and you're finished.
X
X
X      NOTES
X
XBefore distributing us.fr, the frequency table for US English, I
Xremoved all but the most frequent 64 kbytes.  This does not
Xaffect the dkus.tt and seus.tt trigram difference tables,
Xbecause the frequency tables for Danish and Swedish are even
Xsmaller.  The full us.fr is 375 kbytes.  If you need it, contact
Xme.
X--
XHoward Gayle
XTN/ETX/T/BG
XEricsson Telecom AB
XS-126 25 Stockholm
XSweden
Xhoward@ericsson.se
Xuunet!ericsson.se!howard
XPhone: +46 8 719 5565
XFAX  : +46 8 719 9598
X
X
END_OF_FILE
if test 8620 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f '78.1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'78.1'\"
else
echo shar: Extracting \"'78.1'\" \(6372 characters\)
sed "s/^X//" >'78.1' <<'END_OF_FILE'
X.\" $Header: 78.1,v 1.12 89/09/05 08:49:31 howard Exp $
X.TH 78 1 "$Revision: 1.12 $"
X.SH NAME
X78dkus, 78seus, 78diff, 78meanFreq, 78triFreq, 78freq2tt \- convert text from ISO 646 to 8-bit character sets
X.SH SYNOPSIS
X.B 78dkus
X.RB [ " \-f " ] 
X.RB [ " \-m " ] 
X.LP
X.B 78seus
X.RB [ " \-f " ] 
X.RB [ " \-m " ] 
X.LP
X.B 78diff
X.I encodings
X.I trigram-difference-table
X<
X.I words
X.LP
X.B 78meanFreq
X.I encodings
X.I frequency-table
X<
X.I words
X.LP
X.B 78triFreq
X.I encodings
X<
X.I filenames
X>
X.I frequency-table
X.LP
X.B 78freq2tt
X.B \-d
X.I encodings
X.I frequency-table1
X.I frequency-table2
X.I trigram-difference-table
X.br
X.B 78freq2tt
X.B \-p
X.I encodings
X.I frequency-table
X.I trigram-table \|.\|.\|.
X.SH COPYRIGHT
XCopyright \(co 1989 Howard Lee Gayle
X.SH DESCRIPTION
X.I 78seus
Xis a filter.
XIts input is assumed to be a mixture of US English written in
XASCII and Swedish written in a Swedish
Xnational version of ISO 646.
XThis is converted to ISO 8859/1 using a trigram-based
Xheuristic.
XBy default, the input is assumed to be a mail message or news
Xarticle, consisting of header, body, and signature.
XThe
X.B \-f
Xoption causes the input to be treated as an ordinary text file.
XThe
X.B \-m
Xoption causes the input to be treated as a
X.IR mail (1)
Xformat file, where each new message begins with a line starting
Xwith `From '.
XThere are many more options for tuning:
X"use the source."
X.PP
X.I 78dkus
Xis like
X.IR 78seus ,
Xbut for Danish.
X.PP
X.I 78diff
Xis a filter.
XIt reads a list of words, one per line, and writes each word
Xpreceded by its trigram score, where positive indicates
Xthe first language and negative the second language in the
Xgiven
X.IR trigram-difference-table .
XThis can be used to find words that need special case
Xtreatment,
X.I e.g.
XC reserved words that have high scores and thus appear Swedish.
X.PP
X.I 78meanFreq
Xreads a list of words, one per line, and writes each word
Xpreceded by the arithmetic mean of the frequencies of the
Xtrigrams in the word.
X.PP
X.I 78triFreq
Xreads from standard input a list of file names, one per line.
XIt computes a trigram frequency table and writes it on standard
Xoutput.
XThe frequencies are multiplied by 2147483647 to scale them into
X31-bit integers.
X.PP
X.I 78freq2tt
Xtakes as input trigram frequency tables as produced by
X.I 78triFreq
Xand generates trigram tables.
XWith the
X.B \-d
Xoption it generates one difference trigram table from two
Xfrequency tables.
XWith the
X.B \-p
Xoption it generates two or more trigram tables from the
Xcorresponding frequency tables.
XThe arguments are interpreted as
X(frequency table, trigram table) pairs.
X.SH ENVIRONMENT
XThe
X.B CZ_PATH
Xenvironment variable is used to find trigram tables.
X.SH ENCODINGS
XAn encoding file contains one line for each trigram letter code.
XThe first item on each line is the code number, in the range
X[0, 29].
XThe second item is a letter that maps to the code.
XThis letter is also used when displaying trigrams, and is typically
Xlower case.
XAdditional, optional letters that also map to the code may follow the 
Xsecond item.
XLetters may be written either as a single character in single
Xquotes or as an Ada-syntax integer numeric literal.
XHowever, the first letter
X.I must
Xbe in single quotes.
X.SH EXAMPLE
XTo look for Swedish-like words in /usr/dict/words:
X.nf
X   78diff ./lib/seus.code seus < /usr/dict/words | sort \-nr
X.fi
XThe most Swedish-like words will have the highest scores.
X.SH FILES
X(All paths starting with ./ are relative to the directory in which
X.I cz
Xis installed.)
X.DT
X.nf
X\&./lib/dk.fr \- Danish trigram frequency table
X\&./lib/se.fr \- Swedish trigram frequency table
X\&./lib/us.fr \- US English trigram frequency table
X\&./lib/dkus.code \- encoding file for Danish or US English
X\&./lib/dkus.tt \- trigram difference table for Danish or US English
X\&./lib/seus.code \- encoding file for Swedish or US English
X\&./lib/seus.tt \- trigram difference table for Swedish or US English
X.fi
X.SH "SEE ALSO"
X.IR bytefreq (1),
X.IR cz (1),
X.IR letterfreq (1).
X.SH BUGS
XThe charater set conversion commands are heuristics.
X.I 78seus
XIt has a measured error rate below 3% on real news articles,
Xbut it does sometimes guess wrong.
X.PP
XThe
X.B \-p
Xoption to
X.I 78freq2tt
Xis not implemented.
X.SH "HINTS FOR WRITING IN ISO 646"
XAs much as possible,
Xuse braces, brackets, vertical bars,
X.I etc.
Xonly for representing letters in a national version.
XDon't use them for ASCII graphics,
XUUCP paths,
Xor
Xquoting text to which you are writing a followup.
X
XFollow the convention that a line with exactly two hyphens and
Xnothing else starts the signature.
X
XWhen changing from one language to another, put a blank line
Xbetween the two languages whenever possible.
X
XDon't put spaces between the letters in a word
Xl\ i\ k\ e\ \ t\ h\ i\ s.
X.SH ETYMOLOGY
XThe
X.I 78
Xprefix indicates conversion from the 7-bit ISO 646 character
Xsets to 8-bit character sets like ISO 8859/1.
X.PP
XI realize that there is not a 1-1 correspondence between
Xlanguages and countries.
XHowever, there are short, widely-used abbreviations for
Xcountries, but not for languages.
XThe general rule is that a country abbreviation implies the
Xmost widely used language in that country,
X.I e.g.
Xuk means British English and us means US English.
XIf this is not enough, a country suffix can be added, meaning
X"as spoken in."
XFor example, if it for some reason became necessary to
Xdistinguish French as spoken in France from French as spoken in
XCanada, then fr would be used for French French and frca for
XCanadian French.
XRemember that the point of the exercise is to determine character
Xsets, not languages
X.I per se.
X.SH LICENSE
XThis program is free software; you can redistribute it and/or modify
Xit under the terms of the GNU General Public License version 1,
Xas published by the Free Software Foundation.
X.PP
XThis program is distributed in the hope that it will be useful,
Xbut WITHOUT ANY WARRANTY; without even the implied warranty of
XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
XGNU General Public License for more details.
X.PP
XYou should have received a copy of the GNU General Public License
Xalong with this program; if not, write to the Free Software
XFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X.SH AUTHOR
XHoward Gayle,
XTN/ETX/T/BG,
XEricsson Telecom AB,
XS-126 25 Stockholm,
XSweden,
Xhoward@ericsson.se,
Xuunet!ericsson.se!howard,
XPhone: +46 8 719 5565,
XFAX: +46 8 719 9598,
XTelex: 14910 ERIC S
END_OF_FILE
if test 6372 -ne `wc -c <'78.1'`; then
    echo shar: \"'78.1'\" unpacked with wrong size!
fi
# end of '78.1'
fi
if test -f '78.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'78.h'\"
else
echo shar: Extracting \"'78.h'\" \(2398 characters\)
sed "s/^X//" >'78.h' <<'END_OF_FILE'
X/*
X * 78.h - common definitions for ISO 646 to 8-bit conversion
X *
X * Copyright 1989 Howard Lee Gayle
X *
X * $Header: 78.h,v 1.6 89/08/24 13:03:34 howard Exp $
X *
X * This program is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License version 1,
X * as published by the Free Software Foundation.
X *
X * This program is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with this program; if not, write to the Free Software
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X *
X * Prerequisites:
X *    howard/port.h
X *
X * Each letter of a trigram is encoded into 5 bits, so there are
X * 32 bit combinations.  Two are reserved for the "character" just
X * before the first character in a word (TRIBEG), and the "character"
X * just after the last character in a word (TRIEND).  This leaves 30
X * combinations (TRILO..TRIHI) for real letters.  Fortunately, most
X * languages written with ISO 646 have about 30 letters.  If it is
X * necessary to free up a little space, the least frequent letters
X * can be lumped together.  For example, in English 'q' and 'z' can
X * both map into one code.
X */
X
X#define MLINE   1024     /* Max input line length.*/
X#define NULONGP ((long *) NULL)
X#define TRILO    0       /* First value for letters.*/
X#define TRIHI   29       /* Last value for letters.*/
X#define TRIBEG  30       /* Beginning of word.*/
X#define TRIEND  31       /* End of word.*/
X#define TRINONE 32       /* No code for this byte.*/
X#define TTSUF   S(".tt") /* Trigram table suffix.*/
X
X/* With each letter encoded as 5 bits, a whole trigram can be
X * encoded in 15 bits.  This makes it feasible to index a
X * trigram frequency table directly.  This macro
X/* converts (beginning, middle, end) to trigram.
X * The ordering saves space by putting the middle value in the most
X * significant bits since its max value is 29.*/
X#define TOTRI(a,b,c) (((b) << 10) | ((a) << 5) | (c))
X
X#define TRIMAX TOTRI(TRIBEG, TRIHI, TRIEND) /* Max trigram value.*/
X
X#ifdef NOSCHAR
Xtypedef byteT triDifT;
X#define TRIBIAS 127
X#else  NOSCHAR
Xtypedef signed char triDifT;
X#define TRIBIAS 0
X#endif NOSCHAR
END_OF_FILE
if test 2398 -ne `wc -c <'78.h'`; then
    echo shar: \"'78.h'\" unpacked with wrong size!
fi
# end of '78.h'
fi
if test -f '78code.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'78code.h'\"
else
echo shar: Extracting \"'78code.h'\" \(2817 characters\)
sed "s/^X//" >'78code.h' <<'END_OF_FILE'
X/*
X * 78code.h - definitions for trigram encodings
X *
X * Copyright 1989 Howard Lee Gayle
X *
X * $Header: 78code.h,v 1.2 89/08/25 11:16:02 howard Exp $
X *
X * This program is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License version 1,
X * as published by the Free Software Foundation.
X *
X * This program is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with this program; if not, write to the Free Software
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X *
X * Prerequisites: howard/port.h howard/a2.h 78.h
X */
X
XPRIVATE byteT byte2t[256];     /* Map each byte to a trigram code.*/
XPRIVATE byteT t2byte[TRINONE]; /* Map trigram code to printable character.*/
X
X/* rdcode - read in a trigram encoding file and initialize byte2t and t2byte */
X
XPRIVATE void rdcode (fn)
XR4 bStrT fn; /* Name of trigram encoding file.*/
X
X/* Function:
X *    Initialize byte2t[] and t2byte[] by reading the given encoding file.
X * Algorithm:
X *    Initialize each element of byte2t[] to TRINONE.
X *    Read each line in the encoding file.
X *    Store the primary representation in t2byte[] and byte2t[].
X *    Store any secondary representations in byte2t[].
X * Returns:
X *    
X * Notes:
X *    
X */
X{
XR2 int      i;         /* Trigram code for current letter.*/
XR3 streamT  is;        /* Input stream.*/
X   unsigned ln = 0;    /* Line number.*/
XR1 bStrT    p;         /* Steps through lb[].*/
X   bStrT    p0;        /* mra2i() stores end of number here.*/
X   byteT    lb[MLINE]; /* Line buffer.*/
X
Xis = mfopen (fn, "r");
Xfor (p = byte2t; p != &byte2t[256];)
X   *p++ = TRINONE;
Xt2byte[TRIBEG] = '(';
Xt2byte[TRIEND] = ')';
Xwhile (NULBSTR != getlic (lb, MLINE, is, fn, &ln, 1, COMMENT))
X   {
X   i = mra2i (lb, NULBSTR, TRUE, S("Trigram code"), TRILO, TRIHI, &p0);
X   if (EOS != t2byte[i]) malf1 ("%s %u: code %d already used", fn, ln, i);
X   for (p = p0; ' ' == B(*p); ++p)
X      ;
X   if (('\'' != B(*p)) || (EOS == B(p[1])) || ('\'' != B(p[2])))
X      malf1 ("%s %u: bad letter: %s", fn, ln, p);
X   ++p;
X   t2byte[i] = B(*p);
X   byte2t[B(*p)] = i;
X   for (p += 2; EOS != B(*p);)
X      {
X      for (; ' ' == B(*p); ++p)
X         ;
X      if (EOS != B(*p))
X         {
X         if (('\'' == B(*p)) && (EOS != B(p[1])) && ('\'' == B(p[2])))
X            {
X            ++p;
X            byte2t[B(*p)] = i;
X            p += 2;
X            }
X         else
X            {
X            byte2t[mra2i (p, NULBSTR, TRUE, S("Byte"), 0, 255, &p0)] = i;
X            p = p0;
X            }
X         }
X      }
X   }
Xmfclose (is, fn);
X}
END_OF_FILE
if test 2817 -ne `wc -c <'78code.h'`; then
    echo shar: \"'78code.h'\" unpacked with wrong size!
fi
# end of '78code.h'
fi
if test -f '78code2c.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'78code2c.c'\"
else
echo shar: Extracting \"'78code2c.c'\" \(1987 characters\)
sed "s/^X//" >'78code2c.c' <<'END_OF_FILE'
X/*
X * 78code2c - Convert encodings file to C code
X */
X
X#ifndef lint
Xstatic char _cpyrgt[] = "Copyright 1989 Howard Lee Gayle";
X#endif lint
X
X/*
X * This program is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License version 1,
X * as published by the Free Software Foundation.
X *
X * This program is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with this program; if not, write to the Free Software
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X */
X
X#include <stdio.h>
X#include <howard/port.h>
X#include <howard/version.h>
X#include <howard/usage.h>
X
XMAINVER ("@(#)$Header: 78code2c.c,v 1.2 89/08/26 13:25:59 howard Exp $");
XUSAGE ("encodings > c-code");
X
X#include <string.h>
X#include <howard/malf.h>
X#include <howard/registers.i>
X#include "cz.h"
X#include "78.h"
X#include "78code.h"
X
X/* main - main function							*/
X
XPUBLIC int main (argc, argv)
Xint    argc; /* Number of arguments.*/
XbStrT *argv; /* Points to array of argument strings.*/
X
X/* Function:
X *    
X * Algorithm:
X *    
X * Notes:
X *    
X */
X
X{
XR1 bStrT p1; /* Steps through byte2t[] and t2byte[].*/
XR2 bStrT p2; /* End of byte2t[] or t2byte[].*/
X
Xif (2 != argc) usage();
Xrdcode (argv[1]);
XPUTS ("PRIVATE byteT byte2t[256] = /* Map each byte to a trigram code.*/");
XPUTS ("{");
Xp1 = byte2t;
Xfor (p2 = p1 + 256; p1 != p2; ++p1)
X   PRINTF ("%d,\n", B(*p1));
XPUTS ("};\n");
XPUTS (
X"PRIVATE byteT t2byte[TRINONE] = /* Map trigram code to printable character.*/"
X     );
XPUTS ("{");
Xp1 = t2byte;
Xfor (p2 = p1 + TRINONE; p1 != p2; ++p1)
X   PRINTF ("'%c',\n", (EOS == B(*p1)) ? '?' : B(*p1));
XPUTS ("};");
Xmfflush (stdout, S("Standard Output"));
Xexit (SUCCESS);
X
X#ifdef lint
Xreturn (SUCCESS);
X#endif
X}
END_OF_FILE
if test 1987 -ne `wc -c <'78code2c.c'`; then
    echo shar: \"'78code2c.c'\" unpacked with wrong size!
fi
# end of '78code2c.c'
fi
if test -f '78common.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'78common.h'\"
else
echo shar: Extracting \"'78common.h'\" \(6285 characters\)
sed "s/^X//" >'78common.h' <<'END_OF_FILE'
X/*
X * 78common.h - common functions for ISO 646 to 8-bit conversion
X *
X * Copyright 1989 Howard Lee Gayle
X *
X * $Header: 78common.h,v 1.2 89/08/24 13:03:41 howard Exp $
X *
X * This program is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License version 1,
X * as published by the Free Software Foundation.
X *
X * This program is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with this program; if not, write to the Free Software
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X *
X * Prerequisites:
X *    limits.h
X *    howard/port.h
X *    howard/a2.h
X *    howard/malf.h
X *    howard/registers.i
X *    cz.h
X *    78.h
X *    78????.h (defines byte2t[])
X */
X
X/* dif78 - compute trigram frequency difference for one word */
X
XPUBLIC int dif78 (wp, lim, tt)
XR1 bStrT    wp;  /* The word.*/
XR3 bStrT    lim; /* Don't pass this.*/
XR4 triDifT *tt;  /* Difference table.*/
X
X/* Function:
X *    Sum the frequency differences of all the trigrams in a word.
X * Algorithm:
X *    Special-case single-letter words.  Otherwise, loop through
X *    the word.
X * Returns:
X *    Sum of the values in the difference table for each trigram in the word.
X * Notes:
X *    
X */
X{
XR2 int r; /* Return.*/
X
Xif (NULBSTR == wp)            malf1 ("dif78: word NUL");
Xif (EOS == B(*wp))            malf1 ("dif78: word empty");
Xif (((triDifT *) NULL) == tt) malf1 ("dif78: no difference table");
Xif ((EOS == B(wp[1])) || (lim == (wp + 1)))
X    return (tt[TOTRI (TRIBEG, byte2t[B(*wp)], TRIEND)] - TRIBIAS);
Xr = tt[TOTRI (TRIBEG, byte2t[B(*wp)], byte2t[B(wp[1])])] - TRIBIAS;
Xfor (; (EOS != B(wp[2])) && (lim != (wp + 2)); ++wp)
X   r += tt[TOTRI (byte2t[B(*wp)], byte2t[B(wp[1])], byte2t[B(wp[2])])]-TRIBIAS;
Xr += tt[TOTRI (byte2t[B(*wp)], byte2t[B(wp[1])], TRIEND)] - TRIBIAS;
Xreturn (r);
X}
X
X/* frqmm - find minimum and maximum values in a trigram frequency table */
X
XPRIVATE void frqmm (fp, minp, pminp, maxp)
XR1 long *fp;    /* Points to frequency table.*/
XR7 long *minp;  /* Store min here.*/
XR8 long *pminp; /* Store positive min here.*/
XR9 long *maxp;  /* Store max here.*/
X
X/* Function:
X *    Find the minimum and maximum frequencies in the given table.
X * Algorithm:
X *    Linear search.
X * Returns:
X *    
X * Notes:
X *    
X */
X{
XR2 long  f;   /* Current frequency.*/
XR6 long *fp2; /* End of fp[].*/
XR3 long  l;   /* Min.*/
XR4 long  h;   /* Max.*/
XR5 long  p;   /* Positive min.*/
X
Xif (NULONGP == fp) malf1 ("frqmm: no frequency table");
Xl = LONG_MAX;
Xh = LONG_MIN;
Xp = LONG_MAX;
Xfor (fp2 = fp + (TRIMAX + 1); fp != fp2;)
X   {
X   f = *fp++;
X   if (f < l) l = f;
X   if (f > h) h = f;
X   if ((f > 0) && (f < p)) p = f;
X   }
Xif (NULONGP != minp)  *minp = l;
Xif (NULONGP != pminp) *pminp = p;
Xif (NULONGP != maxp)  *maxp = h;
X}
X
X/* mrdfrq - read in a trigram frequency file */
X
XPRIVATE void mrdfrq (fn, fp)
XR2 bStrT fn; /* File name.*/
XR3 long *fp; /* Points to frequency table.*/
X
X/* Function:
X *    Read a file representation of a trigram frequency table into
X *    its internal representation.
X * Algorithm:
X *    Read each line in the file.  Convert the frequency to a long.
X *    Index into fp[] and store the value.
X * Returns:
X *    
X * Notes:
X *    1) There is no checking for duplicate trigrams.
X *    2) fp[] is assumed to be zero on entry.
X */
X{
XR4 int      a;         /* Trigram code for first letter.*/
XR5 int      b;         /* Trigram code for second letter.*/
XR6 int      c;         /* Trigram code for third letter.*/
XR7 long     f;         /* Frequency.*/
XR8 streamT  is;        /* Input stream.*/
X   unsigned ln = 0;    /* Input line number.*/
XR1 bStrT    p;         /* Steps through lb[].*/
X   bStrT    p0;        /* End of frequency.*/
X   byteT    lb[MLINE]; /* Line buffer.*/
X
Xif (NULONGP == fp) malf1 ("mrdfrq: no frequency table");
Xis = mfopen (fn, "r");
Xwhile (NULBSTR != getlic (lb, MLINE, is, fn, &ln, 1, COMMENT))
X   {
X   f = mra2l (lb, NULBSTR, TRUE, S("Frequency"), 0L, (long) LONG_MAX, &p0);
X   for (p = p0; ' ' == B(*p); ++p)
X      ;
X   if ((EOS == B(*p)) || (EOS == B(p[1])) || (EOS == B(p[2])))
X      malf1 ("%s %u: bad trigram", fn, ln);
X   a = (('(' == B(*p)) ? TRIBEG : byte2t[B(*p)]);
X   b = byte2t[B(p[1])];
X   c = ((')' == B(p[2])) ? TRIEND : byte2t[B(p[2])]);
X   fp[TOTRI (a, b, c)] = f;
X   }
Xmfclose (is, fn);
X}
X
X/* mrdtri - read trigram table and handle errors */
X
XPUBLIC void mrdtri (sim, tt)
XbStrT sim; /* Simple part of file name.*/
XbStrT tt;  /* Store trigram table here.*/
X
X/* Function:
X *    Read in a trigram table.
X * Algorithm:
X *    Call mopenp() to search path and open the file.
X *    Call fread() to do the read.  Close the file
X * Returns:
X *    
X * Notes:
X *    
X */
X{
XR1 streamT is;         /* Input stream.*/
X   byteT   fnb[MFILE]; /* Store full paths here.*/
X
Xis = mopenp (path, PATHSEP, sim, TTSUF, S("r"), fnb, MFILE);
Xif ((1 != fread ((cStrT) tt, TRIMAX + 1, 1, is)) || ferror (is))
X   malf1 ("%s: Read error", fnb);
Xmfclose (is, fnb);
X}
X
X/* word78 - compute trigram index for one word */
X
XPUBLIC unsigned word78 (wp, lim, b2t, tt)
XR1 bStrT wp;  /* The word.*/
XR4 bStrT lim; /* Don't pass this.*/
XR2 bStrT b2t; /* Byte to trigraph code map.*/
XR5 bStrT tt;  /* Trigram table.*/
X
X/* Function:
X *    Sum the frequencies of all the trigrams in a word.
X * Algorithm:
X *    Special-case single-letter words.  Otherwise, loop through
X *    the word.
X * Returns:
X *    Sum of the values in the trigram table for each trigram in the word.
X * Notes:
X *    
X */
X{
XR3 unsigned r; /* Return.*/
X
Xif (NULBSTR == wp)  malf1 ("word78: word NUL");
Xif (EOS == B(*wp))  malf1 ("word78: word empty");
Xif (NULBSTR == b2t) malf1 ("word78: no code map");
Xif (NULBSTR == tt)  malf1 ("word78: no trigram table");
Xif ((EOS == B(wp[1])) || (lim == (wp + 1)))
X    return (tt[TOTRI (TRIBEG, b2t[B(*wp)], TRIEND)]);
Xr = tt[TOTRI (TRIBEG, b2t[B(*wp)], b2t[B(wp[1])])];
Xfor (; (EOS != B(wp[2])) && (lim != (wp + 2)); ++wp)
X   r += tt[TOTRI (b2t[B(*wp)], b2t[B(wp[1])], b2t[B(wp[2])])];
Xr += tt[TOTRI (b2t[B(*wp)], b2t[B(wp[1])], TRIEND)];
Xreturn (r);
X}
END_OF_FILE
if test 6285 -ne `wc -c <'78common.h'`; then
    echo shar: \"'78common.h'\" unpacked with wrong size!
fi
# end of '78common.h'
fi
if test -f '78diff.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'78diff.c'\"
else
echo shar: Extracting \"'78diff.c'\" \(1904 characters\)
sed "s/^X//" >'78diff.c' <<'END_OF_FILE'
X/*
X * 78diff - compute trigram score for words
X */
X
X#ifndef lint
Xstatic char _cpyrgt[] = "Copyright 1989 Howard Lee Gayle";
X#endif lint
X
X/*
X * This program is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License version 1,
X * as published by the Free Software Foundation.
X *
X * This program is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with this program; if not, write to the Free Software
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X */
X
X#include <stdio.h>
X#include <howard/port.h>
X#include <howard/version.h>
X#include <howard/usage.h>
X
XMAINVER ("@(#)$Header: 78diff.c,v 1.7 89/08/25 11:45:50 howard Exp $");
XUSAGE ("encodings trigram-difference-table < word-list");
X
X#include <limits.h>
X#include <string.h>
X#include <howard/a2.h>
X#include <howard/malf.h>
X#include <howard/registers.i>
X#include "cz.h"
X#include "78.h"
X#include "78code.h"
X#include "78common.h"
X
XPRIVATE triDifT diftab[TRIMAX + 1]; /* Trigram difference table.*/
X
X/* main - main function							*/
X
XPUBLIC int main (argc, argv)
Xint    argc; /* Number of arguments.*/
XbStrT *argv; /* Points to array of argument strings.*/
X
X/* Function:
X *	
X * Algorithm:
X *    Read each word. Call dif78().
X * Notes:
X *	
X */
X
X{
Xunsigned ln = 0;    /* Input line number.*/
XbyteT    wb[MLINE]; /* Word buffer.*/
X
Xif (3 != argc) usage();
Xipath();
Xrdcode (argv[1]);
Xmrdtri (argv[2], diftab);
Xwhile (NULBSTR != getlin (wb, MLINE, stdin, S("Standard input"), &ln, 0))
X   PRINTF ("%11d %s\n", dif78 (wb, NULBSTR, diftab), wb);
Xmfflush (stdout, S("Standard Output"));
Xexit (SUCCESS);
X
X#ifdef lint
Xreturn (SUCCESS);
X#endif
X}
END_OF_FILE
if test 1904 -ne `wc -c <'78diff.c'`; then
    echo shar: \"'78diff.c'\" unpacked with wrong size!
fi
# end of '78diff.c'
fi
if test -f '78freq2tt.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'78freq2tt.c'\"
else
echo shar: Extracting \"'78freq2tt.c'\" \(4717 characters\)
sed "s/^X//" >'78freq2tt.c' <<'END_OF_FILE'
X/*
X * 78freq2tt - make trigram table
X */
X
X#ifndef lint
Xstatic char _cpyrgt[] = "Copyright 1989 Howard Lee Gayle";
X#endif lint
X
X/*
X * This program is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License version 1,
X * as published by the Free Software Foundation.
X *
X * This program is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with this program; if not, write to the Free Software
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X */
X
X#include <stdio.h>
X#include <howard/port.h>
X#include <howard/version.h>
X#include <howard/usage.h>
X
XMAINVER ("@(#)$Header: 78freq2tt.c,v 2.4 89/08/28 18:54:50 howard Exp $");
XUSAGE ("[-d encodings frequency1 frequency2 table] or [-p encodings {frequency table}]");
X
X#include <float.h>
X#include <limits.h>
X#include <math.h>
X#include <howard/a2.h>
X#include <howard/malf.h>
X#include <howard/registers.i>
X#include "cz.h"
X#include "78.h"
X#include "78code.h"
X#include "78common.h"
X
X#define MTABLE 3    /* Max number of frequency tables.*/
X
XPRIVATE long   freq[MTABLE][TRIMAX + 1]; /* Frequency tables.*/
XPRIVATE double lfreq[TRIMAX + 1];        /* Log freq.*/
X
XPRIVATE char eIntern[] = "Internal error %s";
X
X/* dif - make a difference table from two frequency tables */
X
XPRIVATE void dif (ffn1, ffn2, dfn)
X   bStrT ffn1; /* Name of file containing first frequency table.*/
X   bStrT ffn2; /* Name of file containing second frequency table.*/
XR9 bStrT dfn;  /* Name of file to hold output difference trigram table.*/
X
X/* Function:
X *    Write a trigram difference table.
X * Algorithm:
X *    Read in the two frequency tables.  Compute and apply the cutoff.
X *    Compute ln (f1/f2).  Scale.
X * Returns:
X *    
X * Notes:
X *    
X */
X{
XR8 long    co;   /* Cutoff frequency.*/
X   double  f1;   /* 1 + freq[0][i].*/
X   double  f2;   /* 1 + freq[1][i].*/
XR4 long   *fp1;  /* Steps through freq[0].*/
XR5 long   *fp2;  /* End of freq[0].*/
XR6 long   *fp3;  /* Steps through freq[1].*/
XR1 int     i;    /* General putpose.*/
X   double  l;    /* ln (f1/f2).*/
XR2 double *lp1;  /* Steps through lfreq[].*/
XR3 double *lp2;  /* End of lfreq[].*/
X   double  maxl; /* Max |l|.*/
X   long    min1; /* Minimum frequency in first table.*/
X   long    min2; /* Minimum frequency in second table.*/
X   double  minl; /* Min (l).*/
XR7 streamT os;   /* Output stream.*/
X   double  s;    /* Scale factor.*/
X
Xmrdfrq (ffn1, freq[0]);
Xmrdfrq (ffn2, freq[1]);
Xos = mfopen (dfn, "w");
Xfrqmm (freq[0], NULONGP, &min1, NULONGP);
Xfrqmm (freq[1], NULONGP, &min2, NULONGP);
Xif (min1 > min2)
X   {
X   fp1 = freq[1];
X   co = min1;
X   }
Xelse
X   {
X   fp1 = freq[0];
X   co = min2;
X   }
XFPRINTF (stderr, "Cutoff %ld\n", co);
Xfor (fp2 = fp1 + (TRIMAX + 1); fp1 != fp2; ++fp1)
X   if (*fp1 < co) *fp1 = 0;
Xfp1 = freq[0];
Xfp3 = freq[1];
Xlp1 = lfreq;
Xmaxl = -DBL_MAX;
Xminl = DBL_MAX;
Xfor (fp2 = fp1 + (TRIMAX + 1); fp1 != fp2;)
X   {
X   f1 = *fp1 + 1;
X   f2 = *fp3 + 1;
X   l = log (f1 / f2);
X   *lp1++ = l;
X   if (l < minl) minl = l;
X   if (l > maxl) maxl = l;
X   ++fp1;
X   ++fp3;
X   }
Xmaxl = MAX (DABS (minl), DABS (maxl));
Xs = 127.0 / maxl;
Xlp1 = lfreq;
Xfor (lp2 = lp1 + (TRIMAX + 1); lp1 != lp2; ++lp1)
X   {
X   i = (int) (*lp1 * s);
X   if (ABS (i) > 127) malf1 (eIntern, "dif 1");
X   PUTC (i + TRIBIAS, os);
X   }
Xmfflush (os, dfn);
Xmfclose (os, dfn);
X}
X/* main - main function							*/
X
XPUBLIC int main (argc, argv)
XR5 int    argc; /* Number of arguments.*/
XR1 bStrT *argv; /* Points to array of argument strings.*/
X
X/* Function:
X *	
X * Algorithm:
X *    Decode args and call appropriate function.
X * Notes:
X *    
X */
X
X{
XR2     rcharT c; /* Option letter.*/
Xextern int optind; /* See getopt (3).*/
Xextern cStrT optarg; /* See getopt (3).*/
XR3     boolT difFlg = FALSE; /* Made a difference table.*/
XR4     boolT pairFlg = FALSE; /* Made trigram tables.*/
X
Xwhile (EOF != (c = getopt (argc, (cStrT *) argv, "dp")))
X   {
X   switch (c)
X      {
X      case '?':
X         usage();
X         break;
X      case 'd':
X         difFlg = TRUE;
X         break;
X      case 'p':
X         pairFlg = TRUE;
X         break;
X      default:
X         malf1 (eIntern, "main 1");
X         break;
X      }
X   }
Xargc -= optind;
Xargv += optind;
Xif (difFlg == pairFlg) usage();
Xif (difFlg)
X   {
X   if (4 != argc) usage();
X   rdcode (argv[0]);
X   dif (argv[1], argv[2], argv[3]);
X   }
Xelse
X   {
X   malf1 ("-p option not implemented");
X   }
Xmfflush (stdout, S("Standard Output"));
Xexit (SUCCESS);
X
X#ifdef lint
Xreturn (SUCCESS);
X#endif
X}
END_OF_FILE
if test 4717 -ne `wc -c <'78freq2tt.c'`; then
    echo shar: \"'78freq2tt.c'\" unpacked with wrong size!
fi
# end of '78freq2tt.c'
fi
if test -f '78meanFreq.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'78meanFreq.c'\"
else
echo shar: Extracting \"'78meanFreq.c'\" \(2617 characters\)
sed "s/^X//" >'78meanFreq.c' <<'END_OF_FILE'
X/*
X * 78meanFreq - compute arithmetic mean of trigram frequencies for words
X */
X
X#ifndef lint
Xstatic char _cpyrgt[] = "Copyright 1989 Howard Lee Gayle";
X#endif lint
X
X/*
X * This program is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License version 1,
X * as published by the Free Software Foundation.
X *
X * This program is distributed in the hope that it will be useful,
X * but WITHOUT ANY WARRANTY; without even the implied warranty of
X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X * GNU General Public License for more details.
X *
X * You should have received a copy of the GNU General Public License
X * along with this program; if not, write to the Free Software
X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X */
X
X#include <stdio.h>
X#include <howard/port.h>
X#include <howard/version.h>
X#include <howard/usage.h>
X
XMAINVER ("@(#)$Header: 78meanFreq.c,v 1.2 89/09/05 09:17:44 howard Exp $");
XUSAGE ("encodings frequency-table < words");
X
X#include <limits.h>
X#include <howard/a2.h>
X#include <howard/malf.h>
X#include <howard/registers.i>
X#include "cz.h"
X#include "78.h"
X#include "78code.h"
X#include "78common.h"
X
XPRIVATE long freq[TRIMAX + 1]; /* Frequency table.*/
X
X/* sumfreq - compute sum of trigram frequencies for one word */
X
XPRIVATE double sumfreq (wp)
XR1 bStrT    wp;  /* The word.*/
X
X/* Function:
X *    Sum the frequencies of all the trigrams in a word.
X * Algorithm:
X *    Special-case single-letter words.  Otherwise, loop through
X *    the word.
X * Returns:
X *    Sum of the values.
X * Notes:
X *    1) There is no check for non-letters.  This is a bug.
X */
X{
Xdouble r; /* Return.*/
X
Xif (EOS == B(wp[1]))
X    return (freq[TOTRI (TRIBEG, byte2t[B(*wp)], TRIEND)]);
Xr = freq[TOTRI (TRIBEG, byte2t[B(*wp)], byte2t[B(wp[1])])];
Xfor (; EOS != B(wp[2]); ++wp)
X   r += freq[TOTRI (byte2t[B(*wp)], byte2t[B(wp[1])], byte2t[B(wp[2])])];
Xr += freq[TOTRI (byte2t[B(*wp)], byte2t[B(wp[1])], TRIEND)];
Xreturn (r);
X}
X
X/* main - main function							*/
X
XPUBLIC int main (argc, argv)
X   int    argc; /* Number of arguments.*/
XR1 bStrT *argv; /* Points to array of argument strings.*/
X
X/* Function:
X *    
X * Algorithm:
X *    
X * Notes:
X *    
X */
X
X{
Xunsigned ln = 0;    /* Input line number.*/
XbyteT    wb[MLINE]; /* Word buffer.*/
X
Xif (3 != argc) usage();
Xrdcode (argv[1]);
Xmrdfrq (argv[2], freq);
Xwhile (NULBSTR != getlic (wb, MLINE, stdin, S("Standard input"), &ln, 0, EOS))
X   PRINTF ("%11.0f %s\n", sumfreq (wb) / strlen (wb), wb);
Xmfflush (stdout, S("Standard Output"));
Xexit (SUCCESS);
X
X#ifdef lint
Xreturn (SUCCESS);
X#endif
X}
END_OF_FILE
if test 2617 -ne `wc -c <'78meanFreq.c'`; then
    echo shar: \"'78meanFreq.c'\" unpacked with wrong size!
fi
# end of '78meanFreq.c'
fi
if test -f '8859-1.p4' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'8859-1.p4'\"
else
echo shar: Extracting \"'8859-1.p4'\" \(1469 characters\)
sed "s/^X//" >'8859-1.p4' <<'END_OF_FILE'
X% 8859-1.p4 - PostScript for cz0 for ISO 8859/1.
X%
X% $Header: 8859-1.p4,v 1.1 89/08/04 16:36:32 howard Exp $
X%
X% Copyright 1989 Howard Lee Gayle
X% This file is written in the ISO 8859/1 character set.
X%
X% This program is free software; you can redistribute it and/or modify
X% it under the terms of the GNU General Public License version 1,
X% as published by the Free Software Foundation.
X%
X% This program is distributed in the hope that it will be useful,
X% but WITHOUT ANY WARRANTY; without even the implied warranty of
X% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X% GNU General Public License for more details.
X%
X% You should have received a copy of the GNU General Public License
X% along with this program; if not, write to the Free Software
X% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X
Xinclude(ps-abbrev.m4)
Xinclude(8859-1.m4)
X
X`/'PDEL % Diplay DEL.
X   {% def
X   PFIXWID
X      {% ifelse
X      (7F)ShowHalf
X      }
X      {% else
X      (DEL)ShowSpcl
X      }
X   ifelse
X   }PBIND PDEF
X
X`/'PSHY % Display soft hyphen as a dropped umlaut.
X   {% def
X   PFIXWID
X      {% ifelse
X      gsave
X         0 Size -0.25 mul rmoveto (\250)PSHOW
X      grestore
X      ( )PSHOW
X      }
X      {% else
X      0 Size -0.35 mul rmoveto(\250)PSHOW
X      0 Size  0.35 mul rmoveto
X      }
X   ifelse
X   }PBIND def
X
X`/'PNBSP % No break space.
X   {% def
X   SymbolFont1 Size SCALEFN[0.5 0 0 0.25 0 0]makefont SETFONT
X   (\353\373)PSHOW
X   SetFont
X   }PBIND PDEF
END_OF_FILE
if test 1469 -ne `wc -c <'8859-1.p4'`; then
    echo shar: \"'8859-1.p4'\" unpacked with wrong size!
fi
# end of '8859-1.p4'
fi
if test -f 'FREEZE' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'FREEZE'\"
else
echo shar: Extracting \"'FREEZE'\" \(3011 characters\)
sed "s/^X//" >'FREEZE' <<'END_OF_FILE'
X$Header: FREEZE,v 2.21 89/09/25 07:14:38 howard Exp $
X$Log:	FREEZE,v $
X# Revision 2.21  89/09/25  07:14:38  howard
X# *** empty log message ***
X# 
X# Revision 2.20  89/08/29  18:38:17  howard
X# *** empty log message ***
X# 
X========================================
X78.1         1.12    1989-09-05 08:49:31
X78.h         1.6     1989-08-24 13:03:34
X78.tex       1.8     1989-08-31 07:38:27
X78code.h     1.2     1989-08-25 11:16:02
X78code2c.c   1.2     1989-08-26 13:25:59
X78common.h   1.2     1989-08-24 13:03:41
X78diff.c     1.7     1989-08-25 11:45:50
X78dkus.c     1.2     1989-08-26 13:26:06
X78freq2tt.c  2.4     1989-08-28 18:54:50
X78heur.h     1.2     1989-08-26 13:26:29
X78meanFreq.c 1.2     1989-09-05 09:17:44
X78seus.c     1.43    1989-08-28 18:39:58
X78triFreq.c  2.2     1989-08-25 11:15:35
X8859-1-fox.t 1.1     1989-09-22 07:59:13
X8859-1.m4    1.3     1989-07-07 07:17:12
X8859-1.p4    1.1     1989-08-04 16:36:32
X8859-1.rc    1.1     1989-08-04 16:37:49
X8859-1.t     1.2     1989-09-22 07:51:07
XMakefile     1.18    1989-09-23 17:00:19
XREADME       1.1     1989-09-23 16:59:26
XT-61.m4      1.2     1989-07-07 07:17:41
XT-61.p4      1.1     1989-08-04 16:41:23
XT-61.rc      1.1     1989-08-04 17:10:29
XT-61.t       1.1     1989-09-22 07:59:42
Xb.bib        1.5     1989-09-22 07:44:48
Xbytefreq.1   1.1     1989-08-09 16:22:25
Xbytefreq.c   1.8     1989-08-18 08:14:36
Xchar8-dec.t  1.1     1989-09-22 07:59:54
Xchar8-hex.t  1.1     1989-09-22 08:00:11
Xchar8-oct.t  1.1     1989-09-22 08:00:21
Xcommon.p4    1.1     1989-08-04 17:11:24
Xcz-Gnews.el  1.2     1989-09-22 07:41:31
Xcz-news.b    1.3     1989-08-19 11:19:44
Xcz-rmail.el  1.1     1989-08-04 17:11:31
Xcz.1         2.9     1989-08-29 10:14:52
Xcz.b         1.2     1989-08-08 08:12:43
Xcz.el        1.1     1989-08-04 17:11:36
Xcz.h         1.3     1989-08-17 18:49:04
Xcz0-init.h   1.1     1989-08-17 15:10:10
Xcz0.1        2.13    1989-08-30 10:27:19
Xcz0.c        2.25    1989-08-21 10:54:56
Xcz0.h        1.1     1989-08-17 15:09:56
Xde.rc        1.1     1989-08-04 17:11:38
Xdk.fr        1.1     1989-08-26 13:30:55
Xdk.rc        1.2     1989-08-27 10:51:43
Xdkus.code    1.1     1989-08-26 13:33:36
Xes.rc        1.1     1989-08-04 17:11:42
Xfr.rc        1.1     1989-08-04 17:11:44
Xget-fonts.ps 1.1     1989-06-29 10:48:43
Xget-header.1 1.5     1989-08-29 10:50:04
Xget-header.c 1.3     1989-08-19 11:11:26
Xgrid.1       1.3     1989-08-29 10:53:25
Xgrid.c       1.4     1989-08-21 11:03:01
Xhook-add.el  1.1     1989-08-04 17:11:46
Xlaser-dr.ps  1.1     1989-06-28 08:44:27
Xletterfreq.1 1.2     1989-08-25 08:10:48
Xletterfreq.c 1.4     1989-08-25 07:51:30
Xprolog-beg.p4 1.1     1989-08-04 17:11:48
Xprolog-end.p4 1.1     1989-08-04 17:11:50
Xps-abbrev.m4 1.1     1989-08-04 17:11:53
Xse.fr        1.2     1989-08-24 13:03:57
Xse.rc        1.2     1989-08-29 10:07:10
Xseus.code    1.1     1989-08-26 13:33:50
Xstate0.m4    1.1     1989-08-04 17:12:01
XuMakefile    1.6     1989-09-22 07:44:45
Xuk.rc        1.2     1989-08-29 10:08:11
Xus.fr        1.2     1989-08-24 13:04:05
END_OF_FILE
if test 3011 -ne `wc -c <'FREEZE'`; then
    echo shar: \"'FREEZE'\" unpacked with wrong size!
fi
# end of 'FREEZE'
fi
echo shar: End of archive 1 \(of 14\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 14 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0