|
|
1.1 root 1: %{
2: #ifndef lint
3: static char sccsid[] = "@(#)end.l 4.2 (Berkeley) 82/11/06";
4: #endif not lint
5:
6: #include <stdio.h>
7: #include <ctype.h>
8: #include "names.h"
9: #include "ehash.c"
10: #include "edict.c"
11: #define OUT1(c) putchar(c); putchar(':'); for(i=yyleng-1;i>=0;)putchar(yytext[i--])
12: #define POUT1(c) putchar(c); putchar(':'); for(i=yyleng-1;i>0;)putchar(yytext[i--])
13: int i;
14: int nomin = 0;
15: int NOCAPS = 0; /*if set, all caps mapped to lower, plurals stripped*/
16: %}
17:
18: C [A-Z0-9a-z",;]
19: L [a-zA-Z-]
20:
21: %%
22: ^{C}:.+ {
23: ECHO;
24: }
25: ^ci.+ {
26: look(ic,2,ADJ);
27: }
28: ^de.+ {
29: look(ed,2,ED);
30: }
31: ^draw.+ {
32: if(yytext[5] == 'E'){
33: OUT1(NOUN_ADJ);
34: }
35: OUT1(ADJ_ADV);
36: }
37: ^eca.+ {
38: look(ace,3,NOUN_VERB);
39: }
40: ^eci.+ {
41: look(ice,3,NOUN_VERB);
42: }
43: ^ecne.+ {
44: if(look(ence,4,NOM))nomin++;
45: }
46: ^ecna.+ {
47: if(look(ance,4,NOM))nomin++;
48: }
49: ^ee.+ {
50: look(ee,2,NOUN);
51: }
52: ^ega.+ {
53: look(age,3,NOUN);
54: }
55: ^elba.+ {
56: look(able,4,ADJ);
57: }
58: ^elbi.+ {
59: look(ible,4,ADJ);
60: }
61: ^elc.+ {
62: look(cle,3,NOUN);
63: }
64: ^eru.+ {
65: look(ure,3,NOUN);
66: }
67: ^eti.+ {
68: look(ite,3,NOUN);
69: }
70: ^evi.+ {
71: look(ive,3,ADJ);
72: }
73: ^ezi.+ {
74: look(ize,3,VERB);
75: }
76: ^gni.+ {
77: look(ing,3,ING);
78: }
79: ^hsi.+ {
80: look(ish,3,ADJ);
81: }
82: ^lac.+ {
83: look(cal,3,ADJ);
84: }
85: ^lanoi.+ {
86: look(ional,5,ADJ);
87: }
88: ^luf.+ {
89: look(ful,3,ADJ);
90: }
91: ^msi.+ {
92: OUT1(NOUN);
93: }
94: ^nam.* {
95: look(man,3,NOUN);
96: }
97: ^nem.* {
98: OUT1(NV_PL);
99: }
100: ^noi.+ {
101: if(look(ion,3,NOM))nomin++;
102: }
103: ^pihs.+ {
104: look(ship,4,NOUN);
105: }
106: ^ral.+ {
107: look(lar,3,ADJ);
108: }
109: ^ronoh {
110: OUT1(NOUN_VERB);
111: }
112: ^ro.+ {
113: OUT1(NOUN);
114: }
115: ^si.+ {
116: look(is,2,NOUN);
117: }
118: ^ssel.+ {
119: look(less,4,ADJ);
120: }
121: ^ssen.+ {
122: look(ness,4,NOUN);
123: }
124: ^sse.+ {
125: look(ess,3,NOUN);
126: }
127: ^ss.+ {
128: look(ss,2,NOUN);
129: }
130: ^suo.+ {
131: look(ous,3,ADJ);
132: }
133: ^su.+ {
134: look(us,2,NOUN);
135: }
136: ^snoi.+ {
137: if(look(ion,4,PNOUN))nomin++;
138: }
139: ^stnem.+ {
140: if(look(ment,5,PNOUN))nomin++;
141: }
142: ^secne.+ {
143: if(look(ence,5,PNOUN))nomin++;
144: }
145: ^secna.+ {
146: if(look(ance,5,PNOUN))nomin++;
147: }
148: ^s.+ {
149: if(isupper(yytext[yyleng-1])){
150: if(NOCAPS){
151: yytext[yyleng-1] = tolower(yytext[yyleng-1]);
152: POUT1(PNOUN);
153: }
154: else { OUT1(PNOUN); }
155: }
156: else {
157: if(NOCAPS){POUT1(NV_PL);}
158: else{ OUT1(NV_PL); }
159: }
160: }
161: ^tna.+ {
162: look(ant,3,NOUN_ADJ);
163: }
164: ^tnem.+ {
165: if(look(ment,4,NOM))nomin++;
166: }
167: ^tse.+ {
168: look(est,3,ADJ);
169: }
170: ^tsi.+ {
171: look(ist,3,NOUN);
172: }
173: [,\n] {
174: putchar(yytext[0]);
175: }
176: {L}+ {
177: if(isupper(yytext[yyleng-1])){
178: if(NOCAPS)
179: yytext[yyleng-1] = tolower(yytext[yyleng-1]);
180: if((yytext[0] == 'n' || yytext[0] == 'l') && yytext[1] == 'a'){
181: OUT1(NOUN_ADJ);
182: }
183: else {
184: OUT1(NOUN);
185: }
186: }
187: else {
188: OUT1(UNK);
189: }
190: }
191: ^:[\n] {
192: egetd();
193: }
194: ^:.+[\n] {
195: printf("%s",yytext);
196: }
197: %%
198: look(f,n,nc)
199: char (*f)();
200: int n;
201: char nc;
202: {
203: int in,nn,ret;
204: char sch;
205: in=0;
206: sch=yytext[yyleng-1];
207: if(isupper(sch)){
208: yytext[yyleng-1] = tolower(sch);
209: in=1;
210: }
211: if((*f)(&yytext[n],1,0) != 0){
212: nn = (*f)(&yytext[n],1,0);
213: if(nc == PNOUN)
214: if(nn == NOUN_VERB){
215: if(in == 1)nn=PNOUN;
216: else nn=NV_PL;
217: }
218: ret = 0;
219: }
220: else {
221: nn = nc;
222: ret = 1;
223: }
224: if(in==1){
225: if(nn == NOUN_VERB)nn=NOUN;
226: if(!NOCAPS)yytext[yyleng-1]=sch;
227: }
228: if(nn==PNOUN && yytext[0] == 's' && NOCAPS){
229: POUT1(nn);
230: }
231: else {
232: OUT1(nn);
233: }
234: return(ret);
235: }
236: yywrap(){
237: printf(";%d\n",nomin);
238: return(1);
239: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.