2 * ¸õÊä¤Î¸ò´¹¤Î¥Ò¥¹¥È¥ê¤ò´ÉÍý¤¹¤ë¡£
4 * anthy_swap_cand_ent() ¤Ç³Ø½¬¤¹¤ë
5 * anthy_proc_swap_candidate() ¤Ç³Ø½¬·ë²Ì¤òÍѤ¤¤ë
7 * ¡ÖÅÄü¤¬¡×¤È¤¤¤¦¸õÊä¤ò¥È¥Ã¥×¤Ë½Ð¤·¤Æ¡ÖÅÄȪ¤¬¡×¤Ç³ÎÄꤵ¤ì¤¿¾ì¹ç¤Ï
8 * ¼«Î©¸ìÉô:¡ÖÅÄü¡×->¡ÖÅÄȪ¡×
9 * ¤ÎÆó¤Ä¤Î¥¨¥ó¥È¥ê¤òÄɲ乤ë
14 #include <anthy/record.h>
15 #include <anthy/segment.h>
16 /* for OCHAIRE_SCORE */
17 #include <anthy/splitter.h>
20 #define MAX_INDEP_PAIR_ENTRY 100
22 /* ¸õÊä¤Î¼«Î©¸ìÉô¤ò³Ø½¬¤¹¤ë */
24 learn_swap_cand_indep(struct cand_ent *o, struct cand_ent *n)
28 int o_idx = o->core_elm_index;
29 int n_idx = n->core_elm_index;
31 /* ¼«Î©¸ìÉô¤ò´Þ¤àʸÀᤷ¤«³Ø½¬¤·¤Ê¤¤ */
32 if (o_idx < 0 || n_idx < 0) {
35 if (o->elm[o_idx].str.len != n->elm[n_idx].str.len) {
38 if (o->elm[o_idx].nth == -1 || n->elm[n_idx].nth == -1) {
41 res = anthy_get_nth_dic_ent_str(o->elm[o_idx].se, &o->elm[o_idx].str,
42 o->elm[o_idx].nth, &os);
46 res = anthy_get_nth_dic_ent_str(n->elm[n_idx].se, &n->elm[n_idx].str,
47 n->elm[n_idx].nth, &ns);
52 if (anthy_select_section("INDEPPAIR", 1) == 0) {
53 if (anthy_select_row(&os, 1) == 0) {
54 anthy_set_nth_xstr(0, &ns);
62 * ¸õÊäo ¤ò½Ð¤·¤¿¤én ¤¬¥³¥ß¥Ã¥È¤µ¤ì¤¿¤Î¤Ç
63 * o -> n ¤òrecord¤Ë¥»¥Ã¥È¤¹¤ë
66 anthy_swap_cand_ent(struct cand_ent *o, struct cand_ent *n)
72 if (n->flag & CEF_USEDICT) {
73 /* ÍÑÎã¼½ñ¤«¤é½Ð¤Æ¤¤¿¸õÊä */
77 learn_swap_cand_indep(o, n);
82 * ÊÑ´¹»þ¤ËÀ¸À®¤·¤¿¸õÊä¤òʤ٤¿¾õÂ֤ǺÇÍ¥Àè¤Î¸õÊä¤ò·è¤á¤ë
83 * ¥ë¡¼¥×¤Î½üµî¤Ê¤É¤â¹Ô¤¦
86 prepare_swap_candidate(xstr *target)
89 if (anthy_select_row(target, 0) == -1) {
92 xs = anthy_get_nth_xstr(0);
96 /* Âè°ì¸õÊä -> xs ¤È¤Ê¤ë¤Î¤òȯ¸« */
97 anthy_mark_row_used();
98 if (anthy_select_row(xs, 0) != 0){
103 n = anthy_get_nth_xstr(0);
108 if (!anthy_xstrcmp(target, n)) {
109 /* Âè°ì¸õÊä -> xs -> n ¤Ç n = Âè°ì¸õÊä¤Î¥ë¡¼¥× */
110 anthy_select_row(target, 0);
112 anthy_select_row(xs, 0);
114 /* Âè°ì¸õÊä -> xs ¤ò¾Ã¤·¤Æ¡¢¸ò´¹¤ÎɬÍפÏ̵¤· */
117 /* Âè°ì¸õÊä -> xs -> n ¤Ç n != Âè°ì¸õÊä¤Ê¤Î¤Ç
118 * Âè°ì¸õÊä -> n¤òÀßÄê
120 if (anthy_select_row(target, 0) == 0){
121 anthy_set_nth_xstr(0, n);
126 #include <src-worddic/dic_ent.h>
132 proc_swap_candidate_indep(struct seg_ent *se)
139 struct cand_elm *core_elm;
141 core_elm_idx = se->cands[0]->core_elm_index;
142 if (core_elm_idx < 0) {
146 /* 0ÈÖÌܤθõÊä¤Îʸ»úÎó¤ò¼è¤ê½Ð¤¹ */
147 core_elm = &se->cands[0]->elm[core_elm_idx];
148 if (core_elm->nth < 0) {
151 res = anthy_get_nth_dic_ent_str(core_elm->se,
160 anthy_select_section("INDEPPAIR", 1);
161 xs = prepare_swap_candidate(&key);
167 /* Âè°ì¸õÊä -> xs ¤Ê¤Î¤Ç xs¤Î¸õÊä¤òõ¤¹ */
168 for (i = 1; i < se->nr_cands; i++) {
169 if (se->cands[i]->nr_words == se->cands[0]->nr_words &&
170 se->cands[i]->core_elm_index == core_elm_idx) {
172 res = anthy_get_nth_dic_ent_str(se->cands[i]->elm[core_elm_idx].se,
173 &se->cands[i]->elm[core_elm_idx].str,
174 se->cands[i]->elm[core_elm_idx].nth,
177 !anthy_xstrcmp(&cand, xs)) {
179 /* ¤ß¤Ä¤±¤¿¤Î¤Ç¤½¤Î¸õÊä¤Î¥¹¥³¥¢¤ò¥¢¥Ã¥× */
180 se->cands[i]->score = se->cands[0]->score + 1;
189 * ÊÑ´¹»þ¤ËÀ¸À®¤·¤¿¸õÊä¤òʤ٤¿¾õÂ֤ǺÇÍ¥Àè¤Î¸õÊä¤ò·è¤á¤ë
192 anthy_proc_swap_candidate(struct seg_ent *seg)
194 if (NULL == seg->cands) { /* ¼½ñ¤â¤·¤¯¤Ï³Ø½¬¥Ç¡¼¥¿¤¬²õ¤ì¤Æ¤¤¤¿»þ¤ÎÂкö */
198 if (seg->cands[0]->score >= OCHAIRE_SCORE) {
199 /* cands[0] ¤ÏÆÃÊ̤ÊÅÀ¿ô¤ò»ý¤Ã¤Æ¤¤¤ë */
202 if (seg->cands[0]->flag & CEF_USEDICT) {
206 proc_swap_candidate_indep(seg);
209 /* ¸õÊä¸ò´¹¤Î¸Å¤¤¥¨¥ó¥È¥ê¤ò¾Ã¤¹ */
211 anthy_cand_swap_ageup(void)
213 if (anthy_select_section("INDEPPAIR", 0) == 0) {
214 anthy_truncate_section(MAX_INDEP_PAIR_ENTRY);