1 /* segment(文節) の定義 */
2 #ifndef _segment_h_included_
3 #define _segment_h_included_
4 
5 #include <anthy/segclass.h>
6 #include <anthy/wtype.h>
7 #include <anthy/xstr.h>
8 #include <anthy/dic.h>
9 
10 /** 候補の構成要素 */
11 struct cand_elm {
12   int nth; /* -1のときは辞書からの割り当てをやっていない */
13   wtype_t wt;
14   seq_ent_t se;
15   int ratio;/* 頻度を評価する際に使用する比率 */
16   xstr str;/* 変換対象の文字列 */
17   int id;/* 変換結果の文字列に対するhash値 */
18 };
19 
20 /** 一つの候補に相当する。
21  * anthy_release_cand_ent()で解放する
22  */
23 struct cand_ent {
24   /** 候補のスコア */
25   int score;
26   /** 変換後の文字列 */
27   xstr str;
28   /** 要素の数 */
29   int nr_words;
30   /** 候補を構成する要素の配列 */
31   struct cand_elm *elm;
32   /** 自立語部のインデックス */
33   int core_elm_index;
34   /** 付属語のhash値 */
35   int dep_word_hash;
36   /** 候補のフラグ CEF_? */
37   unsigned int flag;
38   struct meta_word *mw;
39 };
40 
41 /* 候補(cand_ent)のフラグ */
42 #define CEF_NONE           0
43 #define CEF_OCHAIRE        0x00000001
44 #define CEF_SINGLEWORD     0x00000002
45 #define CEF_HIRAGANA       0x00000004
46 #define CEF_KATAKANA       0x00000008
47 #define CEF_GUESS          0x00000010
48 #define CEF_USEDICT        0x00000020
49 #define CEF_COMPOUND       0x00000040
50 #define CEF_COMPOUND_PART  0x00000080
51 #define CEF_BEST           0x00000100
52 #define CEF_CONTEXT        0x00000200
53 
54 /** Context内に存在する文節の列
55  * release_seg_entで解放する
56  */
57 struct seg_ent {
58   /* strの実体はcontext中にある */
59   xstr str;
60   /* commitされた候補の番号、負の数の場合はまだコミットされていない */
61   int committed;
62 
63   /* 候補の配列 */
64   int nr_cands;/* 候補の数 */
65   struct cand_ent **cands;/* 配列 */
66 
67   int from, len;/* len == str.len */
68 
69   /* 文節の構成 */
70   int nr_metaword;
71   struct meta_word **mw_array;
72 
73   /* 一番成績の良かったクラス */
74   enum seg_class best_seg_class;
75   /* 一番成績の良かったmeta_word
76    * mw_array中にも、含まれることが期待できるが、保証はしない */
77   struct meta_word *best_mw;
78 
79   struct seg_ent *prev, *next;
80 };
81 
82 /** 文節のリスト */
83 struct segment_list {
84   int nr_segments;
85   struct seg_ent list_head;
86 };
87 
88 /* 候補を解放する(無駄に生成してしまったもの等) */
89 void anthy_release_cand_ent(struct cand_ent *s);
90 
91 /**/
92 struct seg_ent *anthy_get_nth_segment(struct segment_list *c, int );
93 void anthy_print_candidate(struct cand_ent *ce);
94 
95 /* compose.c */
96 /* 候補を作り出す */
97 struct splitter_context;
98 void anthy_do_make_candidates(struct splitter_context *sc,
99 			      struct seg_ent *e, int is_reverse);
100 
101 #endif
102