Mercurial > freewnn
comparison Wnn/include/jllib.h @ 0:bbc77ca4def5
initial import
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Thu, 13 Dec 2007 04:30:14 +0900 |
parents | |
children | aa17e2acfa01 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:bbc77ca4def5 |
---|---|
1 /* | |
2 * $Id: jllib.h,v 1.5 2005/04/10 15:26:37 aonoto 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 | |
14 * | |
15 * Maintainer: FreeWnn Project <freewnn@tomo.gr.jp> | |
16 * | |
17 * This library is free software; you can redistribute it and/or | |
18 * modify it under the terms of the GNU Lesser General Public | |
19 * License as published by the Free Software Foundation; either | |
20 * version 2 of the License, or (at your option) any later version. | |
21 * | |
22 * This library 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 GNU | |
25 * Lesser General Public License for more details. | |
26 * | |
27 * You should have received a copy of the GNU Lesser General Public | |
28 * License along with this library; if not, write to the | |
29 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
30 * Boston, MA 02111-1307, USA. | |
31 */ | |
32 | |
33 /* | |
34 * Nihongo Henkan Library Header File | |
35 */ | |
36 | |
37 #ifndef WNN_JLLIB_H | |
38 #define WNN_JLLIB_H | |
39 | |
40 #include "jslib.h" | |
41 | |
42 | |
43 /* | |
44 ユーザープログラムは、直接この構造体の内容をアクセスする必要は無いはず。 | |
45 ライブラリ関数を用いること。 | |
46 */ | |
47 | |
48 #define WNN_YOMI_SIZE 10 | |
49 | |
50 typedef struct wnn_jl_bun WNN_BUN; | |
51 | |
52 struct wnn_jl_bun | |
53 { | |
54 int jirilen; /* 候補文節の自立語 */ | |
55 int dic_no; | |
56 int entry; | |
57 int kangovect; /* 接続ベクトルテーブルへのポインタ */ | |
58 int hinsi; /* 品詞 */ | |
59 int hindo:16; /* 頻度(仮想値) */ | |
60 int ref_cnt:4; /* 文節リストに使われている */ | |
61 /* BUG FIX signed --> unsigned */ | |
62 unsigned int ima:1; /* 今使ったよビット */ | |
63 unsigned int hindo_updated:1; /* この文節の頻度は更新されている */ | |
64 unsigned int nobi_top:1; /* 伸ばし縮みを行ったかを示す。 */ | |
65 /* egg みたいに伸ばし縮みを繰り返し行う時に、途中に現れる候補の今 | |
66 使ったよ ビットを 落としてはならない。 */ | |
67 unsigned int dai_top:1; /* 大文節の先頭 */ | |
68 unsigned int dai_end:1; /* 大文節のsaigo *//* 次候補 nomi */ | |
69 unsigned int from_zenkouho:2; /*次候補から選択された文節かどうか */ | |
70 unsigned int bug:1; /* BUG FIX とりあえず */ | |
71 /* BUG FIX signed --> unsigned */ | |
72 int hyoka; | |
73 int daihyoka; | |
74 short yomilen; | |
75 short kanjilen; | |
76 WNN_BUN *down; /* 今使ったよビットを落とす対象の文節 */ | |
77 w_char yomi[WNN_YOMI_SIZE]; /* 読み、漢字が入る。入り切らない時には | |
78 次につなげる */ | |
79 WNN_BUN *next; /* 次のストラクトへのポインタ */ | |
80 WNN_BUN *free_next; /* 次のストラクトへのポインタ */ | |
81 }; | |
82 | |
83 | |
84 struct wnn_buf | |
85 { | |
86 struct wnn_env *env; /* 環境 */ | |
87 int bun_suu; /* 文節数 */ | |
88 int zenkouho_suu; /* 全候補の数 */ | |
89 WNN_BUN **bun; /* 文節へのポインタ */ | |
90 WNN_BUN **down_bnst; /* 今使ったよビットを落とす対象の文節 */ | |
91 | |
92 WNN_BUN **zenkouho; /* 全候補へのポインタ */ | |
93 int *zenkouho_dai; /* daibunsetsu zenkouho */ | |
94 int zenkouho_dai_suu; /* daibunsetsu zenkouho suu */ | |
95 | |
96 short c_zenkouho; /* 全候補中、注目している候補 */ | |
97 short zenkouho_daip; | |
98 int zenkouho_bun; /* 全候補を取っている文節 */ | |
99 int zenkouho_end_bun; /* 全候補(dai)を取っている最後の文節 */ | |
100 int zenkouho_endvect; /* 全候補を取った endvect *//* ADD KURI */ | |
101 | |
102 WNN_BUN *free_heap; | |
103 char *heap; /* linked list of alloced area */ | |
104 int msize_bun; | |
105 int msize_zenkouho; | |
106 }; | |
107 | |
108 | |
109 #define WNN_SHO 0 | |
110 #define WNN_DAI 1 | |
111 | |
112 #define WNN_NO_USE 0 | |
113 #define WNN_USE_MAE 1 | |
114 #define WNN_USE_ATO 2 | |
115 #define WNN_USE_ZENGO (WNN_USE_MAE | WNN_USE_ATO) | |
116 /* #define WNN_ZENGO_YUUSEN 4 */ | |
117 | |
118 #define WNN_UNIQ_KNJ 2 | |
119 #define WNN_UNIQ 1 | |
120 #define WNN_NO_UNIQ 0 | |
121 | |
122 #define WNN_NO_CREATE 0 | |
123 #define WNN_CREATE (-1) | |
124 | |
125 #define WNN_DIC_PRIO_DEFAULT 5 | |
126 | |
127 #define WNN_YOMI 0 | |
128 #define WNN_KANJI 1 | |
129 | |
130 #define jl_next(buf) jl_set_jikouho((buf), (buf)->c_zenkouho + 1) | |
131 | |
132 #define jl_previous(buf) jl_set_jikouho((buf), (buf)->c_zenkouho - 1) | |
133 | |
134 #define jl_next_dai(buf) jl_set_jikouho_dai((buf), (buf)->c_zenkouho + 1) | |
135 | |
136 #define jl_previous_dai(buf) jl_set_jikouho_dai((buf), (buf)->c_zenkouho - 1) | |
137 | |
138 #define jl_get_kanji(buf, bun_no, bun_no2, area)\ | |
139 wnn_get_area(buf, bun_no, bun_no2, area, WNN_KANJI) | |
140 | |
141 #define jl_get_yomi(buf, bun_no, bun_no2, area)\ | |
142 wnn_get_area(buf, bun_no, bun_no2, area, WNN_YOMI) | |
143 | |
144 #define jl_bun_suu(buf) ((buf)->bun_suu) | |
145 | |
146 #define jl_zenkouho_suu(buf) ((buf)->zenkouho_daip? (buf)->zenkouho_dai_suu:(buf)->zenkouho_suu) | |
147 | |
148 #define jl_zenkouho_bun(buf) ((buf)->zenkouho_bun) | |
149 | |
150 #define jl_c_zenkouho(buf) ((buf)->c_zenkouho) | |
151 | |
152 #define jl_zenkouho_daip(buf) ((buf)->zenkouho_daip) | |
153 | |
154 #define jl_dai_top(buf, k) ((buf)->bun[k]->dai_top) | |
155 | |
156 #define jl_jiri_len(buf, k) ((buf)->bun[k]->jirilen) | |
157 | |
158 #define jl_fuzoku_len(buf, k) \ | |
159 (jl_yomi_len((buf), k, k+1) - jl_jiri_len((buf), k)) | |
160 | |
161 #define jl_jiri_kanji_len(buf, k) \ | |
162 (jl_kanji_len((buf), k, k+1) - jl_fuzoku_len((buf), k)) | |
163 | |
164 /* Macros to create library functions from "_e" libraries */ | |
165 | |
166 #define jl_env(buf) ((buf)->env) | |
167 | |
168 #define jl_dic_add(buf,dic_name,hindo_name,rev, prio,rw, hrw, pwd_dic, pwd_hindo, error_handler, message_handler)\ | |
169 jl_dic_add_e(jl_env(buf),dic_name,hindo_name,rev,prio,rw, hrw, pwd_dic,\ | |
170 pwd_hindo, error_handler, message_handler) | |
171 | |
172 #define jl_fuzokugo_set(buf, fname) jl_fuzokugo_set_e(jl_env(buf), fname) | |
173 | |
174 #define jl_fuzokugo_get(buf, fname) jl_fuzokugo_get_e(jl_env(buf), fname) | |
175 | |
176 | |
177 #define jl_dic_save(buf,dic_no) jl_dic_save_e(jl_env(buf),dic_no) | |
178 | |
179 #define jl_dic_save_all(buf) jl_dic_save_all_e(jl_env(buf)) | |
180 | |
181 #define jl_dic_list(buf, dip) jl_dic_list_e(jl_env(buf), dip) | |
182 | |
183 #define jl_word_search(buf,dic_no, yomi, jdp) \ | |
184 jl_word_search_e(jl_env(buf),dic_no, yomi, jdp) | |
185 | |
186 #define jl_word_search_by_env(buf, yomi, jdp) \ | |
187 jl_word_search_by_env_e(jl_env(buf), yomi, jdp) | |
188 | |
189 #define jl_word_use(buf, dic_no, entry) \ | |
190 jl_word_use_e(jl_env(buf), dic_no, entry) | |
191 | |
192 | |
193 #define jl_param_set(buf, param) jl_param_set_e(jl_env(buf), param) | |
194 | |
195 #define jl_param_get(buf, param) jl_param_get_e(jl_env(buf), param) | |
196 | |
197 #define jl_dic_delete(buf, dic_no) jl_dic_delete_e(jl_env(buf), dic_no) | |
198 | |
199 #define jl_dic_use(buf, dic_no, flag) jl_dic_use_e(jl_env(buf), dic_no, flag) | |
200 | |
201 #define jl_word_add(buf, dic, yomi, kanji, com, hinsi, hindo) \ | |
202 jl_word_add_e(jl_env(buf), dic, yomi, kanji, com, hinsi, hindo) | |
203 | |
204 #define jl_word_delete(buf, dic, entry)\ | |
205 jl_word_delete_e(jl_env(buf), dic, entry) | |
206 | |
207 #define jl_word_info(buf, dic_no, entry)\ | |
208 jl_word_info_e(jl_env(buf), dic_no, entry) | |
209 | |
210 #define jl_inspect(buf, bun_no)\ | |
211 jl_word_info(buf, (buf)->bun[bun_no]->dic_no,(buf)->bun[bun_no]->entry) | |
212 | |
213 #define jl_hinsi_number(buf, name) jl_hinsi_number_e(jl_env(buf), name) | |
214 | |
215 #define jl_hinsi_name(buf, no) jl_hinsi_name_e(jl_env(buf), no) | |
216 | |
217 #define jl_word_comment_set(buf, dic, entry, comm) \ | |
218 jl_word_comment_set_e((buf)->env, dic, entry, comm) | |
219 | |
220 #define jl_dic_comment_set(buf, dic, comm) \ | |
221 jl_dic_comment_set_e((buf)->env, dic, comm) | |
222 | |
223 #define jl_hinsi_list(buf, dic_no, name, area) \ | |
224 jl_hinsi_list_e(jl_env(buf), dic_no, name, area) | |
225 | |
226 #define jl_hinsi_dicts(buf, no, area) \ | |
227 jl_hinsi_dicts_e(jl_env(buf), no, area) | |
228 | |
229 #ifdef nodef /*当面の間、頻度ファイルのコメントはユーザに見せない。 */ | |
230 #define jl_hindo_comment_set(buf, dic, comm) \ | |
231 jl_hindo_comment_set_e((buf)->env, dic, comm) | |
232 #endif | |
233 | |
234 #define jl_isconnect(buf) jl_isconnect_e((buf)->env) | |
235 | |
236 #define jl_env_sticky(buf) js_env_sticky((buf)->env) | |
237 #define jl_env_sticky_e(env) js_env_sticky(env) | |
238 #define jl_env_un_sticky(buf) js_env_un_sticky((buf)->env) | |
239 #define jl_env_un_sticky_e(env) js_env_un_sticky(env) | |
240 | |
241 /* for select server by useing $LANG */ | |
242 #define jl_open(env_n, server_n, wnnrc_n, error_handler, message_handler, timeout) \ | |
243 jl_open_lang(env_n, server_n, NULL, wnnrc_n, error_handler, message_handler, timeout) | |
244 | |
245 #define jl_connect(env_n, server_n, wnnrc_n, error_handler, message_handler, timeout) \ | |
246 jl_connect_lang(env_n, server_n, NULL, wnnrc_n, error_handler, message_handler, timeout) | |
247 #define jl_get_lang(buf) js_get_lang((buf)->env) | |
248 #define jl_set_lang(buf, lang) js_set_lang((buf)->env, lang) | |
249 | |
250 /* extern function defines */ | |
251 extern struct wnn_buf *jl_open_lang (); | |
252 extern struct wnn_env *jl_connect_lang (); | |
253 extern struct wnn_env *jl_env_get (); | |
254 extern struct wnn_jdata *jl_word_info_e (); | |
255 extern w_char *jl_hinsi_name_e (); | |
256 | |
257 extern void jl_close (); | |
258 extern int jl_dic_add_e (); | |
259 extern int jl_dic_comment_set_e (); | |
260 extern int jl_dic_delete_e (); | |
261 extern int jl_dic_list_e (); | |
262 extern int jl_dic_save_all_e (); | |
263 extern int jl_dic_save_e (); | |
264 extern int jl_dic_use_e (); | |
265 extern void jl_disconnect (); | |
266 extern void jl_disconnect_if_server_dead (); | |
267 extern void jl_env_set (); | |
268 extern int jl_fuzokugo_get_e (); | |
269 extern int jl_fuzokugo_set_e (); | |
270 extern void jl_get_zenkouho_kanji (); | |
271 extern int jl_hinsi_dicts_e (); | |
272 extern int jl_hinsi_list_e (); | |
273 extern int jl_hinsi_number_e (); | |
274 extern int jl_isconnect_e (); | |
275 extern int jl_kanji_len (); | |
276 extern int jl_kill (); | |
277 extern int jl_nobi_conv (); | |
278 extern int jl_nobi_conv_e2 (); | |
279 extern int jl_param_get_e (); | |
280 extern int jl_param_set_e (); | |
281 extern int jl_ren_conv (); | |
282 extern int jl_set_env_wnnrc (); | |
283 extern int jl_set_env_wnnrc1 (); | |
284 extern int jl_set_jikouho (); | |
285 extern int jl_set_jikouho_dai (); | |
286 extern int jl_tan_conv (); | |
287 extern int jl_update_hindo (); | |
288 extern int jl_word_add_e (); | |
289 extern int jl_word_comment_set_e (); | |
290 extern int jl_word_delete_e (); | |
291 extern int jl_word_search_by_env_e (); | |
292 extern int jl_word_search_e (); | |
293 extern int jl_word_use_e (); | |
294 extern int jl_yomi_len (); | |
295 extern int jl_zenkouho (); | |
296 extern int jl_zenkouho_dai (); | |
297 extern int wnn_get_area (); | |
298 | |
299 extern char *wnn_perror (); | |
300 extern char *wnn_perror_lang (); | |
301 | |
302 #ifdef CONVERT_by_STROKE | |
303 extern void jl_get_zenkouho_yomi (); | |
304 #endif | |
305 | |
306 #endif /* WNN_JLLIB_H */ |