OSDN Git Service

first commit
[slackware/slackbuild.git] / stardict-tools / stardict-tools-3.0.1 / src / exc2i2e.c
1 /*
2 *  This program is free software; you can redistribute it and/or modify
3 *  it under the terms of the GNU General Public License as published by
4 *  the Free Software Foundation; either version 2 of the License, or
5 *  (at your option) any later version.
6 *
7 *  This program is distributed in the hope that it will be useful,
8 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
9 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 *  GNU Library General Public License for more details.
11 *
12 *  You should have received a copy of the GNU General Public License
13 *  along with this program; if not, write to the Free Software
14 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 */
16
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <string.h>
20
21 void Under2Space(char *p)
22 {
23 for (p=strchr(p, '_'); p; p=strchr(p, '_')) *(p++)=' ';
24 }
25
26
27 int main (int argc, char *argv[])
28 {
29 int i;
30 char *p;
31 char word[200], word2[200];
32
33 for (i=0; i<4; i++)
34    {
35    switch (i)
36       {
37       case 0: freopen("/usr/share/wordnet/noun.exc", "rt", stdin); break;
38       case 1: freopen("/usr/share/wordnet/verb.exc", "rt", stdin); break;
39       case 2: freopen("/usr/share/wordnet/adj.exc", "rt", stdin); break;
40       case 3: freopen("/usr/share/wordnet/adv.exc", "rt", stdin); break;
41       }
42    while (fgets(word, 200, stdin))
43       {
44       p=strchr(word, '\n');
45       if (p) *p=0;
46       p=strchr(word, ' ');
47       *(p++)=0;
48       Under2Space(word);
49       for (p=strtok(p, " "); p; p=strtok(NULL, " "))
50          {
51          switch(i)
52             {
53             case 0:
54             sprintf(word2, "%ses", p);
55             if (strcmp(word, word2)==0) continue;
56             break;
57             
58             case 1:
59             if (p[strlen(p)-1]=='y')
60                {
61                strcpy(word2, p);
62                strcpy(word2+strlen(word2)-1, "ied");
63                if (strcmp(word, word2)==0) continue;
64                }
65             if (strchr("bcdfghjklmnpqrstvz", p[strlen(p)-1]))
66                {
67                sprintf(word2, "%s%ced", p, p[strlen(p)-1]);
68                if (strcmp(word, word2)==0) continue;
69                sprintf(word2, "%s%cing", p, p[strlen(p)-1]);
70                if (strcmp(word, word2)==0) continue;
71                }
72             if (p[strlen(p)-1]=='e')
73                {
74                sprintf(word2, "%sd", p);
75                if (strcmp(word, word2)==0) continue;
76                }
77             sprintf(word2, "%sed", p);
78             if (strcmp(word, word2)==0) continue;
79             sprintf(word2, "%sing", p);
80             if (strcmp(word, word2)==0) continue;
81             break;
82             
83             case 2:
84             case 3:
85             if (p[strlen(p)-1]=='y')
86                {
87                strcpy(word2, p);
88                strcpy(word2+strlen(p)-1, "ier");
89                //printf ("word=%s! word2=%s!\t", word, word2);
90                if (strcmp(word, word2)==0) continue;
91                strcpy(word2+strlen(p)-1, "iest");
92                if (strcmp(word, word2)==0) continue;
93                }
94             if (strchr("bcdfghjklmnpqrstvz", p[strlen(p)-1]))
95                {
96                sprintf(word2, "%s%cer", p, p[strlen(p)-1]);
97                if (strcmp(word, word2)==0) continue;
98                sprintf(word2, "%s%cest", p, p[strlen(p)-1]);
99                if (strcmp(word, word2)==0) continue;
100                }
101             if (p[strlen(p)-1]=='e')
102                {
103                sprintf(word2, "%sr", p);
104                if (strcmp(word, word2)==0) continue;
105                sprintf(word2, "%sst", p);
106                if (strcmp(word, word2)==0) continue;
107                }
108             sprintf(word2, "%ser", p);
109             if (strcmp(word, word2)==0) continue;
110             sprintf(word2, "%sest", p);
111             if (strcmp(word, word2)==0) continue;
112             break;
113             }
114          
115          Under2Space(p);
116          if (strcmp(word, p)==0) continue;
117                         printf((i)? "%s : => {%s}\n": "%s : pl. of {%s}\n", word, p);
118                         switch(i)
119                                 {
120                                 case 0: printf("%s : (pl) %s\n", p, word); break;
121                                 case 1: printf("%s : (%s)\n", p, word); break;
122                                 case 2: printf("%s : %s (>)\n", p, word); break;
123                                 case 3: printf("%s : (adv.) %s (>)\n", p, word); break;
124                                 }
125          }
126       }
127    }
128 return 0;
129 }