0
|
1 /*
|
|
2 * $Id: oldatonewa.c,v 1.6 2004/07/19 18:24:26 hiroo Exp $
|
|
3 */
|
|
4
|
|
5 /*
|
|
6 * FreeWnn is a network-extensible Kana-to-Kanji conversion system.
|
|
7 * This file is part of FreeWnn.
|
|
8 *
|
|
9 * Copyright Kyoto University Research Institute for Mathematical Sciences
|
|
10 * 1987, 1988, 1989, 1990, 1991, 1992
|
|
11 * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1999
|
|
12 * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992
|
|
13 * Copyright FreeWnn Project 1999, 2000, 2002, 2004
|
|
14 *
|
|
15 * Maintainer: FreeWnn Project <freewnn@tomo.gr.jp>
|
|
16 *
|
|
17 * This program is free software; you can redistribute it and/or modify
|
|
18 * it under the terms of the GNU General Public License as published by
|
|
19 * the Free Software Foundation; either version 2 of the License, or
|
|
20 * (at your option) any later version.
|
|
21 *
|
|
22 * This program is distributed in the hope that it will be useful,
|
|
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
25 * GNU General Public License for more details.
|
|
26 *
|
|
27 * You should have received a copy of the GNU General Public License
|
|
28 * along with this program; if not, write to the Free Software
|
|
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
30 */
|
|
31
|
|
32 #ifndef lint
|
|
33 static char *rcs_id = "$Id: oldatonewa.c,v 1.6 2004/07/19 18:24:26 hiroo Exp $";
|
|
34 #endif /* lint */
|
|
35
|
|
36 #ifdef HAVE_CONFIG_H
|
|
37 # include <config.h>
|
|
38 #endif
|
|
39
|
|
40 #include <stdio.h>
|
|
41 #if STDC_HEADERS
|
|
42 # include <string.h>
|
|
43 #else
|
|
44 # if HAVE_STRINGS_H
|
|
45 # include <strings.h>
|
|
46 # endif
|
|
47 #endif /* STDC_HEADERS */
|
|
48 #include "commonhd.h"
|
|
49 #include "wnn_os.h"
|
|
50 #include "wnn_string.h"
|
|
51
|
|
52 static char *ohinsi[] = {
|
|
53 "カ行五段",
|
|
54 "カ行(行く)",
|
|
55 "ガ行五段",
|
|
56 "サ行五段",
|
|
57 "タ行五段",
|
|
58 "ナ行五段",
|
|
59 "バ行五段",
|
|
60 "マ行五段",
|
|
61 "ラ行五段",
|
|
62 "ワ行五段",
|
|
63 "一段&名詞",
|
|
64 "一段",
|
|
65 "サ行(する)&名詞",
|
|
66 "サ行(する)",
|
|
67 "ザ行(ずる)",
|
|
68 "来(こ)",
|
|
69 "形容詞",
|
|
70 "形容動詞",
|
|
71 "名詞",
|
|
72 "連体詞",
|
|
73 "副詞",
|
|
74 "接続詞,感動詞",
|
|
75 "来(き)",
|
|
76 "来(く)",
|
|
77 "接頭語",
|
|
78 "接尾語",
|
|
79 "助数詞",
|
|
80 "数詞",
|
|
81 "ラ行(下さい)",
|
|
82 "固有名詞",
|
|
83 "形容動詞(たる)",
|
|
84 "単漢字"
|
|
85 };
|
|
86
|
|
87 #define LINE_SIZE 1024
|
|
88
|
|
89 extern int motoni2 ();
|
|
90 static int get_line1 (char* buffer);
|
|
91 static char* get_string (char* str, char* buf);
|
|
92
|
|
93 int
|
|
94 main (void)
|
|
95 {
|
|
96 char buffer[LINE_SIZE];
|
|
97
|
|
98 fgets (buffer, LINE_SIZE, stdin);
|
|
99 printf ("\\total %s", buffer);
|
|
100 for (; fgets (buffer, LINE_SIZE, stdin) != NULL;)
|
|
101 {
|
|
102 get_line1 (buffer);
|
|
103 }
|
|
104 exit (0);
|
|
105 }
|
|
106
|
|
107 static int
|
|
108 get_line1 (char* buffer)
|
|
109 {
|
|
110 char *c = buffer;
|
|
111 char tmp[LINE_SIZE];
|
|
112 char kanji[LINE_SIZE];
|
|
113 char yomi[LINE_SIZE];
|
|
114 /*
|
|
115 char comment[LINE_SIZE];
|
|
116 */
|
|
117 w_char wyomi[LINE_SIZE];
|
|
118 w_char wyomi1[LINE_SIZE];
|
|
119 int hinsi;
|
|
120 int hindo;
|
|
121 int k;
|
|
122 int len;
|
|
123
|
|
124 if ((c = get_string (yomi, c)) == NULL)
|
|
125 return (1);
|
|
126 wnn_Sstrcpy (wyomi, yomi);
|
|
127 wnn_Sreverse (wyomi1, wyomi);
|
|
128 wnn_sStrcpy (yomi, wyomi1);
|
|
129 if ((c = get_string (kanji, c)) == NULL)
|
|
130 return (-1);
|
|
131 if ((c = get_string (tmp, c)) == NULL)
|
|
132 return (-1);
|
|
133 sscanf (tmp, "%x", &hinsi);
|
|
134 if ((c = get_string (tmp, c)) == NULL)
|
|
135 return (-1);
|
|
136 sscanf (tmp, "%d", &hindo);
|
|
137 hindo = motoni2 (hindo);
|
|
138 for (k = 0; k < 32; k++)
|
|
139 {
|
|
140 if (hinsi & (1 << k))
|
|
141 {
|
|
142 /*
|
|
143 printf("%s\t\t%s\t\t%s\t\t%d\n",yomi,kanji,ohinsi[k],hindo);
|
|
144 */
|
|
145 printf ("%s\t", yomi);
|
|
146 len = strlen (yomi);
|
|
147 if (len < 8)
|
|
148 printf ("\t");
|
|
149 if (len < 16)
|
|
150 printf ("\t");
|
|
151 printf ("%s\t", kanji);
|
|
152 len = strlen (kanji);
|
|
153 if (len < 8)
|
|
154 printf ("\t");
|
|
155 if (len < 16)
|
|
156 printf ("\t");
|
|
157 printf ("%s\t", ohinsi[k]);
|
|
158 len = strlen (ohinsi[k]);
|
|
159 if (len < 8)
|
|
160 printf ("\t");
|
|
161 printf ("%d\n", hindo);
|
|
162 }
|
|
163 }
|
|
164 return (0);
|
|
165 }
|
|
166
|
|
167 static char *
|
|
168 get_string (char* str, char* buf)
|
|
169 {
|
|
170 char *c = buf;
|
|
171 /*
|
|
172 int k;
|
|
173 */
|
|
174 for (; *c == '\t' || *c == ' '; c++);
|
|
175 if (*c == '\0' || *c == '\n')
|
|
176 {
|
|
177 return (NULL);
|
|
178 }
|
|
179 for (; *c != '\t' && *c != ' ' && *c != '\n' && *c != '\0'; c++)
|
|
180 {
|
|
181 *str++ = *c;
|
|
182 }
|
|
183 *str = 0;
|
|
184 return (c);
|
|
185 }
|