0
|
1 /*
|
|
2 * FreeWnn is a network-extensible Kana-to-Kanji conversion system.
|
|
3 * This file is part of FreeWnn.
|
|
4 *
|
|
5 * Copyright Kyoto University Research Institute for Mathematical Sciences
|
|
6 * 1987, 1988, 1989, 1990, 1991, 1992
|
|
7 * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1999
|
|
8 * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992
|
|
9 * Copyright FreeWnn Project 1999, 2000, 2002
|
|
10 *
|
|
11 * Maintainer: FreeWnn Project <freewnn@tomo.gr.jp>
|
|
12 *
|
|
13 * This program is free software; you can redistribute it and/or modify
|
|
14 * it under the terms of the GNU General Public License as published by
|
|
15 * the Free Software Foundation; either version 2 of the License, or
|
|
16 * (at your option) any later version.
|
|
17 *
|
|
18 * This program is distributed in the hope that it will be useful,
|
|
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21 * GNU General Public License for more details.
|
|
22 *
|
|
23 * You should have received a copy of the GNU General Public License
|
|
24 * along with this program; if not, write to the Free Software
|
|
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
26 */
|
|
27
|
|
28 static char rcs_id[] = "$Id: renbn_kai.c,v 1.4 2002/09/01 17:13:11 hiroo Exp $";
|
|
29
|
|
30 #ifdef HAVE_CONFIG_H
|
|
31 # include <config.h>
|
|
32 #endif
|
|
33
|
|
34 /* #include <stdio.h> */ /* for debug only */
|
|
35 #include "commonhd.h"
|
|
36 #include "de_header.h"
|
|
37 #include "fzk.h"
|
|
38 #include "kaiseki.h"
|
|
39
|
|
40 static struct DSD_DBN *dcdbn_set (struct DSD_DBN *, struct DSD_SBN **, struct BZD *);
|
|
41 static struct DSD_SBN *dcdsbn_set (struct DSD_SBN *, struct SYO_BNSETSU *);
|
|
42 static int cnt_syo (struct SYO_BNSETSU *);
|
|
43 static void cnt_bzd (struct BZD *, int *, int *);
|
|
44 static int chk_yomi_endvect (int, int, int, int);
|
|
45 static int set_kata_giji_sbn (int, int, int, int, struct SYO_BNSETSU **);
|
|
46 static int set_kata_giji_bzd (int, int, int, int, struct BZD **, int);
|
|
47
|
|
48 int
|
|
49 renbn_kai (int yomi_sno, /* 解析文字列 start index */
|
|
50 int yomi_eno, /* 解析文字列 end index (end char の次) */
|
|
51 int beginvect, /* 前端ベクタ(-1:文節先頭、-2:なんでも)品詞No. */
|
|
52 #ifndef NO_FZK
|
|
53 w_char *fzkchar,
|
|
54 #endif /* NO_FZK */
|
|
55 int endvect, /* 終端ベクタ */
|
|
56 int endvect1, /* 終端ベクタ (予備) */
|
|
57 int endvect2, /* bunsetsu 終端ベクタ */
|
|
58 int kaidbno, /* 解析大文節数 */
|
|
59 int kaisbno, /* 解析小文節数 */
|
|
60 struct DSD_DBN **dsd_dbn) /* 決定大文節情報エリア pointer */
|
|
61 {
|
|
62 int dbn_cnt;
|
|
63 int sbn_cnt;
|
|
64 struct DSD_SBN *dsd_sbn; /* 決定大文節情報エリア pointer */
|
|
65
|
|
66 UINT dicidyno, /* 決定した大文節の index */
|
|
67 buncnt = 0; /* 決定した大文節数 */
|
|
68 struct BZD *rbzdptr; /* 決定の対象となるノード top pointer */
|
|
69 struct BZD *brbzdptr, /* work pointer */
|
3
|
70 *dicide_bp = NULL, /* 決定した大文節の top pointer */
|
|
71 *dicide_np = NULL, /* 決定した大文節への pointer */
|
0
|
72 *wkbzdptr, /* work pointer */
|
|
73 *maxbzd; /* 決定の対象となっている大文節の */
|
|
74 /* 最大の評価値を持つノードへの pointer */
|
|
75 int rtmknode;
|
|
76 extern int _status;
|
|
77
|
|
78 dicidyno = yomi_sno - 1;
|
3
|
79 rbzdptr = NULL;
|
0
|
80 rtmknode = 1;
|
|
81
|
|
82 _status = 0;
|
|
83
|
|
84 if (c_env->fzk_fid == -1)
|
|
85 {
|
|
86 wnn_errorno = WNN_FZK_FILE_NO_LOAD;
|
|
87 return (-1);
|
|
88 }
|
|
89 ft = (struct FT *) files[c_env->fzk_fid].area;
|
|
90 if (chk_yomi_endvect (yomi_sno, yomi_eno, endvect, endvect1) < 0)
|
|
91 return (-1);
|
|
92 while (dicidyno + 1 < yomi_eno)
|
|
93 {
|
3
|
94 if (rbzdptr == NULL)
|
0
|
95 {
|
|
96 if (dbn_kai (dicidyno + 1, yomi_eno, beginvect,
|
|
97 #ifndef NO_FZK
|
|
98 fzkchar,
|
|
99 #endif /* NO_FZK */
|
|
100 endvect, endvect1, kaisbno, &rbzdptr) < 0)
|
|
101 {
|
|
102 log_err ("CONVERSION ERROR.");
|
|
103 init_work_areas ();
|
|
104 return (-1); /* ERROR */
|
|
105 }
|
3
|
106 if (rbzdptr == NULL)
|
0
|
107 {
|
|
108 if (set_kata_giji_bzd (dicidyno + 1, yomi_eno, endvect, endvect1, &rbzdptr, buncnt) < 0)
|
|
109 return (-1);
|
|
110 buncnt++;
|
|
111 rtmknode = 0;
|
3
|
112 if (dicide_bp == NULL)
|
0
|
113 dicide_bp = rbzdptr;
|
3
|
114 else if (dicide_np != NULL)
|
|
115 dicide_np->lnk_son = rbzdptr;
|
0
|
116 break;
|
|
117 }
|
|
118 }
|
|
119 /* 1 文節決定可能になるまでノードを作る */
|
|
120 if (kaidbno == 1)
|
|
121 {
|
|
122 /* 各文節の評価値の足し算(son_v)は、mknode でやるんだけど kaidbno が 1
|
|
123 つまり 1文節解析の場合は、そこを通らないからここでやろう */
|
|
124 for (brbzdptr = rbzdptr->lnk_br; brbzdptr != 0; brbzdptr = brbzdptr->lnk_br)
|
|
125 brbzdptr->son_v = brbzdptr->v_jc;
|
|
126 }
|
|
127 else
|
|
128 {
|
|
129 while ((int) (rbzdptr->kbcnt) < kaidbno && rtmknode > 0)
|
|
130 {
|
|
131 for (brbzdptr = rbzdptr; brbzdptr != 0; brbzdptr = brbzdptr->lnk_br)
|
|
132 {
|
|
133 rtmknode = mknode (brbzdptr, yomi_eno, beginvect,
|
|
134 #ifndef NO_FZK
|
|
135 fzkchar,
|
|
136 #endif /* NO_FZK */
|
|
137 endvect2, kaisbno);
|
|
138 brbzdptr->son_v /= brbzdptr->kbcnt;
|
|
139 if (rtmknode == 0)
|
|
140 {
|
|
141 brbzdptr->son_v += brbzdptr->v_jc;
|
|
142 }
|
|
143 else if (rtmknode == -1)
|
|
144 {
|
|
145 log_err ("CONVERSION ERROR.");
|
|
146 init_work_areas (); /* エラーでいいのかな */
|
|
147 return (-1); /* ERROR */
|
|
148 }
|
|
149 }
|
|
150 }
|
|
151 }
|
|
152
|
|
153 /* 最大の評価を持つノードを見つける */
|
|
154 for (brbzdptr = rbzdptr->lnk_br, maxbzd = rbzdptr; brbzdptr != 0; brbzdptr = wkbzdptr)
|
|
155 {
|
|
156 wkbzdptr = brbzdptr->lnk_br;
|
|
157 if (maxbzd->son_v <= brbzdptr->son_v)
|
|
158 {
|
|
159 clr_node (maxbzd); /* garbage collection */
|
|
160 maxbzd = brbzdptr;
|
|
161 }
|
|
162 else
|
|
163 clr_node (brbzdptr);
|
|
164 }
|
|
165
|
|
166 /* 1 文節決定 */
|
|
167 buncnt++; /* 決定文節 count up */
|
|
168 dicidyno = maxbzd->j_c; /* 決定した文節の top */
|
|
169 /* kettei sita node no link */
|
|
170 if (maxbzd->bend_m == yomi_sno)
|
|
171 {
|
|
172 dicide_bp = dicide_np = maxbzd;
|
|
173 }
|
|
174 else
|
|
175 {
|
|
176 dicide_np->lnk_son = maxbzd;
|
|
177 dicide_np = maxbzd;
|
|
178 }
|
|
179 rbzdptr = maxbzd->lnk_son;
|
|
180 }
|
|
181
|
|
182 cnt_bzd (dicide_bp, &dbn_cnt, &sbn_cnt);
|
3
|
183 if ((*dsd_dbn = get_dsd_dbn (dbn_cnt)) == NULL)
|
0
|
184 {
|
|
185 init_work_areas ();
|
|
186 return (-1);
|
|
187 }
|
3
|
188 if ((dsd_sbn = get_dsd_sbn (sbn_cnt)) == NULL)
|
0
|
189 {
|
|
190 init_work_areas ();
|
|
191 return (-1);
|
|
192 }
|
|
193
|
|
194 dcdbn_set (*dsd_dbn, &dsd_sbn, dicide_bp);
|
|
195 return (buncnt);
|
|
196 }
|
|
197
|
|
198 /************************************************************/
|
|
199 /* 単文節解析(大文節) routine */
|
|
200 /************************************************************/
|
|
201 int
|
|
202 tan_dai (int yomi_sno, /* 解析文字列 start index */
|
|
203 int yomi_eno, /* 解析文字列 end index (end char の次) */
|
|
204 int beginvect, /* 前端ベクタ(-1:文節先頭、-2:なんでも)品詞No. */
|
|
205 #ifndef NO_FZK
|
|
206 w_char *fzkchar,
|
|
207 #endif /* NO_FZK */
|
|
208 int endvect, /* 終端ベクタ */
|
|
209 int endvect1, /* 終端ベクタ */
|
|
210 int kaisbno, /* 解析小文節数 */
|
|
211 struct DSD_DBN **dsd_dbn) /* 決定大文節情報エリア pointer */
|
|
212 {
|
|
213 int dbn_cnt;
|
|
214 int sbn_cnt;
|
|
215 struct DSD_SBN *dsd_sbn; /* 決定大文節情報エリア pointer */
|
|
216 struct BZD *rbzdptr; /* 決定の対象となるノードの
|
|
217 トップポインタ */
|
|
218 struct BZD *brbzdptr, *wkbzdptr;
|
|
219 struct BZD *maxbzd; /* 決定の対象となっている文節の
|
|
220 最大の評価値を持つノードへのポインタ */
|
|
221 extern int _status;
|
|
222
|
|
223 if (c_env->fzk_fid == -1)
|
|
224 {
|
|
225 wnn_errorno = WNN_FZK_FILE_NO_LOAD;
|
|
226 return (-1);
|
|
227 }
|
|
228 ft = (struct FT *) files[c_env->fzk_fid].area;
|
|
229
|
|
230 rbzdptr = 0;
|
|
231 _status = 0;
|
|
232 if (chk_yomi_endvect (yomi_sno, yomi_eno, endvect, endvect1) < 0)
|
|
233 return (-1);
|
|
234 if (dbn_kai (yomi_sno, yomi_eno, beginvect,
|
|
235 #ifndef NO_FZK
|
|
236 fzkchar,
|
|
237 #endif /* NO_FZK */
|
|
238 endvect, endvect1, kaisbno, &rbzdptr) < 0)
|
|
239 {
|
|
240 init_work_areas ();
|
|
241 return (-1); /* ERROR */
|
|
242 }
|
|
243
|
|
244 /* 最大の評価値を持つノードを見つける */
|
|
245 for (brbzdptr = rbzdptr, maxbzd = 0; brbzdptr != 0; brbzdptr = wkbzdptr)
|
|
246 {
|
|
247 wkbzdptr = brbzdptr->lnk_br;
|
|
248 if (brbzdptr->j_c == yomi_eno - 1)
|
|
249 { /* 文節長さ */
|
3
|
250 if (maxbzd == NULL)
|
0
|
251 {
|
|
252 maxbzd = brbzdptr;
|
|
253 }
|
|
254 else if (maxbzd->v_jc < brbzdptr->v_jc)
|
|
255 {
|
|
256 freebzd (maxbzd);
|
|
257 maxbzd = brbzdptr;
|
|
258 }
|
|
259 else
|
|
260 {
|
|
261 freebzd (brbzdptr);
|
|
262 }
|
|
263 }
|
|
264 else
|
|
265 {
|
|
266 clr_node (brbzdptr);
|
|
267 }
|
|
268 }
|
|
269
|
3
|
270 if (maxbzd == NULL)
|
0
|
271 {
|
|
272 if (set_kata_giji_bzd (yomi_sno, yomi_eno, endvect, endvect1, &maxbzd, 0) < 0)
|
|
273 return (-1);
|
|
274 }
|
|
275 cnt_bzd (maxbzd, &dbn_cnt, &sbn_cnt);
|
3
|
276 if ((*dsd_dbn = get_dsd_dbn (dbn_cnt)) == NULL)
|
0
|
277 {
|
|
278 init_work_areas ();
|
|
279 return (-1);
|
|
280 }
|
3
|
281 if ((dsd_sbn = get_dsd_sbn (sbn_cnt)) == NULL)
|
0
|
282 {
|
|
283 init_work_areas ();
|
|
284 return (-1);
|
|
285 }
|
|
286
|
|
287 dcdbn_set (*dsd_dbn, &dsd_sbn, maxbzd);
|
|
288 return (1);
|
|
289 }
|
|
290
|
|
291 /************************************************************/
|
|
292 /* 単文節解析(小文節) routine */
|
|
293 /************************************************************/
|
|
294 int
|
|
295 tan_syo (int yomi_sno, /* 解析文字列 start index */
|
|
296 int yomi_eno, /* 解析文字列 end index (end char の次) */
|
|
297 int beginvect, /* 前端ベクタ(-1:文節先頭、-2:なんでも)品詞No. */
|
|
298 #ifndef NO_FZK
|
|
299 w_char *fzkchar,
|
|
300 #endif /* NO_FZK */
|
|
301 int endvect, /* 終端ベクタ */
|
|
302 int endvect1, /* 終端ベクタ */
|
|
303 struct DSD_SBN **dsd_sbn) /* 決定小文節情報エリア pointer */
|
|
304 {
|
|
305 int sbn_cnt;
|
|
306 struct SYO_BNSETSU *rsbnptr; /* 決定の対象となるノードのトップポインタ */
|
|
307 struct SYO_BNSETSU *brsbnptr, *wksbnptr;
|
|
308 struct SYO_BNSETSU *maxsbn; /* 決定の対象となっている文節の
|
|
309 最大の評価値を持つノードへのポインタ */
|
|
310 int divid;
|
|
311 extern int _status;
|
|
312
|
|
313 if (c_env->fzk_fid == -1)
|
|
314 {
|
|
315 wnn_errorno = WNN_FZK_FILE_NO_LOAD;
|
|
316 return (-1);
|
|
317 }
|
|
318 ft = (struct FT *) files[c_env->fzk_fid].area;
|
|
319
|
|
320 rsbnptr = 0;
|
|
321 _status = 0;
|
|
322 if (chk_yomi_endvect (yomi_sno, yomi_eno, endvect, endvect1) < 0)
|
|
323 return (-1);
|
|
324 if (sbn_kai (yomi_sno, yomi_eno, endvect, endvect1, &rsbnptr, 1, 0) < 0)
|
|
325 {
|
|
326 init_work_areas ();
|
|
327 return (-1); /* ERROR */
|
|
328 }
|
|
329
|
|
330 /* 最大の評価値を持つノードを見つける */
|
|
331 for (brsbnptr = rsbnptr, maxsbn = 0; brsbnptr != 0; brsbnptr = wksbnptr)
|
|
332 {
|
|
333 wksbnptr = brsbnptr->lnk_br;
|
|
334 if (brsbnptr->j_c == yomi_eno - 1)
|
|
335 { /* 文節長さ */
|
3
|
336 if (maxsbn == NULL)
|
0
|
337 {
|
|
338 maxsbn = brsbnptr;
|
|
339 divid = get_status (brsbnptr->kangovect, beginvect,
|
|
340 #ifndef NO_FZK
|
|
341 fzkchar,
|
|
342 #endif /* NO_FZK */
|
|
343 &(brsbnptr->status));
|
|
344 brsbnptr->v_jc = DIVID_HYOUKA (brsbnptr->v_jc, divid);
|
|
345 }
|
|
346 else
|
|
347 {
|
|
348 divid = get_status (brsbnptr->kangovect, beginvect,
|
|
349 #ifndef NO_FZK
|
|
350 fzkchar,
|
|
351 #endif /* NO_FZK */
|
|
352 &(brsbnptr->status));
|
|
353 brsbnptr->v_jc = DIVID_HYOUKA (brsbnptr->v_jc, divid);
|
|
354 if (beginvect != WNN_ALL_HINSI && ((brsbnptr->status == WNN_SENTOU && maxsbn->status != WNN_SENTOU) || (brsbnptr->status == WNN_CONNECT && maxsbn->status != WNN_CONNECT)))
|
|
355 {
|
|
356 freesbn (maxsbn);
|
|
357 maxsbn = brsbnptr;
|
|
358 }
|
|
359 else if (maxsbn->v_jc < brsbnptr->v_jc)
|
|
360 {
|
|
361 freesbn (maxsbn);
|
|
362 maxsbn = brsbnptr;
|
|
363 }
|
|
364 else
|
|
365 {
|
|
366 freesbn (brsbnptr);
|
|
367 }
|
|
368 }
|
|
369 }
|
|
370 else
|
|
371 {
|
|
372 freesbn (brsbnptr);
|
|
373 }
|
|
374 }
|
|
375
|
3
|
376 if (maxsbn == NULL)
|
0
|
377 {
|
|
378 if (set_kata_giji_sbn (yomi_sno, yomi_eno, endvect, endvect1, &maxsbn) < 0)
|
|
379 return (-1);
|
|
380 }
|
|
381 if (maxsbn->jentptr == 0 && maxsbn->status == WNN_NOT_CONNECT)
|
|
382 maxsbn->status = WNN_GIJI;
|
|
383 sbn_cnt = cnt_syo (maxsbn);
|
3
|
384 if ((*dsd_sbn = get_dsd_sbn (sbn_cnt)) == NULL)
|
0
|
385 {
|
|
386 init_work_areas ();
|
|
387 return (-1);
|
|
388 }
|
|
389 dcdsbn_set (*dsd_sbn, maxsbn);
|
|
390 freesbn (maxsbn);
|
|
391 return (1);
|
|
392 }
|
|
393
|
|
394 /**********************************************/
|
|
395 /* 決定した文節の情報をセットする */
|
|
396 /**********************************************/
|
|
397 static struct DSD_DBN *
|
|
398 dcdbn_set (struct DSD_DBN *dsd_dbn,
|
|
399 struct DSD_SBN **dsd_sbn,
|
|
400 struct BZD *bzd)
|
|
401 {
|
|
402 struct DSD_DBN *nextp;
|
|
403 #ifdef CONVERT_from_TOP
|
|
404 struct DSD_DBN *dsd_dbn_head;
|
|
405 struct BZD *s_bzd; /* Buffer son's bzd */
|
|
406 dsd_dbn_head = dsd_dbn;
|
|
407 while (bzd != 0)
|
|
408 {
|
|
409 nextp = dsd_dbn++;
|
|
410 nextp->bun_m = bzd->bend_m;
|
|
411 nextp->bun_jc = bzd->j_c;
|
|
412 nextp->sbncnt = bzd->sbn_cnt;
|
|
413 nextp->v_jc = bzd->v_jc;
|
|
414
|
|
415 if (bzd->sbn->status == 0)
|
|
416 bzd->sbn->status = WNN_SENTOU;
|
|
417
|
|
418 nextp->sbn = *dsd_sbn;
|
|
419 *dsd_sbn = dcdsbn_set (*dsd_sbn, bzd->sbn);
|
|
420
|
|
421 s_bzd = bzd->lnk_son;
|
|
422 freebzd (bzd);
|
|
423 bzd = s_bzd;
|
|
424 }
|
|
425 return (dsd_dbn_head);
|
|
426 #else /* CONVERT_from_TOP */
|
|
427 if (bzd == 0)
|
|
428 return (dsd_dbn);
|
|
429 nextp = dcdbn_set (dsd_dbn, dsd_sbn, bzd->lnk_son);
|
|
430 nextp->bun_m = bzd->bend_m;
|
|
431 nextp->bun_jc = bzd->j_c;
|
|
432 nextp->sbncnt = bzd->sbn_cnt;
|
|
433 nextp->v_jc = bzd->v_jc;
|
|
434
|
|
435 if (bzd->sbn->status == 0)
|
|
436 bzd->sbn->status = WNN_SENTOU;
|
|
437
|
|
438 nextp->sbn = *dsd_sbn;
|
|
439 *dsd_sbn = dcdsbn_set (*dsd_sbn, bzd->sbn);
|
|
440 freebzd (bzd);
|
|
441 return (++nextp);
|
|
442 #endif /* CONVERT_from_TOP */
|
|
443 }
|
|
444
|
|
445 static struct DSD_SBN *
|
|
446 dcdsbn_set (struct DSD_SBN *dsd_sbn,
|
|
447 struct SYO_BNSETSU *sbn)
|
|
448 {
|
|
449 if (sbn == 0)
|
|
450 return (dsd_sbn);
|
|
451 #ifdef CONVERT_from_TOP
|
|
452 dsd_sbn = dcdsbn_set (dsd_sbn, sbn->parent);
|
|
453 #endif /* CONVERT_from_TOP */
|
|
454 dsd_sbn->bun_m = sbn->bend_m;
|
|
455 dsd_sbn->bun_jc = sbn->j_c;
|
|
456 dsd_sbn->i_jc = sbn->i_jc;
|
|
457 dsd_sbn->jentptr = sbn->jentptr;
|
|
458 dsd_sbn->t_jc = sbn->t_jc;
|
|
459 dsd_sbn->hinsi = sbn->hinsi_fk;
|
|
460 dsd_sbn->kangovect = sbn->kangovect;
|
|
461 dsd_sbn->v_jc = sbn->v_jc;
|
|
462 dsd_sbn->status = sbn->status;
|
|
463 dsd_sbn->status_bkwd = sbn->status_bkwd;
|
|
464 dsd_sbn++;
|
|
465 #ifndef CONVERT_from_TOP
|
|
466 dsd_sbn = dcdsbn_set (dsd_sbn, sbn->parent);
|
|
467 #endif /* CONVERT_from_TOP */
|
|
468 return (dsd_sbn);
|
|
469 }
|
|
470
|
|
471 /* 1 大文節中の小文節の数 */
|
|
472 static int
|
|
473 cnt_syo (struct SYO_BNSETSU *sbn)
|
|
474 {
|
|
475 int cnt;
|
|
476 cnt = 0;
|
|
477 while (sbn)
|
|
478 {
|
|
479 cnt++;
|
|
480 sbn = sbn->parent;
|
|
481 }
|
|
482 return (cnt);
|
|
483 }
|
|
484
|
|
485 /* 1 大文節の数 */
|
|
486 static void
|
|
487 cnt_bzd (struct BZD *bzd,
|
|
488 int *dbn_cnt,
|
|
489 int *sbn_cnt)
|
|
490 {
|
|
491 *dbn_cnt = 0;
|
|
492 *sbn_cnt = 0;
|
|
493 while (bzd)
|
|
494 {
|
|
495 *sbn_cnt += cnt_syo (bzd->sbn);
|
|
496 (*dbn_cnt)++;
|
|
497 bzd = bzd->lnk_son;
|
|
498 }
|
|
499 }
|
|
500
|
|
501 static int
|
|
502 chk_yomi_endvect (
|
|
503 int yomi_sno, /* 解析文字列 start index */
|
|
504 int yomi_eno, /* 解析文字列 end index (end char の次) */
|
|
505 int endvect, /* 終端ベクタ */
|
|
506 int endvect1) /* 終端ベクタ */
|
|
507 {
|
|
508 if (yomi_sno == yomi_eno || (fzk_ckvt (endvect) == NO && fzk_ckvt (endvect1) == NO))
|
|
509 {
|
|
510 wnn_errorno = WNN_NO_KOUHO;
|
|
511 log_err ("chk_yomi_endvect: cannot make tan-bunsetu kouho.");
|
|
512 return (-1);
|
|
513 }
|
|
514 return (0);
|
|
515 }
|
|
516
|
|
517 static int
|
|
518 set_kata_giji_sbn (
|
|
519 int yomi_sno, /* 解析文字列 start index */
|
|
520 int yomi_eno, /* 解析文字列 end index (end char の次) */
|
|
521 int endvect, /* 終端ベクタ */
|
|
522 int endvect1, /* 終端ベクタ */
|
|
523 struct SYO_BNSETSU **sbn)
|
|
524 {
|
|
525 struct ICHBNP *ichbnpbp; /* ICHBNP のセーブ */
|
|
526 int fzkcnt;
|
|
527 int tempi;
|
|
528 int connect_flg = NO;
|
|
529
|
|
530 if (chk_yomi_endvect (yomi_sno, yomi_eno, endvect, endvect1) < 0)
|
|
531 return (-1);
|
|
532
|
|
533 fzkcnt = fzk_kai (&bun[yomi_sno], &bun[yomi_eno], endvect, endvect1, &ichbnpbp);
|
|
534 if (fzkcnt <= 0)
|
|
535 {
|
|
536 log_err ("tan_syo(): cannot make tan-bunsetu kouho.");
|
|
537 init_work_areas ();
|
|
538 return (-1); /* ERROR */
|
|
539 }
|
|
540 for (tempi = fzkcnt - 1; (int) tempi >= (int) 0; tempi--)
|
|
541 {
|
|
542 if (kan_ck_vector (giji_no, getfzkoh (ichbnpbp, tempi)->vector) == WNN_CONNECT_BK)
|
|
543 {
|
|
544 connect_flg = YES;
|
|
545 break;
|
|
546 }
|
|
547 }
|
|
548 if (tempi < 0)
|
|
549 {
|
|
550 for (tempi = fzkcnt - 1; (int) tempi >= (int) 0; tempi--)
|
|
551 {
|
|
552 if (kan_ck_vector (giji_no, getfzkoh1 (ichbnpbp, tempi)->vector) == WNN_CONNECT_BK)
|
|
553 {
|
|
554 break;
|
|
555 }
|
|
556 }
|
|
557 if (tempi < 0)
|
|
558 {
|
|
559 freeibsp (ichbnpbp);
|
|
560 wnn_errorno = WNN_NO_KOUHO;
|
|
561 log_err ("tan_syo(): cannot make tanbunsetu kouho.");
|
|
562 return (-1);
|
|
563 }
|
|
564 }
|
|
565
|
|
566 if ((*sbn = getsbnsp ()) == 0)
|
|
567 return (-1);
|
|
568
|
|
569 (*sbn)->j_c = yomi_eno - 1;
|
|
570 (*sbn)->i_jc = getfzkoh (ichbnpbp, tempi)->offset + yomi_sno;
|
|
571 (*sbn)->bend_m = yomi_sno;
|
|
572 (*sbn)->v_jc = 0;
|
|
573 (*sbn)->jentptr = 0;
|
|
574 (*sbn)->t_jc = WNN_KATAKANA;
|
|
575 (*sbn)->kangovect = ft->kango_hinsi_area[giji_no];
|
|
576 (*sbn)->hinsi_fk = giji_no;
|
|
577 (*sbn)->status = WNN_GIJI;
|
|
578 (*sbn)->status_bkwd = connect_flg;
|
|
579 freeibsp (ichbnpbp);
|
|
580 return (1);
|
|
581 }
|
|
582
|
|
583 static int
|
|
584 set_kata_giji_bzd (
|
|
585 int yomi_sno, /* 解析文字列 start index */
|
|
586 int yomi_eno, /* 解析文字列 end index (end char の次) */
|
|
587 int endvect, /* 終端ベクタ */
|
|
588 int endvect1, /* 終端ベクタ */
|
|
589 struct BZD **bzd,
|
|
590 int buncnt)
|
|
591 {
|
|
592 if ((*bzd = getbzdsp ()) == 0)
|
|
593 return (-1);
|
|
594 if (set_kata_giji_sbn (yomi_sno, yomi_eno, endvect, endvect1, &(*bzd)->sbn) < 0)
|
|
595 return (-1);
|
|
596 (*bzd)->j_c = yomi_eno - 1;
|
|
597 (*bzd)->bend_m = yomi_sno;
|
|
598 (*bzd)->v_jc = 0;
|
|
599 (*bzd)->sbn_cnt = 1;
|
|
600 (*bzd)->kbcnt = buncnt + 1;
|
|
601 return (1);
|
|
602 }
|