# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	MANIFEST
#	Makefile
#	eng.1
#	eng.c
#	eng.h
#	eng.r
#	phon.pro
#	r2x.l
#	span.c
#	span.h
#	span.r
#	test
#
echo x - MANIFEST
sed 's/^X//' >MANIFEST << 'END-of-MANIFEST'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X MANIFEST                   1	This shipping list
X Makefile                   1	
X eng.1                      1	man page for translator and English rules
X phon.pro                   1	C-code for phonemic translator
X r2x.l                      1	(f)lex program creates rules.h
X eng.r                      1	English rules for translator
X span.r                     1	prototype rules for Spanish translator
END-of-MANIFEST
echo x - Makefile
sed 's/^X//' >Makefile << 'END-of-Makefile'
X# make phonemic translator
X#		Greg Lee, lee@uhccux.uhcc.hawaii.edu, July 1990
X
Xall:	eng span
X
Xeng:	eng.c eng.h
X	gcc -s -O -o eng eng.c
X
Xeng.c:	phon.pro
X	rm -f eng.c
X	echo '#include "eng.h"' >eng.c
X	cat phon.pro >>eng.c
X
Xeng.h:	r2x eng.r
X	rm -f eng.h
X	./r2x <eng.r >eng.h
X
Xspan:	span.c span.h
X	gcc -s -O -o span span.c
X
Xspan.c:	phon.pro
X	rm -f span.c
X	echo '#include "span.h"' >span.c
X	cat phon.pro >>span.c
X
Xspan.h:	r2x span.r
X	rm -f span.h
X	./r2x <span.r >span.h
X
Xr2x:	r2x.l
X	lex r2x.l
X	cc -o r2x lex.yy.c
X	@rm lex.yy.c
X
Xshar:
X	makekit -m
X	mv Part01 phon.shar
X
XDIST = MANIFEST Makefile eng.1 phon.pro r2x.l eng.r span.r
X
Xtar:	$(DIST)
X	tar cf phon.tar $(DIST)
X	compress phon.tar
END-of-Makefile
echo x - eng.1
sed 's/^X//' >eng.1 << 'END-of-eng.1'
X.TH ENG 1 LOCAL
X.SH NAME
Xeng \- a phonemic translator
X.SH SYNOPSIS
X.B eng
Xfilename  [ filenames ]
X.SH DESCRIPTION
X.I Eng
Xtranslates texts into a kind of phonemic or broad phonetic  transcription.
XThe rules which determine the transcription are in file eng.r.
XThe interpreter program itself, apart from these rules,
Xdoes not embody any assumptions about English or phonemics,
Xexcept that it changes any upper case letters that precede
Xlower case letters into lower case, before applying the rules.
XSpaces, tabs, and newlines are passed through from the
Xinput text to the output unaffected.
X.PP
XOther translators can be created by developing alternative sets
Xof rules.
XTo illustrate the procedure, I've included with the distribution
Xa little experimental set of rules for Spanish sent me by
XCelso Alvarez.
XAn included utility program
X.I r2x
Xis used to translate a file of rules into a .h header file,
Xwhich is referenced by an #include statement added to the
XC code in the file phon.pro.
X.PP
XThe rules for English phonemics are derived from those in
X"Automatic Translation of English Text to
XPhonetics by Means of Letter-to-Sound Rules", by Honey Sue Elovitz,
XRodney W. Johnson, McHugh, and Shore, Report 7948 of the United States
XNaval Research Laboatory, 1976.
X.PP
XThe transcription system is the "arpabet", with vowel sounds
Xindicated always by two letters followed optionally by a digit
Xfor stress lower than level one.  In the report mentioned above,
Xone finds the following (excerpted from Table 1):
X.sp
X.DS
X                Latin-Letter Representation of IPA
X
X                \fIexample                   example\fR
X        iy      b\fBee\fRt              ih      b\fBi\fRt
X        ey      g\fBa\fRte              eh      g\fBe\fRt
X        ae      f\fBa\fRt               aa      f\fBa\fRther
X        ao      l\fBaw\fRn              ow      l\fBo\fRne
X        uh      f\fBu\fRll              uw      f\fBoo\fRl
X        er      m\fBur\fRd\fBer\fR            ax      \fBa\fRbout
X        ah      b\fBu\fRt               ay      h\fBi\fRde
X        aw      h\fBow\fR               oy      t\fBoy\fR
X
X        th      e\fBth\fRer             dh      ei\fBth\fRer
X        sh      lea\fBsh\fR             zh      lei\fBs\fRure
X        hh      \fBh\fRow               nx      su\fBng\fR
X        y       \fBy\fRoung             ch      \fBch\fRar
X        jh      \fBj\fRar               wh      \fBwh\fRere
X.DE
X.sp
XAn example rule is
X.sp
X.DS
X        VC[on]#=ax3n
X.DE
X.sp
Xwhich interprets word-final "on" as low-stressed schwa
Xplus [n] when the "on" is preceded by vowel or a vowel
Xand some consonants.  The letter sequence being interpreted
Xis enclosed in brackets which are preceded by a left
Xenvironment and followed by a right environment.  The
Xinterpretation follows the "=" of the rule.
X.PP
XIn the environments of rules, "#" and certain capital
Xletters have special interpretations:
X.sp
X.DS
X        #        other than a lower case alphabetic letter
X        Q        a consonant (bcdfghjklmnpqrstvwxz)
X        C        zero or more consonants
X        V        one or more vowels (aeiouy)
X        Z        a voiced consonant (bdvgjlmnrwz)
X        A        a suffix (er,e,es,ed,ing,ely)
X        S        a sibilant (scgzxj ch sh)
X        D        a coronal (tsrdlznj th ch sh)
X.DE
X.sp
X.PP
XThe rules apply simultaneously, in the sense that the
Xapplicability of the rules is considered with respect
Xto the input text only -- the results of applying other
Xrules do not count.
XThe phonemic
Xinterpreter considers possible
Xinput strings in one pass from the beginning to the end
Xof the input text, with earlier stated rules given precedence
Xover later ones.
X.PP
XLetters not interpreted by any rules are copied from the
Xinput to the output, but preceded by "??" in the output,
Xto aid in identifying uninterpreted segments.
X.SH BUGS
XThe interpreter is very inefficient; it does a simple
Xsequential search for an applicable rule for each
Xnon-white-space character in a file.
XAn entire text file is stored in memory during interpretation,
Xwhich may cause difficulties with large files;
Xit would be better to just interpret one line at a time.
X.SH AUTHORS
Xinterpreter: Greg Lee, lee@uhccux.uhcc.hawaii.edu
X.br
XEnglish rules: Honey Sue Elovitz, Rodney W. Johnson, McHugh, and Shore.
END-of-eng.1
echo x - eng.c
sed 's/^X//' >eng.c << 'END-of-eng.c'
X#include "eng.h"
X/*
X * phon - phonemic translator
X *	Greg Lee, lee@uhccux.uhcc.hawaii.edu, 8/27/89
X */
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X
Xint debug = 0;
X
Xchar *fbuf;
X
Xmain(argc, argv)
Xint argc;
Xchar *argv[];
X{	int k;
X	unsigned readin();
X
X	for (k = 1; --argc; k++) interpret(argv[k]);
X}
X
XFILE *fopen();
X
Xinterpret(name)
Xchar *name;
X{
X	unsigned i, size, readin(), apply();
X
X	size = readin(name, &fbuf);
X
X	for (i=4; i<size+4; i++)
X		if (fbuf[i] >= 'A' && fbuf[i] <= 'Z' &&
X		    fbuf[i+1] >= 'a' && fbuf[i+1] <= 'z')
X		fbuf[i] += 32;
X
X	for (i=4; i<size+4; ) i = apply(i);
X	free(fbuf);
X}
X
Xunsigned
Xreadin(name,place)
Xchar *name, **place;
X{	FILE *f;
X	struct stat statbuf;
X
X	if (stat(name, &statbuf)) {
X		perror(name);
X		return(0);
X    	}
X
X	if ( (*place = (char *)malloc(statbuf.st_size+8)) == NULL ) {
X		fprintf(stderr, "not enough memory for %s\n", name);
X		exit(1);
X	}
X
X	if ( (f = fopen(name, "r")) == NULL ) {
X		fprintf(stderr, "no file %s\n", name);
X		exit(1);
X	}
X
X	fread(*place+4, 1, statbuf.st_size, f);
X
X	fclose(f);
X
X	return(statbuf.st_size);
X}
X
Xunsigned
Xapply(i)
Xint i;
X{	int r;
X	int match, c,j,k;
X	char *lhs,*rhs,*lctx,*rctx;
X
X    c = fbuf[i];
X    if (c == ' ' || c == '\t' || c == '\n') {
X	putchar(c);
X	return(i+1);
X    }
X
X    for (r=1,match=0; !match && rules[r][0]; r += 4) {
X	lctx = rules[r-1];
X	lhs = rules[r];
X	rctx = rules[r+1];
X	rhs = rules[r+2];
X
X	for (k=0; lhs[k] == fbuf[i+k]; k++) ;
X	if (!lhs[k]) {
X		int cf();
X
X		match = k;
Xif (debug) printf("\nrule %d: [%s] -> [%s] /[%s]_[%s]\n",r,lhs,rhs,lctx,rctx);
Xif (debug) printf("at %d lhs m=%d;",i,match);
X		j = i-1;
X		while ((c = *lctx++) && match)
X			if ((j = cf(j,-1,c)) < -1) match = 0;
Xif (debug) printf(" %s on left at %d;", match? "yes" : "no", j);
X		j = i+match;
X		while ((c = *rctx++) && match)
X			if ((j = cf(j, 1,c)) < -1) match = 0;
Xif (debug) printf(" %s on right at %d;", match? "yes" : "no", j);
X		if (match) while (c = *rhs++) putchar(c);
X	}
X    }
X    if (!match) {
X	putchar('?');
X	putchar('?');
X	putchar(fbuf[i]);
X	return(i+1);
X    }
X    else return(i+match);
X}
X
Xint
Xcf(pos,inc,c)
Xint pos,inc,c;
X{   int r = 0;
X    int vtest(), ctest(), ptest(), stest(), ztest(), dtest();
X
X    if (pos < 0 && c == '#') return(pos+inc);
X    switch (c) {
X	case '#':
X		while (pos >= 0 && (fbuf[pos] < 'a' || fbuf[pos] > 'z')) {
X			pos += inc;
X			r++;
X		}
X		if (pos < 0) r = 1;
X		break;
X	case 'V':
X		while (pos >= 0 && vtest(fbuf[pos])) {
X			pos += inc;
X			r++;
X		}
X		break;
X	case 'Q':
X		if (ctest(fbuf[pos])) r = 1;
X		pos += inc;
X		break;
X	case 'C':
X		while (pos >= 0 && ctest(fbuf[pos]))
X			pos += inc;
X		r = 1;
X		break;
X	case 'P':
X		if (ptest(fbuf[pos])) r = 1;
X		pos += inc;
X		break;
X/* Z	[bdvgjlmnrwz]		*/
X	case 'Z':
X		if (ztest(fbuf[pos])) r = 1;
X		pos += inc;
X		break;
X/* D	[tsrdlznj]|th|ch|sh		*/
X	case 'D':
X		if (inc == 1 && fbuf[pos+1] == 'h'
X			&& (fbuf[pos] == 't' ||
X			    fbuf[pos] == 'c' ||
X			    fbuf[pos] == 's') ) {
X			r = 1;
X			pos += 2;
X		}
X		else if (inc == -1 && fbuf[pos] == 'h'
X			&& (fbuf[pos-1] == 't' ||
X			    fbuf[pos-1] == 'c' ||
X			    fbuf[pos-1] == 's') ) {
X			r = 1;
X			pos -= 2;
X		}
X		else if (dtest(fbuf[pos])) {
X			r = 1;
X			pos += inc;
X		}
X		break;
X/* S	[scgzxj]|ch|sh		*/
X	case 'S':
X		if (inc == 1 && fbuf[pos+1] == 'h'
X			&& (fbuf[pos] == 'c' ||
X			    fbuf[pos] == 's') ) {
X			r = 1;
X			pos += 2;
X		}
X		else if (inc == -1 && fbuf[pos] == 'h'
X			&& (fbuf[pos-1] == 'c' ||
X			    fbuf[pos-1] == 's') ) {
X			r = 1;
X			pos -= 2;
X		}
X		else if (stest(fbuf[pos])) {
X			r = 1;
X			pos += inc;
X		}
X		break;
X/* A	er|e|es|ed|ing|ely		*/
X	case 'A':
X		if (fbuf[pos] == 'i'
X			&& fbuf[pos+1] == 'n'
X			&& fbuf[pos+2] == 'g') {
X			r = 1;
X			pos += 3;
X		}
X		else if (fbuf[pos] == 'e'
X			&& fbuf[pos+1] == 'l'
X			&& fbuf[pos+2] == 'y') {
X			r = 1;
X			pos += 3;
X		}
X		else if (fbuf[pos] == 'e'
X			&& fbuf[pos+1] == 'r') {
X			r = 1;
X			pos += 2;
X		}
X		else if (fbuf[pos] == 'e'
X			&& fbuf[pos+1] == 's') {
X			r = 1;
X			pos += 2;
X		}
X		else if (fbuf[pos] == 'e'
X			&& fbuf[pos+1] == 'd') {
X			r = 1;
X			pos += 2;
X		}
X		else if (fbuf[pos] == 'e') {
X			r = 1;
X			pos += inc;
X		}
X		break;
X	default:
X		if (fbuf[pos] == c) r = 1;
X		pos += inc;
X		break;
X    }
X    if (r) return(pos);
X    else return(-10);
X}
X
X/* V	[aeiouy]+		*/
Xint
Xvtest(c)
Xint c;
X{
X	if (c == 'a') return(1);
X	if (c == 'e') return(1);
X	if (c == 'i') return(1);
X	if (c == 'o') return(1);
X	if (c == 'u') return(1);
X	if (c == 'y') return(1);
X	return(0);
X}
X
X/* Q	[bcdfghjklmnpqrstvwxz]		*/
X/* C	[bcdfghjklmnpqrstvwxz]*		*/
Xint
Xctest(c)
Xint c;
X{
X	if (c == 'b') return(1);
X	if (c == 'c') return(1);
X	if (c == 'd') return(1);
X	if (c == 'f') return(1);
X	if (c == 'g') return(1);
X	if (c == 'h') return(1);
X	if (c == 'j') return(1);
X	if (c == 'k') return(1);
X	if (c == 'l') return(1);
X	if (c == 'm') return(1);
X	if (c == 'n') return(1);
X	if (c == 'p') return(1);
X	if (c == 'q') return(1);
X	if (c == 'r') return(1);
X	if (c == 's') return(1);
X	if (c == 't') return(1);
X	if (c == 'v') return(1);
X	if (c == 'w') return(1);
X	if (c == 'x') return(1);
X	if (c == 'z') return(1);
X	return(0);
X}
X
X/* P	[eiy]		*/
Xint ptest(c)
Xint c;
X{
X	if (c == 'e') return(1);
X	if (c == 'i') return(1);
X	if (c == 'y') return(1);
X	return(0);
X}
X/* Z	[bdvgjlmnrwz]		*/
Xint
Xztest(c)
Xint c;
X{
X	if (c == 'b') return(1);
X	if (c == 'd') return(1);
X	if (c == 'v') return(1);
X	if (c == 'g') return(1);
X	if (c == 'j') return(1);
X	if (c == 'l') return(1);
X	if (c == 'm') return(1);
X	if (c == 'n') return(1);
X	if (c == 'r') return(1);
X	if (c == 'w') return(1);
X	if (c == 'z') return(1);
X	return(0);
X}
X/* S	[scgzxj]|ch|sh		*/
Xint
Xstest(c)
Xint c;
X{
X	if (c == 's') return(1);
X	if (c == 'c') return(1);
X	if (c == 'g') return(1);
X	if (c == 'z') return(1);
X	if (c == 'x') return(1);
X	if (c == 'j') return(1);
X	return(0);
X}
X/* D	[tsrdlznj]|th|ch|sh		*/
Xint
Xdtest(c)
Xint c;
X{
X	if (c == 't') return(1);
X	if (c == 's') return(1);
X	if (c == 'r') return(1);
X	if (c == 'd') return(1);
X	if (c == 'l') return(1);
X	if (c == 'z') return(1);
X	if (c == 'n') return(1);
X	if (c == 'j') return(1);
X	return(0);
X}
END-of-eng.c
echo x - eng.h
sed 's/^X//' >eng.h << 'END-of-eng.h'
Xstatic char *rules[] = {
X"","a","#","ax3",
X"#","are","#","aa3r",
X"#","and","#","ae3nd",
X"#","as","#","ae3z",
X"#","at","#","ae3t",
X"#","an","#","ae3n",
X"#","ar","o","ax3r",
X"","ar","V","ehr",
X"Q#","as","V","eys",
X"","a","wa","ax3",
X"","aw","","ao",
X"C#","any","","eh2niy3",
X"","a","QPV","ey",
X"CV","ally","","ax3liy3",
X"#","al","V","ax3l",
X"","again","","ax3gehn",
X"CV","ag","e","ih3jh",
X"","a","QPCV","ae",
X"C#","a","QP#","ey2",
X"","a","QA#","ey",
X"#","arr","","ax3r",
X"","arr","","ae2r",
X"C#","ar","#","aa2r",
X"","ar","#","er3",
X"","ar","","aar",
X"","air","","eh2r",
X"","ai","","ey",
X"","ay","","ey",
X"","au","","ao",
X"CV","al","#","ax3l",
X"CV","als","#","ax3lz",
X"","alk","","aok",
X"","al","Q","aol",
X"C#","able","","ey2bax3l",
X"","able","","ax3bax3l",
X"","ang","P","eynjh",
X"","a","","ae",
X"","A","","ey",
X"C#","b","C#","biy",
X"","B","","biy",
X"#","be","QV","bih3",
X"","being","","biy2ih3nx",
X"#","both","#","bow2th",
X"#","by","#","bay3",
X"#","but","#","bah3t",
X"#","been","#","bih3n",
X"#","bus","V","bih2z",
X"","buil","","bih2l",
X"","b","","b",
X"C#","c","C#","siy",
X"","C","","siy",
X"#","ch","Q","k",
X"eQ","ch","","k",
X"","ch","","ch",
X"s#","ci","V","say2",
X"","ci","a","sh",
X"","ci","o","sh",
X"","ci","en","sh",
X"","c","P","s",
X"","ck","","k",
X"","com","A#","kahm",
X"","c","","k",
X"C#","d","C#","diy",
X"","D","","diy",
X"CV","ded","#","dih3d",
X"eZ","d","#","d",
X"eQCV","d","#","t",
X"#","de","QV","dih3",
X"#","do","#","duw",
X"#","does","","dahz",
X"#","doing","","duw2ih3nx",
X"#C","dow","","daw",
X"","du","a","jhuw3",
X"","d","","d",
X"CV","e","#","",
X"QC#'","e","#","",
X"C#","e","#","iy",
X"","E","","iy",
X"V","ed","#","d",
X"CV","e","d#","",
X"","ev","er","eh2v",
X"CV","ered","#","er3d",
X"CV","ering","","er3ih3nx",
X"CV","en","#","eh3n",
X"CV","ened","#","eh3nd",
X"","e","QA#","iy",
X"","eri","V","iy2riy3",
X"","eri","","ehrih",
X"CV","er","V","er3",
X"","er","V","ehr",
X"CV","er","#","er3",
X"CV","ers","#","er3z",
X"","er","","er",
X"#","even","","iy2veh3n",
X"CV","e","w","",
X"D","ew","","uw",
X"","ew","","yuw",
X"","e","o","iy",
X"SCV","es","#","ih3z",
X"CV","e","s#","",
X"CV","ely","#","liy3",
X"CV","ement","","meh3nt",
X"","eful","","fuh3l",
X"","ee","","iy",
X"","earn","","er2n",
X"#","ear","Q","er",
X"","ead","","eh2d",
X"CV","ea","#","iyax3",
X"","ea","su","eh",
X"","ea","","iy",
X"","eigh","","ey2",
X"","ei","","iy",
X"#","eye","","ay2",
X"","ey","","iy",
X"","eu","","yuw",
X"","e","","eh",
X"C#","f","C#","ehf",
X"","F","","ehf",
X"#","for","#","fao3r",
X"#","from","#","frax3m",
X"","ful","","fuhl",
X"","f","","f",
X"C#","g","C#","jhiy",
X"","G","","jhiy",
X"","giv","","gih2v",
X"#","g","iQ","g",
X"","ge","t","geh",
X"us","gges","","gjheh2s",
X"","gg","","g",
X"Vb#","g","","g",
X"","g","P","jh",
X"","great","","grey2t",
X"V","gh","","",
X"","g","","g",
X"C#","h","C#","eych",
X"","H","","eych",
X"#","hav","","hhaev",
X"#","has","#","hhae3z",
X"#","had","#","hhae3d",
X"#","here","","hhiyr",
X"#","hour","","aw2er3",
X"","how","","hhaw",
X"","h","V","hh",
X"","h","","",
X"#","in","#","ih3n",
X"#","in","","ihn",
X"CV","i","ng","ih3",
X"#","is","#","ih3z",
X"#","if","#","ih3f",
X"#","into","#","ih3ntuw3",
X"#","I","#","ay",
X"","in","d","ay2n",
X"","ier","","iy3er3",
X"rCV","ied","#","iy3d",
X"","ied","#","ay2d",
X"","ien","","iyehn",
X"","ie","t","ayeh",
X"C#","i","A#","ay",
X"","i","A#","iy",
X"","ie","","iy",
X"","i","QPCV","ih",
X"CV","i","Qal","ih3",
X"","ir","V","ay2r",
X"","iz","A#","ayz",
X"","is","A#","ayz",
X"","i","dA#","ay",
X"CV","ity","#","ih3tiy3",
X"QP","i","QP","ih",
X"","i","tA#","ay",
X"QCV","i","QP","ih",
X"","i","QP","ay",
X"","ir","","er",
X"","igh","","ay",
X"","ild","","ay2ld",
X"","ign","#","ayn",
X"","ign","Q","ayn",
X"","ign","A#","ayn",
X"CV","ic","#","ih3k",
X"","ique","","iy2k",
X"","i","","ih",
X"C#","j","C#","jhey",
X"","J","","jhey",
X"","j","","jh",
X"C#","k","C#","key",
X"","K","","key",
X"#","k","n","",
X"","k","","k",
X"C#","l","C#","ehl",
X"","L","","ehl",
X"","lo","cV","low",
X"l","l","","",
X"QCV","l","A#","ax3l",
X"","lead","","liy2d",
X"","l","","l",
X"C#","m","C#","ehm",
X"","M","","ehm",
X"","mov","","muw2v",
X"","m","","m",
X"C#","n","C#","ehn",
X"","N","","ehn",
X"e","ng","P","njh",
X"","ng","r","nxg",
X"","ng","V","nxg",
X"","ngl","A#","nxgax3l",
X"","ng","","nx",
X"","nk","","nxk",
X"#","now","#","naw",
X"","n","","n",
X"","of","#","ax3v",
X"#","on","#","aa3n",
X"","orough","","er2ow3",
X"","or","#","er3",
X"CV","ors","#","er3z",
X"","or","","aor",
X"#","one","","wahn",
X"","ow","","ow",
X"#","over","","ow2ver3",
X"","ov","","ahv",
X"","o","QA#","ow",
X"","o","Qen","ow",
X"","o","QiV","ow",
X"","ol","d","owl",
X"","ought","","ao2t",
X"","ough","","ah2f",
X"#","ou","","aw",
X"h","ou","sV","aw2",
X"","ous","","ax3s",
X"","our","","aor",
X"","ould","","uhd",
X"Q","ou","Ql","ah2",
X"","oup","","uwp",
X"","ou","","aw",
X"","oy","","oy2",
X"","oing","","ow2ih3nx",
X"","oi","","oy",
X"","oor","","ao2r",
X"","ook","","uh2k",
X"","ood","","uhd",
X"","oo","","uw",
X"","o","e","ow",
X"","o","#","ow",
X"","oa","","ow",
X"#","only","","ow2nliy3",
X"#","once","","wahns",
X"","on't","","ownt",
X"c","o","n","aa",
X"","o","ng","ao2",
X"QC#","o","n","ah",
X"i","on","","ax3n",
X"CV","on","#","ax3n",
X"QV","on","","ax3n",
X"","o","st#","ow",
X"","of","Q","aof",
X"","other","","ah2dher3",
X"","oss","#","ao2s",
X"QCV","om","","ahm",
X"","o","","aa",
X"","O","","ow",
X"C#","p","C#","piy",
X"","P","","piy",
X"","ph","","f",
X"","peop","","piy2p",
X"","pow","","paw2",
X"","put","#","puh3t",
X"","p","","p",
X"C#","q","C#","kyuw",
X"","Q","","kyuw",
X"","quar","","kwao2r",
X"","qu","","kw",
X"","q","","k",
X"C#","r","C#","aar",
X"","R","","aar",
X"#","re","QV","riy",
X"","r","","r",
X"C#","s","C#","ehs",
X"","S","","ehs",
X"#","so","#","sow3",
X"","sh","","sh",
X"V","sion","","zhax3n",
X"","some","","sahm",
X"V","sur","V","zher3",
X"","sur","V","sher",
X"V","su","V","zhuw3",
X"V","ssu","V","shuw3",
X"V","sed","#","zd",
X"V","s","V","z",
X"","said","","sehd",
X"Q","sion","","shax3n",
X"","s","s","",
X"Z","s","#","z",
X"eZCV","s","#","z",
X"PVQCV","s","#","z",
X"aVQCV","s","#","z",
X"oVQCV","s","#","z",
X"uVQCV","s","#","z",
X"VQCV","s","#","s",
X"u","s","#","s",
X"VC#","s","#","z",
X"#","sch","","sk",
X"","s","cP","",
X"V","sm","","zm",
X"V","sn","#'","zax3n",
X"","s","","s",
X"C#","t","C#","tiy",
X"","T","","tiy",
X"#","the","#","dhax3",
X"","to","#","tuw3",
X"","that","#","dhaet",
X"#","this","#","dhihs",
X"#","they","","dhey",
X"#","there","","dhehr",
X"","ther","","dher3",
X"","their","","dhehr",
X"#","than","#","dhae3n",
X"#","them","#","dhehm",
X"","these","#","dhiyz",
X"#","then","","dhehn",
X"","through","","thruw3",
X"","those","","dhowz",
X"","though","#","dhow",
X"#","thus","","dhahs",
X"","th","","th",
X"CV","ted","#","tih3d",
X"s","ti","Vn","ch",
X"","ti","o","sh",
X"","ti","a","sh",
X"","tien","","shax3n",
X"","tur","V","cher",
X"","tu","a","chuw3",
X"#","two","","tuw2",
X"","t","","t",
X"#","un","i","yuwn",
X"#","un","","ahn",
X"#","upon","","ax3paon",
X"D","ur","V","uhr",
X"","ur","V","yuhr",
X"","ur","","er",
X"","u","Q#","ah",
X"","u","QQ","ah",
X"","uy","","ay2",
X"g#","u","V","",
X"g","u","A#","",
X"g","u","V","w",
X"nV","u","","yuw",
X"D","u","","uw",
X"","u","","yuw",
X"","U","","yuw",
X"C#","v","C#","viy",
X"","V","","viy",
X"","view","","vyuw2",
X"","v","","v",
X"C#","w","C#","dah2bax3lyuw3",
X"","W","","dah2bax3lyuw3",
X"#","were","","wer3",
X"#","was","#","waa3z",
X"","wa","s","waa",
X"","wa","t","waa2",
X"","where","","whehr",
X"","what","","whaat",
X"","whol","","hhow2l",
X"","who","","hhuw",
X"","wh","","wh",
X"","war","","waor",
X"","wor","Q","wer2",
X"","wr","","r",
X"","w","","w",
X"C#","x","C#","ehks",
X"","X","","ehks",
X"","x","","ks",
X"#","y","#","way",
X"","Y","","way",
X"","young","","yah2nx",
X"#","you","","yuw",
X"#","yes","","yeh2s",
X"#","y","","y",
X"CQV","y","#","iy3",
X"CQV","y","i","iy3",
X"C#","y","#","ay2",
X"C#","y","V","ay2",
X"C#","y","QPCV","ih2",
X"C#","y","QV","ay",
X"","y","","ih",
X"C#","z","C#","ziy",
X"","Z","","ziy",
X"","z","","z",
X"","0","","zih2row3",
X"","1","","wahn",
X"","2","","tuw",
X"","3","","thriy",
X"","4","","fowr",
X"","5","","fayv",
X"","6","","sihks",
X"","7","","seh2vax3n",
X"","8","","eyt",
X"","9","","nayn",
X"C#",".",""," ",
X"","--","","daesh",
X"","-","","hayrax3n",
X"c","'s","#","s",
X"g","'s","#","z",
X"S","'s","#","ih3z",
X"Z","'s","#","z",
X"eSCV","'s","#","ih3z",
X"eZCV","'s","#","z",
X"eQCV","'s","#","s",
X"V","'s","#","z",
X"","'s","","s",
X"","'t","","t",
X"","'ll","","l",
X"","'d","","d",
X"","'m","","m",
X"","'",""," ",
X"",",","","<,>",
X"",".","","<.>",
X"","?","","<?>",
X"",";","","<;>",
X"",":","","<:>",
X"","+","","plahs",
X"","*","","staar",
X"","\"","","kwowt",
X"","$","","daa2ler3sayn",
X"","%","","per3sehnt",
X"","&","","ae3nd",
X"","!","","<!>",
X"","(","","ehlpehrax3n",
X"",")","","aarpehrax3n",
X"","[","","ehlbraekax3t",
X"","]","","aarbraekax3t",
X"","=","","iy2kwax3lz",
X"","@","","ae3t",
X"","<","","leh2sdhae3n",
X"",">","","grey2ter3dhae3n",
X"","/","","slaesh",
X"","\\","","baekslaesh",
X"","_","","yuwskowr",
X"","","",""
X};
END-of-eng.h
echo x - eng.r
sed 's/^X//' >eng.r << 'END-of-eng.r'
X
X	Orthographic rules for English
X
X	(Empty or indented lines in this file are comments.)
X
X   The rules below derive from the project described in
X   "Automatic Translation of English Text to Phonetics by
X   Means of Letter-to-Sound Rules", by Honey Sue Elovitz,
X   Rodney W. Johnson, McHugh, and Shore, Report 7948 of
X   the United States Naval Research Laboatory, 1976.
X
X[a]#=ax3
X#[are]#=aa3r
X#[and]#=ae3nd
X#[as]#=ae3z
X#[at]#=ae3t
X#[an]#=ae3n
X#[ar]o=ax3r
X[ar]V=ehr
X#Q[as]V=eys
X[a]wa=ax3
X[aw]=ao
X#C[any]=eh2niy3
X[a]QPV=ey
XVC[ally]=ax3liy3
X#[al]V=ax3l
X[again]=ax3gehn
XVC[ag]e=ih3jh
X[a]QPCV=ae
X#C[a]QP#=ey2
X[a]QA#=ey
X#[arr]=ax3r
X[arr]=ae2r
X#C[ar]#=aa2r
X[ar]#=er3
X[ar]=aar
X[air]=eh2r
X[ai]=ey
X[ay]=ey
X[au]=ao
XVC[al]#=ax3l
XVC[als]#=ax3lz
X[alk]=aok
X[al]Q=aol
X#C[able]=ey2bax3l
X[able]=ax3bax3l
X[ang]P=eynjh
X[a]=ae
X[A]=ey
X
X#C[b]C#=biy
X[B]=biy
X#[be]QV=bih3
X[being]=biy2ih3nx
X#[both]#=bow2th
X#[by]#=bay3
X#[but]#=bah3t
X#[been]#=bih3n
X#[bus]V=bih2z
X[buil]=bih2l
X[b]=b
X
X#C[c]C#=siy
X[C]=siy
X#[ch]Q=k
XQe[ch]=k
X[ch]=ch
X#s[ci]V=say2
X[ci]a=sh
X[ci]o=sh
X[ci]en=sh
X[c]P=s
X[ck]=k
X[com]A#=kahm
X[c]=k
X
X#C[d]C#=diy
X[D]=diy
XVC[ded]#=dih3d
XZe[d]#=d
XVCQe[d]#=t
X#[de]QV=dih3
X#[do]#=duw
X#[does]=dahz
X#[doing]=duw2ih3nx
XC#[dow]=daw
X[du]a=jhuw3
X[d]=d
X
XVC[e]#=
X'#CQ[e]#=
X#C[e]#=iy
X[E]=iy
XV[ed]#=d
XVC[e]d#=
X[ev]er=eh2v
XVC[ered]#=er3d
XVC[ering]=er3ih3nx
XVC[en]#=eh3n
XVC[ened]#=eh3nd
X[e]QA#=iy
X[eri]V=iy2riy3
X[eri]=ehrih
XVC[er]V=er3
X[er]V=ehr
XVC[er]#=er3
XVC[ers]#=er3z
X[er]=er
X#[even]=iy2veh3n
XVC[e]w=
XD[ew]=uw
X[ew]=yuw
X[e]o=iy
XVCS[es]#=ih3z
XVC[e]s#=
XVC[ely]#=liy3
XVC[ement]=meh3nt
X[eful]=fuh3l
X[ee]=iy
X[earn]=er2n
X#[ear]Q=er
X[ead]=eh2d
XVC[ea]#=iyax3
X[ea]su=eh
X[ea]=iy
X[eigh]=ey2
X[ei]=iy
X#[eye]=ay2
X[ey]=iy
X[eu]=yuw
X[e]=eh
X
X#C[f]C#=ehf
X[F]=ehf
X#[for]#=fao3r
X#[from]#=frax3m
X[ful]=fuhl
X[f]=f
X
X#C[g]C#=jhiy
X[G]=jhiy
X[giv]=gih2v
X#[g]iQ=g
X[ge]t=geh
Xsu[gges]=gjheh2s
X[gg]=g
X#bV[g]=g
X[g]P=jh
X[great]=grey2t
XV[gh]=
X[g]=g
X
X#C[h]C#=eych
X[H]=eych
X#[hav]=hhaev
X#[has]#=hhae3z
X#[had]#=hhae3d
X#[here]=hhiyr
X#[hour]=aw2er3
X[how]=hhaw
X[h]V=hh
X[h]=
X
X#[in]#=ih3n
X#[in]=ihn
XVC[i]ng=ih3
X#[is]#=ih3z
X#[if]#=ih3f
X#[into]#=ih3ntuw3
X#[I]#=ay
X[in]d=ay2n
X[ier]=iy3er3
XVCr[ied]#=iy3d
X[ied]#=ay2d
X[ien]=iyehn
X[ie]t=ayeh
X#C[i]A#=ay
X[i]A#=iy
X[ie]=iy
X[i]QPCV=ih
XVC[i]Qal=ih3
X[ir]V=ay2r
X[iz]A#=ayz
X[is]A#=ayz
X[i]dA#=ay
XVC[ity]#=ih3tiy3
XPQ[i]QP=ih
X[i]tA#=ay
XVCQ[i]QP=ih
X[i]QP=ay
X[ir]=er
X[igh]=ay
X[ild]=ay2ld
X[ign]#=ayn
X[ign]Q=ayn
X[ign]A#=ayn
XVC[ic]#=ih3k
X[ique]=iy2k
X[i]=ih
X
X#C[j]C#=jhey
X[J]=jhey
X[j]=jh
X
X#C[k]C#=key
X[K]=key
X#[k]n=
X[k]=k
X
X#C[l]C#=ehl
X[L]=ehl
X[lo]cV=low
Xl[l]=
XVCQ[l]A#=ax3l
X[lead]=liy2d
X[l]=l
X
X#C[m]C#=ehm
X[M]=ehm
X[mov]=muw2v
X[m]=m
X
X#C[n]C#=ehn
X[N]=ehn
Xe[ng]P=njh
X[ng]r=nxg
X[ng]V=nxg
X[ngl]A#=nxgax3l
X[ng]=nx
X[nk]=nxk
X#[now]#=naw
X[n]=n
X
X[of]#=ax3v
X#[on]#=aa3n
X[orough]=er2ow3
X[or]#=er3
XVC[ors]#=er3z
X[or]=aor
X#[one]=wahn
X[ow]=ow
X#[over]=ow2ver3
X[ov]=ahv
X[o]QA#=ow
X[o]Qen=ow
X[o]QiV=ow
X[ol]d=owl
X[ought]=ao2t
X[ough]=ah2f
X#[ou]=aw
Xh[ou]sV=aw2
X[ous]=ax3s
X[our]=aor
X[ould]=uhd
XQ[ou]Ql=ah2
X[oup]=uwp
X[ou]=aw
X[oy]=oy2
X[oing]=ow2ih3nx
X[oi]=oy
X[oor]=ao2r
X[ook]=uh2k
X[ood]=uhd
X[oo]=uw
X[o]e=ow
X[o]#=ow
X[oa]=ow
X#[only]=ow2nliy3
X#[once]=wahns
X[on't]=ownt
Xc[o]n=aa
X[o]ng=ao2
X#CQ[o]n=ah
Xi[on]=ax3n
XVC[on]#=ax3n
XVQ[on]=ax3n
X[o]st#=ow
X[of]Q=aof
X[other]=ah2dher3
X[oss]#=ao2s
XVCQ[om]=ahm
X[o]=aa
X[O]=ow
X
X#C[p]C#=piy
X[P]=piy
X[ph]=f
X[peop]=piy2p
X[pow]=paw2
X[put]#=puh3t
X[p]=p
X
X#C[q]C#=kyuw
X[Q]=kyuw
X[quar]=kwao2r
X[qu]=kw
X[q]=k
X
X#C[r]C#=aar
X[R]=aar
X#[re]QV=riy
X[r]=r
X
X#C[s]C#=ehs
X[S]=ehs
X#[so]#=sow3
X[sh]=sh
XV[sion]=zhax3n
X[some]=sahm
XV[sur]V=zher3
X[sur]V=sher
XV[su]V=zhuw3
XV[ssu]V=shuw3
XV[sed]#=zd
XV[s]V=z
X[said]=sehd
XQ[sion]=shax3n
X[s]s=
XZ[s]#=z
XVCZe[s]#=z
XVCQVP[s]#=z
XVCQVa[s]#=z
XVCQVo[s]#=z
XVCQVu[s]#=z
XVCQV[s]#=s
Xu[s]#=s
X#CV[s]#=z
X#[sch]=sk
X[s]cP=
XV[sm]=zm
XV[sn]#'=zax3n
X[s]=s
X
X#C[t]C#=tiy
X[T]=tiy
X#[the]#=dhax3
X[to]#=tuw3
X[that]#=dhaet
X#[this]#=dhihs
X#[they]=dhey
X#[there]=dhehr
X[ther]=dher3
X[their]=dhehr
X#[than]#=dhae3n
X#[them]#=dhehm
X[these]#=dhiyz
X#[then]=dhehn
X[through]=thruw3
X[those]=dhowz
X[though]#=dhow
X#[thus]=dhahs
X[th]=th
XVC[ted]#=tih3d
Xs[ti]Vn=ch
X[ti]o=sh
X[ti]a=sh
X[tien]=shax3n
X[tur]V=cher
X[tu]a=chuw3
X#[two]=tuw2
X[t]=t
X#[un]i=yuwn
X#[un]=ahn
X#[upon]=ax3paon
XD[ur]V=uhr
X[ur]V=yuhr
X[ur]=er
X[u]Q#=ah
X[u]QQ=ah
X[uy]=ay2
X#g[u]V=
Xg[u]A#=
Xg[u]V=w
XVn[u]=yuw
XD[u]=uw
X[u]=yuw
X[U]=yuw
X
X#C[v]C#=viy
X[V]=viy
X[view]=vyuw2
X[v]=v
X
X#C[w]C#=dah2bax3lyuw3
X[W]=dah2bax3lyuw3
X#[were]=wer3
X#[was]#=waa3z
X[wa]s=waa
X[wa]t=waa2
X[where]=whehr
X[what]=whaat
X[whol]=hhow2l
X[who]=hhuw
X[wh]=wh
X[war]=waor
X[wor]Q=wer2
X[wr]=r
X[w]=w
X
X#C[x]C#=ehks
X[X]=ehks
X[x]=ks
X
X#[y]#=way
X[Y]=way
X[young]=yah2nx
X#[you]=yuw
X#[yes]=yeh2s
X#[y]=y
XVQC[y]#=iy3
XVQC[y]i=iy3
X#C[y]#=ay2
X#C[y]V=ay2
X#C[y]QPCV=ih2
X#C[y]QV=ay
X[y]=ih
X
X#C[z]C#=ziy
X[Z]=ziy
X[z]=z
X
X	Rules for digits
X[0]=zih2row3
X[1]=wahn
X[2]=tuw
X[3]=thriy
X[4]=fowr
X[5]=fayv
X[6]=sihks
X[7]=seh2vax3n
X[8]=eyt
X[9]=nayn
X
X	Rules for punctuation
X	[ ]'= 
X#C[.]= 
X[--]=daesh
X[-]=hayrax3n
Xc['s]#=s
Xg['s]#=z
XS['s]#=ih3z
XZ['s]#=z
XVCSe['s]#=ih3z
XVCZe['s]#=z
XVCQe['s]#=s
XV['s]#=z
X['s]=s
X['t]=t
X['ll]=l
X['d]=d
X['m]=m
X[']= 
X[,]=<,>
X	[.]#?=poynt
X	QM matching digit is no implemented
X[.]=<.>
X[?]=<?>
X[;]=<;>
X[:]=<:>
X[+]=plahs
X[*]=staar
X["]=kwowt
X[$]=daa2ler3sayn
X[%]=per3sehnt
X[&]=ae3nd
X[!]=<!>
X[(]=ehlpehrax3n
X[)]=aarpehrax3n
X[[]=ehlbraekax3t
X[]]=aarbraekax3t
X[=]=iy2kwax3lz
X[@]=ae3t
X[<]=leh2sdhae3n
X[>]=grey2ter3dhae3n
X[/]=slaesh
X	[#(0)]= 
X[\]=baekslaesh
X[_]=yuwskowr
END-of-eng.r
echo x - phon.pro
sed 's/^X//' >phon.pro << 'END-of-phon.pro'
X/*
X * phon - phonemic translator
X *	Greg Lee, lee@uhccux.uhcc.hawaii.edu, 8/27/89
X */
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X
Xint debug = 0;
X
Xchar *fbuf;
X
Xmain(argc, argv)
Xint argc;
Xchar *argv[];
X{	int k;
X	unsigned readin();
X
X	for (k = 1; --argc; k++) interpret(argv[k]);
X}
X
XFILE *fopen();
X
Xinterpret(name)
Xchar *name;
X{
X	unsigned i, size, readin(), apply();
X
X	size = readin(name, &fbuf);
X
X	for (i=4; i<size+4; i++)
X		if (fbuf[i] >= 'A' && fbuf[i] <= 'Z' &&
X		    fbuf[i+1] >= 'a' && fbuf[i+1] <= 'z')
X		fbuf[i] += 32;
X
X	for (i=4; i<size+4; ) i = apply(i);
X	free(fbuf);
X}
X
Xunsigned
Xreadin(name,place)
Xchar *name, **place;
X{	FILE *f;
X	struct stat statbuf;
X
X	if (stat(name, &statbuf)) {
X		perror(name);
X		return(0);
X    	}
X
X	if ( (*place = (char *)malloc(statbuf.st_size+8)) == NULL ) {
X		fprintf(stderr, "not enough memory for %s\n", name);
X		exit(1);
X	}
X
X	if ( (f = fopen(name, "r")) == NULL ) {
X		fprintf(stderr, "no file %s\n", name);
X		exit(1);
X	}
X
X	fread(*place+4, 1, statbuf.st_size, f);
X
X	fclose(f);
X
X	return(statbuf.st_size);
X}
X
Xunsigned
Xapply(i)
Xint i;
X{	int r;
X	int match, c,j,k;
X	char *lhs,*rhs,*lctx,*rctx;
X
X    c = fbuf[i];
X    if (c == ' ' || c == '\t' || c == '\n') {
X	putchar(c);
X	return(i+1);
X    }
X
X    for (r=1,match=0; !match && rules[r][0]; r += 4) {
X	lctx = rules[r-1];
X	lhs = rules[r];
X	rctx = rules[r+1];
X	rhs = rules[r+2];
X
X	for (k=0; lhs[k] == fbuf[i+k]; k++) ;
X	if (!lhs[k]) {
X		int cf();
X
X		match = k;
Xif (debug) printf("\nrule %d: [%s] -> [%s] /[%s]_[%s]\n",r,lhs,rhs,lctx,rctx);
Xif (debug) printf("at %d lhs m=%d;",i,match);
X		j = i-1;
X		while ((c = *lctx++) && match)
X			if ((j = cf(j,-1,c)) < -1) match = 0;
Xif (debug) printf(" %s on left at %d;", match? "yes" : "no", j);
X		j = i+match;
X		while ((c = *rctx++) && match)
X			if ((j = cf(j, 1,c)) < -1) match = 0;
Xif (debug) printf(" %s on right at %d;", match? "yes" : "no", j);
X		if (match) while (c = *rhs++) putchar(c);
X	}
X    }
X    if (!match) {
X	putchar('?');
X	putchar('?');
X	putchar(fbuf[i]);
X	return(i+1);
X    }
X    else return(i+match);
X}
X
Xint
Xcf(pos,inc,c)
Xint pos,inc,c;
X{   int r = 0;
X    int vtest(), ctest(), ptest(), stest(), ztest(), dtest();
X
X    if (pos < 0 && c == '#') return(pos+inc);
X    switch (c) {
X	case '#':
X		while (pos >= 0 && (fbuf[pos] < 'a' || fbuf[pos] > 'z')) {
X			pos += inc;
X			r++;
X		}
X		if (pos < 0) r = 1;
X		break;
X	case 'V':
X		while (pos >= 0 && vtest(fbuf[pos])) {
X			pos += inc;
X			r++;
X		}
X		break;
X	case 'Q':
X		if (ctest(fbuf[pos])) r = 1;
X		pos += inc;
X		break;
X	case 'C':
X		while (pos >= 0 && ctest(fbuf[pos]))
X			pos += inc;
X		r = 1;
X		break;
X	case 'P':
X		if (ptest(fbuf[pos])) r = 1;
X		pos += inc;
X		break;
X/* Z	[bdvgjlmnrwz]		*/
X	case 'Z':
X		if (ztest(fbuf[pos])) r = 1;
X		pos += inc;
X		break;
X/* D	[tsrdlznj]|th|ch|sh		*/
X	case 'D':
X		if (inc == 1 && fbuf[pos+1] == 'h'
X			&& (fbuf[pos] == 't' ||
X			    fbuf[pos] == 'c' ||
X			    fbuf[pos] == 's') ) {
X			r = 1;
X			pos += 2;
X		}
X		else if (inc == -1 && fbuf[pos] == 'h'
X			&& (fbuf[pos-1] == 't' ||
X			    fbuf[pos-1] == 'c' ||
X			    fbuf[pos-1] == 's') ) {
X			r = 1;
X			pos -= 2;
X		}
X		else if (dtest(fbuf[pos])) {
X			r = 1;
X			pos += inc;
X		}
X		break;
X/* S	[scgzxj]|ch|sh		*/
X	case 'S':
X		if (inc == 1 && fbuf[pos+1] == 'h'
X			&& (fbuf[pos] == 'c' ||
X			    fbuf[pos] == 's') ) {
X			r = 1;
X			pos += 2;
X		}
X		else if (inc == -1 && fbuf[pos] == 'h'
X			&& (fbuf[pos-1] == 'c' ||
X			    fbuf[pos-1] == 's') ) {
X			r = 1;
X			pos -= 2;
X		}
X		else if (stest(fbuf[pos])) {
X			r = 1;
X			pos += inc;
X		}
X		break;
X/* A	er|e|es|ed|ing|ely		*/
X	case 'A':
X		if (fbuf[pos] == 'i'
X			&& fbuf[pos+1] == 'n'
X			&& fbuf[pos+2] == 'g') {
X			r = 1;
X			pos += 3;
X		}
X		else if (fbuf[pos] == 'e'
X			&& fbuf[pos+1] == 'l'
X			&& fbuf[pos+2] == 'y') {
X			r = 1;
X			pos += 3;
X		}
X		else if (fbuf[pos] == 'e'
X			&& fbuf[pos+1] == 'r') {
X			r = 1;
X			pos += 2;
X		}
X		else if (fbuf[pos] == 'e'
X			&& fbuf[pos+1] == 's') {
X			r = 1;
X			pos += 2;
X		}
X		else if (fbuf[pos] == 'e'
X			&& fbuf[pos+1] == 'd') {
X			r = 1;
X			pos += 2;
X		}
X		else if (fbuf[pos] == 'e') {
X			r = 1;
X			pos += inc;
X		}
X		break;
X	default:
X		if (fbuf[pos] == c) r = 1;
X		pos += inc;
X		break;
X    }
X    if (r) return(pos);
X    else return(-10);
X}
X
X/* V	[aeiouy]+		*/
Xint
Xvtest(c)
Xint c;
X{
X	if (c == 'a') return(1);
X	if (c == 'e') return(1);
X	if (c == 'i') return(1);
X	if (c == 'o') return(1);
X	if (c == 'u') return(1);
X	if (c == 'y') return(1);
X	return(0);
X}
X
X/* Q	[bcdfghjklmnpqrstvwxz]		*/
X/* C	[bcdfghjklmnpqrstvwxz]*		*/
Xint
Xctest(c)
Xint c;
X{
X	if (c == 'b') return(1);
X	if (c == 'c') return(1);
X	if (c == 'd') return(1);
X	if (c == 'f') return(1);
X	if (c == 'g') return(1);
X	if (c == 'h') return(1);
X	if (c == 'j') return(1);
X	if (c == 'k') return(1);
X	if (c == 'l') return(1);
X	if (c == 'm') return(1);
X	if (c == 'n') return(1);
X	if (c == 'p') return(1);
X	if (c == 'q') return(1);
X	if (c == 'r') return(1);
X	if (c == 's') return(1);
X	if (c == 't') return(1);
X	if (c == 'v') return(1);
X	if (c == 'w') return(1);
X	if (c == 'x') return(1);
X	if (c == 'z') return(1);
X	return(0);
X}
X
X/* P	[eiy]		*/
Xint ptest(c)
Xint c;
X{
X	if (c == 'e') return(1);
X	if (c == 'i') return(1);
X	if (c == 'y') return(1);
X	return(0);
X}
X/* Z	[bdvgjlmnrwz]		*/
Xint
Xztest(c)
Xint c;
X{
X	if (c == 'b') return(1);
X	if (c == 'd') return(1);
X	if (c == 'v') return(1);
X	if (c == 'g') return(1);
X	if (c == 'j') return(1);
X	if (c == 'l') return(1);
X	if (c == 'm') return(1);
X	if (c == 'n') return(1);
X	if (c == 'r') return(1);
X	if (c == 'w') return(1);
X	if (c == 'z') return(1);
X	return(0);
X}
X/* S	[scgzxj]|ch|sh		*/
Xint
Xstest(c)
Xint c;
X{
X	if (c == 's') return(1);
X	if (c == 'c') return(1);
X	if (c == 'g') return(1);
X	if (c == 'z') return(1);
X	if (c == 'x') return(1);
X	if (c == 'j') return(1);
X	return(0);
X}
X/* D	[tsrdlznj]|th|ch|sh		*/
Xint
Xdtest(c)
Xint c;
X{
X	if (c == 't') return(1);
X	if (c == 's') return(1);
X	if (c == 'r') return(1);
X	if (c == 'd') return(1);
X	if (c == 'l') return(1);
X	if (c == 'z') return(1);
X	if (c == 'n') return(1);
X	if (c == 'j') return(1);
X	return(0);
X}
END-of-phon.pro
echo x - r2x.l
sed 's/^X//' >r2x.l << 'END-of-r2x.l'
X%{
X/*
X * r2x - translate orthographic rules into C array
X *		Greg Lee, lee@uhccux.uhcc.hawaii.edu, 8/27/89
X */
Xint i;
X%}
X%%
X
X^[ \t].*\n	;
X^[ \t]*\n	;
X
X^[^\[\n]*"["	{
X	putchar('"');
X	for (i=0; i<yyleng-1; i++) utchar(yytext[yyleng-2-i]);
X	putchar('"');
X	putchar(',');
X};
X
X"[]"/=		{
X	putchar('"');
X	putchar('[');
X	putchar('"');
X	putchar(',');
X};
X
X"]]"		{
X	putchar('"');
X	putchar(']');
X	putchar('"');
X	putchar(',');
X};
X
X[^\[\]\n]+"]"	{
X	putchar('"');
X	for (i=0; i<yyleng-1; i++) utchar(yytext[i]);
X	putchar('"');
X	putchar(',');
X};
X
X[^=\]\[\n]*"="	{
X	putchar('"');
X	for (i=0; i<yyleng-1; i++) utchar(yytext[i]);
X	putchar('"');
X	putchar(',');
X};
X
X[^=\n]*\n	{
X	putchar('"');
X	for (i=0; i<yyleng-1; i++) utchar(yytext[i]);
X	putchar('"');
X	putchar(',');
X	putchar('\n');
X};
X
X%%
Xmain()
X{
X	printf("static char *rules[] = {\n");
X	yylex();
X	printf("\"\",\"\",\"\",\"\"\n");
X	printf("};\n");
X}
X
Xutchar(c)
Xint c;
X{
X	if (c == '"' || c == '\\') putchar('\\');
X	putchar(c);
X}
END-of-r2x.l
echo x - span.c
sed 's/^X//' >span.c << 'END-of-span.c'
X#include "span.h"
X/*
X * phon - phonemic translator
X *	Greg Lee, lee@uhccux.uhcc.hawaii.edu, 8/27/89
X */
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X
Xint debug = 0;
X
Xchar *fbuf;
X
Xmain(argc, argv)
Xint argc;
Xchar *argv[];
X{	int k;
X	unsigned readin();
X
X	for (k = 1; --argc; k++) interpret(argv[k]);
X}
X
XFILE *fopen();
X
Xinterpret(name)
Xchar *name;
X{
X	unsigned i, size, readin(), apply();
X
X	size = readin(name, &fbuf);
X
X	for (i=4; i<size+4; i++)
X		if (fbuf[i] >= 'A' && fbuf[i] <= 'Z' &&
X		    fbuf[i+1] >= 'a' && fbuf[i+1] <= 'z')
X		fbuf[i] += 32;
X
X	for (i=4; i<size+4; ) i = apply(i);
X	free(fbuf);
X}
X
Xunsigned
Xreadin(name,place)
Xchar *name, **place;
X{	FILE *f;
X	struct stat statbuf;
X
X	if (stat(name, &statbuf)) {
X		perror(name);
X		return(0);
X    	}
X
X	if ( (*place = (char *)malloc(statbuf.st_size+8)) == NULL ) {
X		fprintf(stderr, "not enough memory for %s\n", name);
X		exit(1);
X	}
X
X	if ( (f = fopen(name, "r")) == NULL ) {
X		fprintf(stderr, "no file %s\n", name);
X		exit(1);
X	}
X
X	fread(*place+4, 1, statbuf.st_size, f);
X
X	fclose(f);
X
X	return(statbuf.st_size);
X}
X
Xunsigned
Xapply(i)
Xint i;
X{	int r;
X	int match, c,j,k;
X	char *lhs,*rhs,*lctx,*rctx;
X
X    c = fbuf[i];
X    if (c == ' ' || c == '\t' || c == '\n') {
X	putchar(c);
X	return(i+1);
X    }
X
X    for (r=1,match=0; !match && rules[r][0]; r += 4) {
X	lctx = rules[r-1];
X	lhs = rules[r];
X	rctx = rules[r+1];
X	rhs = rules[r+2];
X
X	for (k=0; lhs[k] == fbuf[i+k]; k++) ;
X	if (!lhs[k]) {
X		int cf();
X
X		match = k;
Xif (debug) printf("\nrule %d: [%s] -> [%s] /[%s]_[%s]\n",r,lhs,rhs,lctx,rctx);
Xif (debug) printf("at %d lhs m=%d;",i,match);
X		j = i-1;
X		while ((c = *lctx++) && match)
X			if ((j = cf(j,-1,c)) < -1) match = 0;
Xif (debug) printf(" %s on left at %d;", match? "yes" : "no", j);
X		j = i+match;
X		while ((c = *rctx++) && match)
X			if ((j = cf(j, 1,c)) < -1) match = 0;
Xif (debug) printf(" %s on right at %d;", match? "yes" : "no", j);
X		if (match) while (c = *rhs++) putchar(c);
X	}
X    }
X    if (!match) {
X	putchar('?');
X	putchar('?');
X	putchar(fbuf[i]);
X	return(i+1);
X    }
X    else return(i+match);
X}
X
Xint
Xcf(pos,inc,c)
Xint pos,inc,c;
X{   int r = 0;
X    int vtest(), ctest(), ptest(), stest(), ztest(), dtest();
X
X    if (pos < 0 && c == '#') return(pos+inc);
X    switch (c) {
X	case '#':
X		while (pos >= 0 && (fbuf[pos] < 'a' || fbuf[pos] > 'z')) {
X			pos += inc;
X			r++;
X		}
X		if (pos < 0) r = 1;
X		break;
X	case 'V':
X		while (pos >= 0 && vtest(fbuf[pos])) {
X			pos += inc;
X			r++;
X		}
X		break;
X	case 'Q':
X		if (ctest(fbuf[pos])) r = 1;
X		pos += inc;
X		break;
X	case 'C':
X		while (pos >= 0 && ctest(fbuf[pos]))
X			pos += inc;
X		r = 1;
X		break;
X	case 'P':
X		if (ptest(fbuf[pos])) r = 1;
X		pos += inc;
X		break;
X/* Z	[bdvgjlmnrwz]		*/
X	case 'Z':
X		if (ztest(fbuf[pos])) r = 1;
X		pos += inc;
X		break;
X/* D	[tsrdlznj]|th|ch|sh		*/
X	case 'D':
X		if (inc == 1 && fbuf[pos+1] == 'h'
X			&& (fbuf[pos] == 't' ||
X			    fbuf[pos] == 'c' ||
X			    fbuf[pos] == 's') ) {
X			r = 1;
X			pos += 2;
X		}
X		else if (inc == -1 && fbuf[pos] == 'h'
X			&& (fbuf[pos-1] == 't' ||
X			    fbuf[pos-1] == 'c' ||
X			    fbuf[pos-1] == 's') ) {
X			r = 1;
X			pos -= 2;
X		}
X		else if (dtest(fbuf[pos])) {
X			r = 1;
X			pos += inc;
X		}
X		break;
X/* S	[scgzxj]|ch|sh		*/
X	case 'S':
X		if (inc == 1 && fbuf[pos+1] == 'h'
X			&& (fbuf[pos] == 'c' ||
X			    fbuf[pos] == 's') ) {
X			r = 1;
X			pos += 2;
X		}
X		else if (inc == -1 && fbuf[pos] == 'h'
X			&& (fbuf[pos-1] == 'c' ||
X			    fbuf[pos-1] == 's') ) {
X			r = 1;
X			pos -= 2;
X		}
X		else if (stest(fbuf[pos])) {
X			r = 1;
X			pos += inc;
X		}
X		break;
X/* A	er|e|es|ed|ing|ely		*/
X	case 'A':
X		if (fbuf[pos] == 'i'
X			&& fbuf[pos+1] == 'n'
X			&& fbuf[pos+2] == 'g') {
X			r = 1;
X			pos += 3;
X		}
X		else if (fbuf[pos] == 'e'
X			&& fbuf[pos+1] == 'l'
X			&& fbuf[pos+2] == 'y') {
X			r = 1;
X			pos += 3;
X		}
X		else if (fbuf[pos] == 'e'
X			&& fbuf[pos+1] == 'r') {
X			r = 1;
X			pos += 2;
X		}
X		else if (fbuf[pos] == 'e'
X			&& fbuf[pos+1] == 's') {
X			r = 1;
X			pos += 2;
X		}
X		else if (fbuf[pos] == 'e'
X			&& fbuf[pos+1] == 'd') {
X			r = 1;
X			pos += 2;
X		}
X		else if (fbuf[pos] == 'e') {
X			r = 1;
X			pos += inc;
X		}
X		break;
X	default:
X		if (fbuf[pos] == c) r = 1;
X		pos += inc;
X		break;
X    }
X    if (r) return(pos);
X    else return(-10);
X}
X
X/* V	[aeiouy]+		*/
Xint
Xvtest(c)
Xint c;
X{
X	if (c == 'a') return(1);
X	if (c == 'e') return(1);
X	if (c == 'i') return(1);
X	if (c == 'o') return(1);
X	if (c == 'u') return(1);
X	if (c == 'y') return(1);
X	return(0);
X}
X
X/* Q	[bcdfghjklmnpqrstvwxz]		*/
X/* C	[bcdfghjklmnpqrstvwxz]*		*/
Xint
Xctest(c)
Xint c;
X{
X	if (c == 'b') return(1);
X	if (c == 'c') return(1);
X	if (c == 'd') return(1);
X	if (c == 'f') return(1);
X	if (c == 'g') return(1);
X	if (c == 'h') return(1);
X	if (c == 'j') return(1);
X	if (c == 'k') return(1);
X	if (c == 'l') return(1);
X	if (c == 'm') return(1);
X	if (c == 'n') return(1);
X	if (c == 'p') return(1);
X	if (c == 'q') return(1);
X	if (c == 'r') return(1);
X	if (c == 's') return(1);
X	if (c == 't') return(1);
X	if (c == 'v') return(1);
X	if (c == 'w') return(1);
X	if (c == 'x') return(1);
X	if (c == 'z') return(1);
X	return(0);
X}
X
X/* P	[eiy]		*/
Xint ptest(c)
Xint c;
X{
X	if (c == 'e') return(1);
X	if (c == 'i') return(1);
X	if (c == 'y') return(1);
X	return(0);
X}
X/* Z	[bdvgjlmnrwz]		*/
Xint
Xztest(c)
Xint c;
X{
X	if (c == 'b') return(1);
X	if (c == 'd') return(1);
X	if (c == 'v') return(1);
X	if (c == 'g') return(1);
X	if (c == 'j') return(1);
X	if (c == 'l') return(1);
X	if (c == 'm') return(1);
X	if (c == 'n') return(1);
X	if (c == 'r') return(1);
X	if (c == 'w') return(1);
X	if (c == 'z') return(1);
X	return(0);
X}
X/* S	[scgzxj]|ch|sh		*/
Xint
Xstest(c)
Xint c;
X{
X	if (c == 's') return(1);
X	if (c == 'c') return(1);
X	if (c == 'g') return(1);
X	if (c == 'z') return(1);
X	if (c == 'x') return(1);
X	if (c == 'j') return(1);
X	return(0);
X}
X/* D	[tsrdlznj]|th|ch|sh		*/
Xint
Xdtest(c)
Xint c;
X{
X	if (c == 't') return(1);
X	if (c == 's') return(1);
X	if (c == 'r') return(1);
X	if (c == 'd') return(1);
X	if (c == 'l') return(1);
X	if (c == 'z') return(1);
X	if (c == 'n') return(1);
X	if (c == 'j') return(1);
X	return(0);
X}
END-of-span.c
echo x - span.h
sed 's/^X//' >span.h << 'END-of-span.h'
Xstatic char *rules[] = {
X"",",","","<,>",
X"",".","","<.>",
X"","-","","",
X"u","\"","","",
X"","\"","","<\">",
X"",":","","<:>",
X"","ai","","ay",
X"","ay","","ay",
X"","au","","aw",
X"","a","","a",
X"","A","","a",
X"","b","","b",
X"","B","","be",
X"","c","e","Z",
X"","c","i","Z",
X"","C","","Ze",
X"","ch","","C",
X"","ciao","","Cau",
X"","c","","k",
X"","D","","de",
X"","d","","d",
X"","E","","e",
X"","e","","e",
X"","F","","efe",
X"","f","","f",
X"","g","","g",
X"","G","","xe",
X"","g","a","g",
X"","g","o","g",
X"","g","u","g",
X"","g","i","x",
X"","g","e","x",
X"","h","","",
X"","H","","aCe",
X"","i","V","y",
X"","i'","","i",
X"","i","","i",
X"","I","","i",
X"","j","","x",
X"","J","","xota",
X"","k","","k",
X"","K","","ka",
X"","ll","","L",
X"","l","","l",
X"","M","","eme",
X"","m","","m",
X"","n~","","N",
X"","n","#b","m",
X"","n","b","m",
X"","n","#v","m",
X"","n","v","m",
X"","n","","n",
X"","N","","ene",
X"","o","","o",
X"","O","","o",
X"","p","","p",
X"","P","","pe",
X"","Q","","ku",
X"","qu","","k",
X"","rr","","R",
X"#","r","","R",
X"s","r","","R",
X"n","r","","R",
X"l","r","","R",
X"C","r","","r",
X"V","r","","r",
X"","r","","r",
X"","R","","eRe",
X"","s","","s",
X"","S","","ese",
X"","t","","t",
X"","T","","te",
X"g","u","e","",
X"g","u","i","",
X"","u","\"","w",
X"","u","V","w",
X"","u'","","u",
X"q","u","","",
X"","U","","u",
X"","u","","u",
X"","v","","b",
X"n","v","","b",
X"m","v","","b",
X"","V","","ube",
X"","w","","w",
X"","W","","ube doble",
X"","x","","ks",
X"","X","","ekis",
X"","Y","","i gryega",
X"V","y","","i",
X"","y","V","y",
X"","y","","i",
X"","Z","","Zeta",
X"","z","","Z",
X"","0","","Zero",
X"","1","","uno",
X"","2","","dos",
X"","3","","tres",
X"","4","","kwatro",
X"","5","","Zinko",
X"","6","","seis",
X"","7","","syete",
X"","8","","oCo",
X"","9","","nwebe",
X"","+","","mas",
X"","*","","asterisko",
X"","%","","por Zyento",
X"","(","","parentesis",
X"",")","","parentesis",
X"","=","","igwal a",
X"","<","","menos ke",
X"",">","","mas ke",
X"","/","","baRa",
X"","\\","","baRa imbertida",
X"","","",""
X};
END-of-span.h
echo x - span.r
sed 's/^X//' >span.r << 'END-of-span.r'
X    Date: Tue, 5 Sep 89 22:09:04 PDT
X    From: sp299-ad@violet.berkeley.edu (Celso Alvarez)
X    Subject: Re: Phonemic interpreter
X
X    Greg,
X
X    I'm sending you the phonemic pseudo-rules in progress that I'm writing
X    for Spanish, just to satisfy my own curiosity.  They have no much value
X    in themselves, as some of them are orthographically based, and
X    I have not checked if their ordering works in all instances.
X    My idea is to turn them little by little into phonetic rules,
X    without much research, just as a mental exercise to review my rusty
X    phonetics.  So far I haven't done anything about lexical accent, that
X    would be a further step.
X
X    I'm also sending you a Key to interpret the value of some signs.  I have
X    not used the Latin transliteration of the IPA with digraphs, but
X    I preferred to keep the one sound-one symbol correspondence.  Upper-
X    case letters are thus used as well.
X
X    The rules correspond to standard Castilian Spanish, with
X    	- palatal lateral [L] instead of [y] in "llamar"
X    	- interdental [Z] <theta> instead of [s] in "caza"
X    	- velar fricative [x] instead of [h] in "gente"
X
X    Please note that some Spanish diacritics should be indicated (not
X    always, though): the palatal nasal is "n~", and the accent mark should
X    be written after the vowel in cases of hiatus like "di'a" [dia], not
X    *[dya].
X
X    If you want to play with them, improve them, or make them look
X    more decent, I'd be glad to maintain a dialogue with you about them.
X
X    Thanks again for sharing this with me.  I still plan to talk to
X    some people into trying to use them for their classes.
X
X    Two more messages will follow.
X
X    celso
X    sp299-ad@violet.berkeley.edu
X
X
X	Key to interpret the value of symbols in rules.r
X
X	a	[a]
X	b	[b]
X	C	palatal affricate in "mucho"
X	d	[d]
X	e	[e]
X	f	[f]
X	g	[g]
X	i	[i]
X	k	[k]
X	l	[l]
X	L	palatal lateral in "llamar"
X	m	[m]
X	n	[n]
X	N	palatal nasal in "cen~o"
X	o	[o]
X	p	[p]
X	r	[r]
X	R	multiple vibrant in "perro", "rosa"
X	s	[s]
X	t	[t]
X	u	[u]
X	w	[w]
X	x	[x]
X	y	[y]
X	Z	interdental fricative in "caza", "cena"
X
X
X	Rules for Spanish
X
X[,]=<,>
X[.]=<.>
X[-]=
Xu["]=
X["]=<">
X[:]=<:>
X
X[ai]=ay
X[ay]=ay
X[au]=aw
X[a]=a
X[A]=a
X
X[b]=b
X[B]=be
X
X[c]e=Z
X[c]i=Z
X[C]=Ze
X[ch]=C
X[ciao]=Cau
X[c]=k
X
X[D]=de
X[d]=d
X
X[E]=e
X[e]=e
X
X[F]=efe
X[f]=f
X
X[g]=g
X[G]=xe
X[g]a=g
X[g]o=g
X[g]u=g
X[g]i=x
X[g]e=x
X
X[h]=
X[H]=aCe
X
X[i]V=y
X[i']=i
X[i]=i
X[I]=i
X
X[j]=x
X[J]=xota
X
X[k]=k
X[K]=ka
X
X[ll]=L
X
X[l]=l
X
X[M]=eme
X[m]=m
X
X[n~]=N
X
X[n]#b=m
X[n]b=m
X[n]#v=m
X[n]v=m
X[n]=n
X[N]=ene
X
X[o]=o
X[O]=o
X
X[p]=p
X[P]=pe
X
X[Q]=ku
X[qu]=k
X
X[rr]=R
X#[r]=R
Xs[r]=R
Xn[r]=R
Xl[r]=R
XC[r]=r
XV[r]=r
X[r]=r
X[R]=eRe
X
X[s]=s
X[S]=ese
X
X[t]=t
X[T]=te
X
Xg[u]e=
Xg[u]i=
X[u]"=w
X[u]V=w
X[u']=u
Xq[u]=
X[U]=u
X[u]=u
X
X[v]=b
Xn[v]=b
Xm[v]=b
X[V]=ube
X
X[w]=w
X[W]=ube doble
X
X[x]=ks
X[X]=ekis
X
X[Y]=i gryega
XV[y]=i
X[y]V=y
X[y]=i
X
X[Z]=Zeta
X[z]=Z
X
X	Rules for digits
X[0]=Zero
X[1]=uno
X[2]=dos
X[3]=tres
X[4]=kwatro
X[5]=Zinko
X[6]=seis
X[7]=syete
X[8]=oCo
X[9]=nwebe
X
X	Rules for punctuation
X	[ ]'= 
X	#C[.]= 
X	[--]=daesh
X	[-]=hayrax3n
X	[']= 
X	[,]=<,>
X	[.]#?=poynt
X	QM matching digit is no implemented
X	[.]=<.>
X	[?]=<?>
X	[;]=<;>
X	[:]=<:>
X[+]=mas
X[*]=asterisko
X	["]=komiLas
X	[$]=daa2ler3sayn
X[%]=por Zyento
X	[&]=ae3nd
X	[!]=<!>
X[(]=parentesis
X[)]=parentesis
X	[[]=ehlbraekax3t
X	[]]=aarbraekax3t
X[=]=igwal a
X	[@]=ae3t
X[<]=menos ke
X[>]=mas ke
X[/]=baRa
X	[#(0)]= 
X[\]=baRa imbertida
X	[_]=yuwskowr
X
END-of-span.r
echo x - test
sed 's/^X//' >test << 'END-of-test'
Xnon-hyphenable
END-of-test
exit

