File: relation.c

package info (click to toggle)
anthy 6300d-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 7,400 kB
  • ctags: 2,270
  • sloc: ansic: 17,009; sh: 13,554; lisp: 1,039; makefile: 252; ruby: 212; perl: 10
file content (93 lines) | stat: -rw-r--r-- 2,112 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
 * ʸδط
 * Copyright (C) 2002-2004 TABATA Yusuke
 */

#include <stdlib.h>

#include <segclass.h>
#include <segment.h>
#include <ordering.h>
#include <dic.h>
#include <hash_map.h>
#include "sorter.h"

static void
reorder_candidate(int from_word_id, struct seg_ent *seg)
{
  int i, pos;
  struct cand_ent *ce = seg->cands[0];
  if (ce->core_elm_index == -1) {
    return ;
  }
  /* 0ܤθʻ */
  pos = anthy_wtype_get_pos(ce->elm[ce->core_elm_index].wt);

  for (i = 0; i < seg->nr_cands; i++) {
    int word_id;
    ce = seg->cands[i];
    if (ce->core_elm_index == -1) {
      continue;
    }
    word_id = ce->elm[ce->core_elm_index].id;
    if (anthy_dic_check_word_relation(from_word_id, word_id) &&
	anthy_wtype_get_pos(ce->elm[ce->core_elm_index].wt) == pos) {
      /* ˥ޥåΤǡΥ򹹿 */
      ce->flag |= CEF_USEDICT;
      ce->score *= 10;
    }
  }
}

/*
 * ѤƸ¤ؤ
 *  @nthܰʹߤʸоݤȤ
 */
void
anthy_reorder_candidates_by_relation(struct segment_list *sl, int nth)
{
  int i;
  for (i = nth; i < sl->nr_segments; i++) {
    int j;
    struct seg_ent *cur_seg;
    struct cand_ent *ce;
    int word_id;
    cur_seg = anthy_get_nth_segment(sl, i);
    if (cur_seg->cands[0]->core_elm_index == -1) {
      /* ܤθ䤬seq_ent줿ǤϤʤ */
      continue;
    }
    ce = cur_seg->cands[0];
    word_id = ce->elm[ce->core_elm_index].id;
    if (word_id == -1) {
      /**/
      continue;
    }
    /* ʸ˸Ƥ */
    for (j = i - 2; j < i + 2 && j < sl->nr_segments; j++) {
      struct seg_ent *target_seg;
      if (j < 0 || j == i) {
	continue;
      }
      /* iܤʸjܤʸФ */
      target_seg = anthy_get_nth_segment(sl, j);
      reorder_candidate(word_id, target_seg);
    }
  }
}

void
anthy_init_ordering_context(struct segment_list *sl,
			    struct ordering_context_wrapper *cw)
{
  (void)sl;
  (void)cw;
}

void
anthy_release_ordering_context(struct segment_list *sl,
			       struct ordering_context_wrapper *cw)
{
  (void)sl;
  (void)cw;
}