2 * ¥³¡¼¥Ñ¥¹¤È¤Ê¤ëʸ¾Ï¤òÆɤó¤Ç¡¢Ê¸Àá¤ÎŤµ¤òÄ´À°¤·¤Æ
3 * ·ÁÂÖÁDzòÀϤηë²Ì¤ò½ÐÎϤ¹¤ë
6 * ¤Þ¤º¿½Ì¤ò¹Ô¤Ã¤¿Ê¸À᤬ºÇ½é¤ÎŤµ¤Ç½ÐÎϤµ¤ì¤ë
7 * ¼¡¤Ë³ÆʸÀáËè¤Ë(¤¢¤ì¤Ð)¸í¤Ã¤¿¸õÊä¡¢Àµ¤·¤¤¸õÊä¤Î½ç¤Ç¾ðÊó¤ò½ÐÎϤ¹¤ë
10 * Copyright (C) 2006-2007 TABATA Yusuke
16 #include <anthy/convdb.h>
20 /* ʸÀá¤ÎŤµ¤òÎãʸ¤Ë¤¢¤ï¤»¤ë */
22 trim_segment(anthy_context_t ac, struct conv_res *cr,
25 int len = strlen(seg);
33 anthy_get_segment(ac, nth, NTH_UNCONVERTED_CANDIDATE, seg_buf, 1024);
34 cur_len = strlen(seg_buf);
40 /* ¿½ÌÁ°¤ÎʸÀá¤Î¾ðÊó¤òɽ¼¨¤¹¤ë */
41 print_size_miss_segment_info(ac, nth);
44 anthy_resize_segment(ac, nth, 1);
46 anthy_resize_segment(ac, nth, -1);
53 * nthÈÖÌܤÎʸÀá¤Ç¸õÊäseg¤òõ¤·¤Æ³ÎÄꤹ¤ë
56 find_candidate(anthy_context_t ac, struct conv_res *cr,
61 struct anthy_segment_stat ass;
64 /* ¸õÊä¥ß¥¹¤Î¥Þ¡¼¥¯¡Ö~¡×¤ò¥¹¥¥Ã¥×¤¹¤ë */
66 cr->cand_check[nth] = 1;
69 anthy_get_segment_stat(ac, nth, &ass);
70 for (i = 0; i < ass.nr_candidate; i++) {
71 anthy_get_segment(ac, nth, i, seg_buf, 1024);
72 if (!strcmp(seg_buf, seg)) {
73 /* °ìÃפ¹¤ë¸õÊä¤ò¸«¤Ä¤±¤¿¤Î¤Ç³ÎÄꤹ¤ë */
74 anthy_commit_segment(ac, nth, i);
81 /* '|' ¤ÇʸÀá¤Ë¶èÀÚ¤é¤ì¤¿Ê¸»úÎó¤Î³ÆʸÀá¤ò°ú¿ô¤Ëfn¤ò¸Æ¤Ö */
83 for_each_segment(anthy_context_t ac, struct conv_res *cr,
85 int (*fn)(anthy_context_t ac, struct conv_res *cr,
88 char *str, *cur, *cur_seg;
94 str = strdup(res_str);
99 while ((cur = strchr(cur, '|'))) {
103 fn(ac, cr, nth, cur_seg);
117 proc_sentence(anthy_context_t ac, struct conv_res *cr)
120 struct anthy_conv_stat acs;
121 /*printf("(%s)\n", cr->src_str);*/
122 anthy_set_string(ac, cr->src_str);
123 /* ʸÀá¤ÎŤµ¤òÄ´À᤹¤ë */
124 if (!for_each_segment(ac, cr, cr->res_str, trim_segment)) {
128 if (anthy_get_stat(ac, &acs)) {
131 cr->cand_check = malloc(sizeof(int) * acs.nr_segment);
132 for (i = 0; i < acs.nr_segment; i++) {
133 cr->cand_check[i] = 0;
138 for_each_segment(ac, cr, cr->cand_str, find_candidate);
142 anthy_print_context(ac);
145 print_context_info(ac, cr);
149 main(int argc, char **argv)
157 for (i = 1; i < argc; i++) {
158 if (!strcmp("-v", argv[i])) {
161 read_db(db, argv[i]);
165 anthy_conf_override("CONFFILE", "../anthy-conf");
166 anthy_conf_override("DIC_FILE", "../mkanthydic/anthy.dic");
168 anthy_set_personality("");
169 ac = anthy_create_context();
172 for (cr = db->res_list.next; cr; cr = cr->next) {
173 proc_sentence(ac, cr);