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 #ifdef HAVE_CONFIG_H
|
|
33 # include <config.h>
|
|
34 #endif
|
|
35
|
|
36 #include <stdio.h>
|
|
37 #if STDC_HEADERS
|
|
38 # include <string.h>
|
|
39 #else
|
|
40 # if HAVE_STRINGS_H
|
|
41 # include <strings.h>
|
|
42 # endif
|
|
43 #endif /* STDC_HEADERS */
|
|
44 #include "commonhd.h"
|
|
45 #include "wnn_os.h"
|
|
46 #include "wnn_string.h"
|
|
47
|
|
48 static char *ohinsi[] = {
|
|
49 "カ行五段",
|
|
50 "カ行(行く)",
|
|
51 "ガ行五段",
|
|
52 "サ行五段",
|
|
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 #define LINE_SIZE 1024
|
|
84
|
|
85 extern int motoni2 ();
|
|
86 static int get_line1 (char* buffer);
|
|
87 static char* get_string (char* str, char* buf);
|
|
88
|
|
89 int
|
|
90 main (void)
|
|
91 {
|
|
92 char buffer[LINE_SIZE];
|
|
93
|
|
94 fgets (buffer, LINE_SIZE, stdin);
|
|
95 printf ("\\total %s", buffer);
|
|
96 for (; fgets (buffer, LINE_SIZE, stdin) != NULL;)
|
|
97 {
|
|
98 get_line1 (buffer);
|
|
99 }
|
|
100 exit (0);
|
|
101 }
|
|
102
|
|
103 static int
|
|
104 get_line1 (char* buffer)
|
|
105 {
|
|
106 char *c = buffer;
|
|
107 char tmp[LINE_SIZE];
|
|
108 char kanji[LINE_SIZE];
|
|
109 char yomi[LINE_SIZE];
|
|
110 /*
|
|
111 char comment[LINE_SIZE];
|
|
112 */
|
|
113 w_char wyomi[LINE_SIZE];
|
|
114 w_char wyomi1[LINE_SIZE];
|
|
115 int hinsi;
|
|
116 int hindo;
|
|
117 int k;
|
|
118 int len;
|
|
119
|
|
120 if ((c = get_string (yomi, c)) == NULL)
|
|
121 return (1);
|
|
122 wnn_Sstrcpy (wyomi, yomi);
|
|
123 wnn_Sreverse (wyomi1, wyomi);
|
|
124 wnn_sStrcpy (yomi, wyomi1);
|
|
125 if ((c = get_string (kanji, c)) == NULL)
|
|
126 return (-1);
|
|
127 if ((c = get_string (tmp, c)) == NULL)
|
|
128 return (-1);
|
|
129 sscanf (tmp, "%x", &hinsi);
|
|
130 if ((c = get_string (tmp, c)) == NULL)
|
|
131 return (-1);
|
|
132 sscanf (tmp, "%d", &hindo);
|
|
133 hindo = motoni2 (hindo);
|
|
134 for (k = 0; k < 32; k++)
|
|
135 {
|
|
136 if (hinsi & (1 << k))
|
|
137 {
|
|
138 /*
|
|
139 printf("%s\t\t%s\t\t%s\t\t%d\n",yomi,kanji,ohinsi[k],hindo);
|
|
140 */
|
|
141 printf ("%s\t", yomi);
|
|
142 len = strlen (yomi);
|
|
143 if (len < 8)
|
|
144 printf ("\t");
|
|
145 if (len < 16)
|
|
146 printf ("\t");
|
|
147 printf ("%s\t", kanji);
|
|
148 len = strlen (kanji);
|
|
149 if (len < 8)
|
|
150 printf ("\t");
|
|
151 if (len < 16)
|
|
152 printf ("\t");
|
|
153 printf ("%s\t", ohinsi[k]);
|
|
154 len = strlen (ohinsi[k]);
|
|
155 if (len < 8)
|
|
156 printf ("\t");
|
|
157 printf ("%d\n", hindo);
|
|
158 }
|
|
159 }
|
|
160 return (0);
|
|
161 }
|
|
162
|
|
163 static char *
|
|
164 get_string (char* str, char* buf)
|
|
165 {
|
|
166 char *c = buf;
|
|
167 /*
|
|
168 int k;
|
|
169 */
|
|
170 for (; *c == '\t' || *c == ' '; c++);
|
|
171 if (*c == '\0' || *c == '\n')
|
|
172 {
|
|
173 return (NULL);
|
|
174 }
|
|
175 for (; *c != '\t' && *c != ' ' && *c != '\n' && *c != '\0'; c++)
|
|
176 {
|
|
177 *str++ = *c;
|
|
178 }
|
|
179 *str = 0;
|
|
180 return (c);
|
|
181 }
|