Mercurial > freewnn
annotate Wnn/jserver/jikouho.c @ 29:35bc1f2e3f14 default tip
minor fix
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Sat, 06 Mar 2010 23:55:24 +0900 |
parents | 466fe6732d8d |
children |
rev | line source |
---|---|
0 | 1 /* |
2 * $Id: jikouho.c,v 1.6 2002/05/12 22:51:16 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 | |
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 /************************************************ | |
33 * 小文節次候補取りだし * | |
34 ************************************************/ | |
35 #ifdef HAVE_CONFIG_H | |
36 # include <config.h> | |
37 #endif | |
38 | |
39 #include <stdio.h> | |
40 #include <ctype.h> | |
41 #if STDC_HEADERS | |
42 # include <stdlib.h> | |
43 #endif /* STDC_HEADERS */ | |
44 | |
45 #include "commonhd.h" | |
46 #include "de_header.h" | |
47 #include "jdata.h" | |
48 #include "fzk.h" | |
49 #include "kaiseki.h" | |
50 | |
51 static struct JKT_SBN *find_jktsbn (); | |
52 static int cmp_dsd_sbn (), cnt_jkt_sbn (), get_suuji_kouho (), get_eisuu_kouho (), get_kigou_kouho (); | |
53 | |
54 static int | |
55 jkt_sbn (yomi_sno, yomi_eno, endvect, endvect1, tjktsbn, bnst_num, parent) | |
56 int yomi_sno; | |
57 int yomi_eno; | |
58 int endvect; /* 終端ベクタ */ | |
59 int endvect1; /* 終端ベクタ */ | |
60 struct JKT_SBN **tjktsbn; /* 小文節解析結果 */ | |
61 int bnst_num; | |
62 struct JKT_SBN *parent; /* 親の幹語ノード */ | |
63 { | |
64 register int fzkcnt, ii, jktcnt; | |
65 register int i; | |
66 struct JKT_SBN *jktsbn; | |
67 struct JKT_SBN *jktsbn_top; | |
68 struct ICHBNP *ichbnpbp; | |
69 int cnt; | |
70 int gijiflag = 0; | |
71 | |
72 struct SYO_BNSETSU *getsbnsp (); | |
73 struct SYO_BNSETSU *giji_sbn; | |
74 | |
75 if (yomi_sno == yomi_eno) | |
76 return (NOTHING); | |
77 | |
78 jktcnt = 0; | |
79 if (fzk_ckvt (endvect) == NO && fzk_ckvt (endvect1) == NO) | |
80 return (NOTHING); | |
81 fzkcnt = fzk_kai (&bun[yomi_sno], &bun[yomi_eno], endvect, endvect1, &ichbnpbp); | |
82 if (fzkcnt <= 0) | |
83 return (fzkcnt); /* ERROR */ | |
84 for (ii = 0; ii < fzkcnt; ii++) | |
85 getfzkoh (ichbnpbp, ii)->offset += yomi_sno; | |
86 | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
87 jktsbn_top = NULL; |
0 | 88 |
89 for (ii = 0; ii < fzkcnt; ii++) | |
90 { /* 辞書引き */ | |
91 i = getfzkoh (ichbnpbp, ii)->offset; | |
92 if (jmtp[i] == (struct jdata **) UN_KNOWN) | |
93 { /* もう引いた? */ | |
94 jmt_set (i); | |
95 } | |
96 } | |
97 | |
98 if ((giji_sbn = getsbnsp ()) == NO) | |
99 return (-1); /* ERROR */ | |
100 | |
101 giji_sbn->bend_m = yomi_sno; | |
102 if (getgiji (yomi_sno, yomi_eno, giji_sbn, ichbnpbp, fzkcnt, bnst_num) >= 0) | |
103 { | |
104 if ((giji_sbn->j_c == yomi_eno - 1) && (giji_sbn->hinsi_fk != katakanago_no && giji_sbn->hinsi_fk != giji_no && giji_sbn->hinsi_fk != fuzokugo_no)) | |
105 { | |
106 if (get_zen_giji (giji_sbn, &jktsbn) < 0) | |
107 return (-1); | |
108 jktsbn->parent = parent; | |
109 jktsbn->kbcnt = bnst_num; | |
110 jktsbn_top = jktsbn; | |
111 gijiflag = 1; | |
112 jktcnt = 1; | |
113 } | |
114 } | |
115 freesbn (giji_sbn); | |
116 | |
117 if ((cnt = jkt_sbn_one (yomi_sno, yomi_eno, &jktsbn_top, bnst_num, parent, ichbnpbp, fzkcnt)) < 0) | |
118 return (-1); | |
119 jktcnt += cnt; | |
120 | |
121 #ifndef NO_KANA | |
122 if (gijiflag == 0) | |
123 { /* ひらがな候補 */ | |
124 if ((jktsbn = get_hira_kouho (&jktsbn_top, yomi_sno, yomi_eno)) < (struct JKT_SBN *) 0) | |
125 return (-1); | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
126 if (jktsbn != NULL) |
0 | 127 { |
128 jktsbn->parent = parent; | |
129 jktsbn->bend_m = yomi_sno; | |
130 jktsbn->kbcnt = bnst_num; | |
131 jktcnt++; | |
132 } | |
133 } | |
134 #endif /* NO_KANA */ | |
135 | |
136 *tjktsbn = jktsbn_top; | |
137 freeibsp (ichbnpbp); | |
138 return (jktcnt); | |
139 } | |
140 | |
141 int | |
142 jkt_sbn_one (yomi_sno, yomi_eno, jktsbn_top, bnst_num, parent, ichbnpbp, fzkcnt) | |
143 int yomi_sno; | |
144 int yomi_eno; | |
145 struct JKT_SBN **jktsbn_top; | |
146 int bnst_num; /* これまでに解析した小文節数 */ | |
147 struct JKT_SBN *parent; /* 親の幹語ノード */ | |
148 struct ICHBNP *ichbnpbp; | |
149 register int fzkcnt; | |
150 { | |
151 register int ii, hyokaval, hyokaval0, hinsidt, jktcnt; | |
152 int hinsidt_fk; /* 複合品詞のセーブ */ | |
153 unsigned short *hinsi_buf; | |
154 struct jdata *jentptr; | |
155 register int i, /* 幹語の終わりのインデックス */ | |
156 t; | |
157 struct JKT_SBN *jktsbn; | |
158 register struct JKT_SONE *jktsone; | |
159 int ll; | |
160 struct fzkkouho *fzkptr; | |
161 | |
162 int connect_flg; | |
163 | |
164 jktcnt = 0; | |
165 | |
166 for (ii = 0; ii < fzkcnt; ii++) | |
167 { /* 付属語 */ | |
168 fzkptr = getfzkoh (ichbnpbp, ii); | |
169 i = fzkptr->offset; | |
170 jentptr = (i > yomi_eno - 1) ? (struct jdata *) NULL : (struct jdata *) C (i, yomi_eno - 1); | |
171 for (; jentptr; jentptr = jentptr->jptr) | |
172 { /* 辞書 */ | |
173 for (t = 0; t < (jentptr->kosuu); t++) | |
174 { /* 幹語 */ | |
175 #ifdef CONVERT_with_SiSheng | |
176 hyokaval = hyoka1 (jentptr->hindo[t], | |
177 (jentptr->hindo_in == 0 ? 0 : jentptr->hindo_in[t]), | |
178 diff_sisheng (jentptr->sisheng[t], jentptr->sisheng_int), yomi_eno - yomi_sno / 2 - i / 2, dic_table[jentptr->jishono].nice); | |
179 #else | |
180 hyokaval = hyoka1 (jentptr->hindo[t], (jentptr->hindo_in == 0 ? 0 : jentptr->hindo_in[t]), yomi_eno - i, yomi_eno - yomi_sno, dic_table[jentptr->jishono].nice); | |
181 #endif /* CONVERT_with_SiSheng */ | |
182 hinsidt_fk = hinsidt = jentptr->hinsi[t]; | |
183 if ((ll = wnn_get_fukugou_component_body (hinsidt_fk, &hinsi_buf)) == 0) | |
184 { | |
185 error1 ("wnn_get_fukugou_component:erroe in jkt_sbn_one.\n"); | |
186 return (-1); | |
187 } | |
188 for (; ll > 0; ll--) | |
189 { | |
190 hinsidt = *hinsi_buf; | |
191 hinsi_buf++; | |
192 /* ここから後は単純品詞だけ考えればいい */ | |
193 connect_flg = kan_ck_vector (hinsidt, fzkptr->vector); | |
194 if (!(jentptr->hindo_in && (jentptr->hindo_in[t] & 0x7f) == 0x7f) && ((jentptr->hindo[t] & 0x7f) != 0x7f) && | |
195 /*コメントアウトされた辞書エントリ */ | |
196 (connect_flg != NO || (bnst_num == 1 && kan_ck_vector (hinsidt, getfzkoh1 (ichbnpbp, ii)->vector) == WNN_CONNECT_BK))) | |
197 { | |
198 | |
199 if (bnst_num == 1) | |
200 /* endvect に接続できないものは評価値を下げる */ | |
201 hyokaval0 = (connect_flg != NO) ? hyokaval : _DIVID (hyokaval, 2); | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
202 else if (parent != NULL) |
0 | 203 { |
204 /* 前の文節が endvect に接続できないものは、 | |
205 評価値を下げる */ | |
206 struct JKT_SONE *tmp; | |
207 hyokaval0 = _DIVID (hyokaval, 2); | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
208 for (tmp = parent->sbn; tmp != NULL; tmp = tmp->lnk_br) |
0 | 209 { |
210 if (tmp->status_bkwd == YES) | |
211 { | |
212 /* 実は接続できた */ | |
213 hyokaval0 = hyokaval; | |
214 break; | |
215 } | |
216 } | |
217 } | |
218 else | |
219 hyokaval0 = hyokaval; | |
220 | |
221 if ((jktsone = getjktsone ()) == NO) | |
222 return (-1); /* ERROR */ | |
223 jktsone->i_jc = i; | |
224 jktsone->v_jc = hyokaval0; | |
225 jktsone->jentptr = jentptr; | |
226 jktsone->t_jc = t; | |
227 jktsone->hinsi_fk = hinsidt_fk; | |
228 jktsone->status_bkwd = connect_flg; | |
229 if ((jktsbn = find_jktsbn (jktsbn_top, jktsone, hinsidt, yomi_eno - 1)) < (struct JKT_SBN *) 0) | |
230 return (-1); | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
231 if (jktsbn != NULL) |
0 | 232 { |
233 jktsbn->parent = parent; | |
234 jktsbn->bend_m = yomi_sno; | |
235 jktsbn->kbcnt = bnst_num; | |
236 jktcnt++; | |
237 } | |
238 } /* 接続できる */ | |
239 } /* 単純品詞 */ | |
240 } /* 幹語 */ | |
241 } /* 辞書 */ | |
242 #if !defined(NO_KANA) && !defined(KOREAN) | |
243 /* カタカナ候補 */ | |
244 if ((jktsbn = get_kata_kouho (jktsbn_top, yomi_sno, yomi_eno, i, fzkptr->vector, getfzkoh1 (ichbnpbp, ii)->vector, ii)) < (struct JKT_SBN *) 0) | |
245 return (-1); | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
246 if (jktsbn != NULL) |
0 | 247 { |
248 jktsbn->parent = parent; | |
249 jktsbn->bend_m = yomi_sno; | |
250 jktsbn->kbcnt = bnst_num; | |
251 jktcnt++; | |
252 } | |
253 #endif /* !defined(NO_KANA) && !defined(KOREAN) */ | |
254 } /* 付属語 */ | |
255 return (jktcnt); | |
256 } | |
257 | |
258 #if !defined(NO_KANA) && !defined(KOREAN) | |
259 /* カタカナ候補 */ | |
260 struct JKT_SBN * | |
261 get_kata_kouho (jktsbn_top, yomi_sno, yomi_eno, i_jc, vector, vector1, hyouka) | |
262 struct JKT_SBN **jktsbn_top; | |
263 int yomi_sno, yomi_eno, i_jc; | |
264 int *vector; | |
265 int *vector1; | |
266 int hyouka; | |
267 { | |
268 struct JKT_SONE *jktsone; | |
269 int connect_flg; | |
270 | |
271 if (!isjhira (bun[i_jc]) && !BAR_CODE (bun[i_jc]) && (i_jc + 1 == yomi_eno || !isjhira (bun[i_jc + 1]))) | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
272 return (NULL); |
0 | 273 |
274 if (i_jc != yomi_eno && !(touten (bun[i_jc])) && !(kuten (bun[i_jc]))) | |
275 { | |
276 if (kan_ck_vector (giji_no, vector) == WNN_CONNECT_BK) | |
277 { | |
278 connect_flg = WNN_CONNECT_BK; | |
279 } | |
280 else if (kan_ck_vector (giji_no, vector1) == WNN_NOT_CONNECT_BK) | |
281 { | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
282 return (NULL); |
0 | 283 } |
284 else | |
285 { | |
286 connect_flg = WNN_NOT_CONNECT_BK; | |
287 } | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
288 if ((jktsone = getjktsone ()) == NULL) |
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
289 return (NULL); |
0 | 290 jktsone->i_jc = i_jc; |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
291 jktsone->jentptr = NULL; |
0 | 292 jktsone->t_jc = WNN_KATAKANA; /* カタカナ */ |
293 jktsone->v_jc = (yomi_eno - i_jc) * KATA_HYOUKA; | |
294 jktsone->hinsi_fk = giji_no; | |
295 jktsone->status_bkwd = connect_flg; | |
296 return (find_jktsbn (jktsbn_top, jktsone, giji_no, yomi_eno - 1)); | |
297 } | |
298 else | |
299 { | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
300 return (NULL); |
0 | 301 } |
302 } | |
303 #endif /* !defined(NO_KANA) && !defined(KOREAN) */ | |
304 | |
305 struct JKT_SBN * | |
306 get_hira_kouho (jktsbn_top, yomi_sno, yomi_eno) | |
307 struct JKT_SBN **jktsbn_top; | |
308 int yomi_sno, yomi_eno; | |
309 { | |
310 struct JKT_SONE *jktsone; | |
311 | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
312 if ((jktsone = getjktsone ()) == NULL) |
0 | 313 return ((struct JKT_SBN *) -1); |
314 jktsone->i_jc = yomi_sno; | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
315 jktsone->jentptr = NULL; |
0 | 316 jktsone->t_jc = WNN_HIRAGANA; /* ひらがな候補 */ |
317 #ifdef KOREAN | |
318 jktsone->hinsi_fk = katakanago_no; /* Hangul */ | |
319 #else | |
320 jktsone->hinsi_fk = giji_no; | |
321 #endif | |
322 jktsone->v_jc = (yomi_eno - yomi_sno) * HIRA_HYOUKA; | |
323 jktsone->status_bkwd = WNN_NOT_CONNECT_BK; | |
324 return (find_jktsbn (jktsbn_top, jktsone, giji_no, yomi_eno - 1)); | |
325 } | |
326 | |
327 static struct JKT_SBN * | |
328 find_jktsbn (jktsbn, jktsone, hinsi, j_c) | |
329 struct JKT_SBN **jktsbn; | |
330 struct JKT_SONE *jktsone; | |
331 int hinsi; | |
332 int j_c; | |
333 { | |
334 register struct JKT_SBN *sbn; | |
335 struct JKT_SBN *tsbn; | |
336 register struct JKT_SONE *sone; | |
337 int v_jc; | |
338 int kangovect; | |
339 | |
340 kangovect = ft->kango_hinsi_area[hinsi]; | |
341 sbn = *jktsbn; | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
342 if (sbn == NULL || sbn->j_c != j_c || sbn->kangovect > kangovect) |
0 | 343 { |
344 if ((sbn = getjktsbn ()) == NO) | |
345 return ((struct JKT_SBN *) -1); | |
346 sbn->lnk_br = *jktsbn; | |
347 *jktsbn = sbn; | |
348 sbn->j_c = j_c; | |
349 sbn->sbn = jktsone; | |
350 sbn->kangovect = kangovect; | |
351 return (sbn); | |
352 } | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
353 while (sbn != NULL && sbn->j_c == j_c) |
0 | 354 { |
355 if (sbn->kangovect == kangovect) | |
356 { | |
357 /* 評価値で SORT */ | |
358 v_jc = jktsone->v_jc; | |
359 sone = sbn->sbn; | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
360 if (sone == NULL || sone->v_jc < v_jc) |
0 | 361 { |
362 sbn->sbn = jktsone; | |
363 jktsone->lnk_br = sone; | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
364 return NULL; |
0 | 365 } |
366 while (sone) | |
367 { | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
368 if (sone->lnk_br == NULL || sone->lnk_br->v_jc < v_jc) |
0 | 369 { |
370 jktsone->lnk_br = sone->lnk_br; | |
371 sone->lnk_br = jktsone; | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
372 return NULL; |
0 | 373 } |
374 sone = sone->lnk_br; | |
375 } | |
376 } | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
377 else if (sbn->lnk_br == NULL || sbn->lnk_br->j_c != j_c || sbn->lnk_br->kangovect > kangovect) |
0 | 378 { |
379 if ((tsbn = getjktsbn ()) == NO) | |
380 return ((struct JKT_SBN *) -1); | |
381 tsbn->lnk_br = sbn->lnk_br; | |
382 sbn->lnk_br = tsbn; | |
383 tsbn->sbn = jktsone; | |
384 tsbn->kangovect = kangovect; | |
385 tsbn->j_c = j_c; | |
386 return (tsbn); | |
387 } | |
388 sbn = sbn->lnk_br; | |
389 } | |
390 return (NULL); | |
391 } | |
392 | |
393 /************************************************** | |
394 * jkt_get_syo : 次候補 all 取りだし 小文節 | |
395 **************************************************/ | |
396 int | |
397 #ifdef NO_FZK | |
398 jkt_get_syo (yomi_sno, yomi_eno, beginvect, endvect, endvect1, dsd_sbn) | |
399 #else | |
400 jkt_get_syo (yomi_sno, yomi_eno, beginvect, fzkchar, endvect, endvect1, dsd_sbn) | |
401 #endif /* NO_FZK */ | |
402 int yomi_sno; | |
403 int yomi_eno; | |
404 int beginvect; /* 前端ベクタ(-1:文節先頭、-2:なんでも)品詞No. */ | |
405 #ifndef NO_FZK | |
406 w_char *fzkchar; | |
407 #endif /* NO_FZK */ | |
408 int endvect; /* 終端ベクタ */ | |
409 int endvect1; /* 終端ベクタ */ | |
410 struct DSD_SBN **dsd_sbn; | |
411 { | |
412 struct DSD_SBN *d_sbn; | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
413 struct JKT_SBN *tjktsbn = NULL; /* 小文節解析結果 */ |
0 | 414 register int cnt = 0; /* 次候補数 */ |
415 register struct JKT_SBN *jktsbn; | |
416 struct JKT_SBN *next_sbn; | |
417 register struct JKT_SONE *sone_p; | |
418 int sbn_cnt; | |
419 int divid; | |
420 | |
421 if (c_env->fzk_fid == -1) | |
422 { | |
423 wnn_errorno = WNN_FZK_FILE_NO_LOAD; | |
424 return (-1); | |
425 } | |
426 | |
427 ft = (struct FT *) files[c_env->fzk_fid].area; | |
428 | |
429 if (jkt_sbn (yomi_sno, yomi_eno, endvect, endvect1, &tjktsbn, 1, (struct JKT_SBN *) 0) < 0) | |
430 { | |
431 init_work_areas (); | |
432 return (-1); | |
433 } | |
434 | |
435 sbn_cnt = cnt_jkt_sbn (tjktsbn); | |
436 if ((*dsd_sbn = d_sbn = get_dsd_sbn (sbn_cnt)) <= (struct DSD_SBN *) 0) | |
437 { | |
438 init_work_areas (); | |
439 return (-1); | |
440 } | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
441 for (jktsbn = tjktsbn; jktsbn != NULL;) |
0 | 442 { |
443 next_sbn = jktsbn->lnk_br; | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
444 for (sone_p = jktsbn->sbn; sone_p != NULL; sone_p = sone_p->lnk_br) |
0 | 445 { |
446 d_sbn->bun_m = jktsbn->bend_m; | |
447 d_sbn->bun_jc = jktsbn->j_c; | |
448 d_sbn->i_jc = sone_p->i_jc; | |
449 d_sbn->jentptr = sone_p->jentptr; | |
450 d_sbn->t_jc = sone_p->t_jc; | |
451 d_sbn->hinsi = sone_p->hinsi_fk; | |
452 d_sbn->kangovect = jktsbn->kangovect; | |
453 d_sbn->status_bkwd = sone_p->status_bkwd; | |
454 divid = get_jkt_status (jktsbn->kangovect, beginvect, | |
455 #ifndef NO_FZK | |
456 fzkchar, | |
457 #endif /* NO_FZK */ | |
458 &(jktsbn->status)); | |
459 d_sbn->v_jc = DIVID_HYOUKA (sone_p->v_jc, divid); | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
460 if (sone_p->jentptr == NULL && jktsbn->status == WNN_NOT_CONNECT) |
0 | 461 d_sbn->status = WNN_GIJI; |
462 else | |
463 d_sbn->status = jktsbn->status; | |
464 cnt++; | |
465 d_sbn++; | |
466 } | |
467 freejktsbn (jktsbn); | |
468 jktsbn = next_sbn; | |
469 } | |
470 qsort ((char *) *dsd_sbn, cnt, sizeof (struct DSD_SBN), cmp_dsd_sbn); | |
471 return (cnt); | |
472 } | |
473 | |
474 static int | |
475 cmp_dsd_sbn (sbn1, sbn2) | |
476 struct DSD_SBN *sbn1; | |
477 struct DSD_SBN *sbn2; | |
478 { | |
479 return (sbn2->v_jc - sbn1->v_jc); | |
480 } | |
481 | |
482 static int | |
483 cnt_jkt_sbn (sbn) | |
484 register struct JKT_SBN *sbn; | |
485 { | |
486 register int cnt; | |
487 cnt = 0; | |
488 while (sbn) | |
489 { | |
490 cnt += cnt_sone (sbn->sbn); | |
491 sbn = sbn->lnk_br; | |
492 } | |
493 return (cnt); | |
494 } | |
495 | |
496 int | |
497 get_zen_giji (giji_sbn, jktsbn) | |
498 struct SYO_BNSETSU *giji_sbn; | |
499 struct JKT_SBN **jktsbn; | |
500 { | |
501 int hinsi; | |
502 hinsi = giji_sbn->hinsi_fk; | |
503 | |
504 if ((*jktsbn = getjktsbn ()) == NULL) | |
505 return (-1); | |
506 if (((*jktsbn)->sbn = getjktsone ()) == NULL) | |
507 return (-1); | |
508 | |
509 (*jktsbn)->j_c = giji_sbn->j_c; | |
510 (*jktsbn)->bend_m = giji_sbn->bend_m; | |
511 (*jktsbn)->kangovect = giji_sbn->kangovect; | |
512 (*jktsbn)->sbn->i_jc = giji_sbn->i_jc; | |
513 (*jktsbn)->sbn->v_jc = giji_sbn->v_jc; | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
514 (*jktsbn)->sbn->jentptr = NULL; |
0 | 515 (*jktsbn)->sbn->t_jc = giji_sbn->t_jc; |
516 (*jktsbn)->sbn->hinsi_fk = giji_sbn->hinsi_fk; | |
517 (*jktsbn)->sbn->status_bkwd = giji_sbn->status_bkwd; | |
518 | |
519 if ((*jktsbn)->sbn->hinsi_fk == fuzokugo_no) | |
520 return (1); | |
521 if (hinsi == suuji_no) | |
522 return (get_suuji_kouho (*jktsbn)); | |
523 if (isascii (bun[(*jktsbn)->sbn->i_jc])) | |
524 { | |
525 if (hinsi == eisuu_no) | |
526 return (get_eisuu_kouho (*jktsbn)); | |
527 else | |
528 return (get_kigou_kouho (*jktsbn)); | |
529 } | |
530 else | |
531 { | |
532 return (1); | |
533 } | |
534 } | |
535 | |
536 static struct JKT_SONE * | |
537 cp_sone (d_sone, s_sone) | |
538 register struct JKT_SONE *d_sone, *s_sone; | |
539 { | |
540 if ((d_sone->lnk_br = getjktsone ()) == NO) | |
541 return ((struct JKT_SONE *) -1); | |
542 d_sone = d_sone->lnk_br; | |
543 d_sone->i_jc = s_sone->i_jc; | |
544 d_sone->v_jc = s_sone->v_jc - 10; /* 第1候補より評価値を下げる */ | |
25
466fe6732d8d
- fixed more NULL pointer related errata
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
545 d_sone->jentptr = NULL; |
0 | 546 d_sone->hinsi_fk = s_sone->hinsi_fk; |
547 d_sone->status_bkwd = s_sone->status_bkwd; | |
548 return (d_sone); | |
549 } | |
550 | |
551 /* 半角数字 */ | |
552 static int | |
553 get_suuji_kouho (jktsbn) | |
554 register struct JKT_SBN *jktsbn; | |
555 { | |
556 register struct JKT_SONE *jktsone; | |
557 int hinsi; | |
558 int len; | |
559 | |
560 hinsi = jktsbn->sbn->t_jc; | |
561 len = jktsbn->j_c - jktsbn->sbn->i_jc; | |
562 if (isspace (bun[jktsbn->j_c]) || isjspace (bun[jktsbn->j_c])) | |
563 len--; | |
564 | |
565 if ((jktsone = cp_sone (jktsbn->sbn, jktsbn->sbn)) < (struct JKT_SONE *) 0) | |
566 return (-1); | |
567 | |
568 if (hinsi != WNN_NUM_HAN) | |
569 { | |
570 jktsone->t_jc = WNN_NUM_HAN; /* 半角数字 */ | |
571 if ((jktsone = cp_sone (jktsone, jktsbn->sbn)) < (struct JKT_SONE *) 0) | |
572 return (-1); | |
573 } | |
574 if (hinsi != WNN_NUM_ZEN) | |
575 { | |
576 jktsone->t_jc = WNN_NUM_ZEN; /* 123 */ | |
577 if (len < 0 && hinsi == WNN_NUM_KAN) | |
578 return (3); | |
579 if ((jktsone = cp_sone (jktsone, jktsbn->sbn)) < (struct JKT_SONE *) 0) | |
580 return (-1); | |
581 } | |
582 if (hinsi != WNN_NUM_KAN) | |
583 { | |
584 jktsone->t_jc = WNN_NUM_KAN; /* 一二三 */ | |
585 if (len < 0) | |
586 return (3); | |
587 if ((jktsone = cp_sone (jktsone, jktsbn->sbn)) < (struct JKT_SONE *) 0) | |
588 return (-1); | |
589 } | |
590 if (hinsi != WNN_NUM_KANSUUJI) | |
591 { | |
592 jktsone->t_jc = WNN_NUM_KANSUUJI; /* 百二十三 */ | |
593 if (len < 3 && hinsi == WNN_NUM_KANOLD) | |
594 return (5); | |
595 if ((jktsone = cp_sone (jktsone, jktsbn->sbn)) < (struct JKT_SONE *) 0) | |
596 return (-1); | |
597 } | |
598 if (hinsi != WNN_NUM_KANOLD) | |
599 { | |
600 jktsone->t_jc = WNN_NUM_KANOLD; /* 壱百弐拾参 */ | |
601 jktsone->v_jc -= 2; /* 評価値をちょっと下げる */ | |
602 if (len < 3) | |
603 return (5); | |
604 if ((jktsone = cp_sone (jktsone, jktsbn->sbn)) < (struct JKT_SONE *) 0) | |
605 return (-1); | |
606 } | |
607 if (hinsi != WNN_NUM_ZENCAN) | |
608 { | |
609 jktsone->t_jc = WNN_NUM_ZENCAN; /* 1,234 */ | |
610 if (hinsi == WNN_NUM_HANCAN) | |
611 return (7); | |
612 if ((jktsone = cp_sone (jktsone, jktsbn->sbn)) < (struct JKT_SONE *) 0) | |
613 return (-1); | |
614 } | |
615 jktsone->t_jc = WNN_NUM_HANCAN; /* 1,234 */ | |
616 return (7); | |
617 } | |
618 | |
619 static int | |
620 get_eisuu_kouho (jktsbn) | |
621 struct JKT_SBN *jktsbn; | |
622 { | |
623 struct JKT_SONE *jktsone; | |
624 if ((jktsone = cp_sone (jktsbn->sbn, jktsbn->sbn)) < (struct JKT_SONE *) 0) | |
625 return (-1); | |
626 | |
627 if (jktsbn->sbn->t_jc == WNN_ALP_ZEN) | |
628 jktsone->t_jc = WNN_ALP_HAN; | |
629 else | |
630 jktsone->t_jc = WNN_ALP_ZEN; | |
631 return (2); | |
632 } | |
633 | |
634 static int | |
635 get_kigou_kouho (jktsbn) | |
636 struct JKT_SBN *jktsbn; | |
637 { | |
638 struct JKT_SONE *jktsone; | |
639 if ((jktsone = cp_sone (jktsbn->sbn, jktsbn->sbn)) < (struct JKT_SONE *) 0) | |
640 return (-1); | |
641 | |
642 if (jktsbn->sbn->t_jc == WNN_KIG_JIS) | |
643 jktsone->t_jc = WNN_KIG_HAN; | |
644 else | |
645 jktsone->t_jc = WNN_KIG_JIS; | |
646 return (2); | |
647 } |