resetting manifest requested domain to floor
[platform/core/uifw/anthy.git] / src-splitter / wordborder.h
1 /* Ê¸Àᶭ³¦¤Î¸¡½Ð¤Ë»È¤¦¥Ç¡¼¥¿ */
2 #ifndef _wordborder_h_included_
3 #define _wordborder_h_included_
4
5
6 #include <anthy/dic.h>
7 #include <anthy/alloc.h>
8 #include <anthy/segclass.h>
9 #include <anthy/depgraph.h>
10
11 struct splitter_context;
12
13 /*
14  * meta_word¤Î»ÈÍѲÄǽ¥Á¥§¥Ã¥¯¤Î¤ä¤êÊý
15  */
16 enum mw_check {
17   /* ¤Ê¤Ë¤â¤»¤º */
18   MW_CHECK_NONE,
19   /* mw->wl¤¬Ìµ¤¤¤«¡¢wl¤¬»È¤¨¤ë¾ì¹ç */
20   MW_CHECK_SINGLE,
21   MW_CHECK_BORDER,
22   MW_CHECK_WRAP,
23   MW_CHECK_OCHAIRE,
24   MW_CHECK_NUMBER,
25   MW_CHECK_COMPOUND
26 };
27
28 /*
29  * Ê¸»úÎóÃæ¤Î¤¢¤ë¾ì½ê¤òɽ¤·¡¤
30  * ¤½¤³¤«¤é»Ï¤Þ¤ëmeta_word, word_list¤Î¥»¥Ã¥È¤ò»ý¤Ä
31  */
32 struct char_node {
33   int max_len;
34   struct meta_word *mw;
35   struct word_list *wl;
36 };
37
38 /*
39  * ¥³¥ó¥Æ¥­¥¹¥ÈÃæ¤Î¼«Î©¸ì¤Ê¤É¤Î¾ðÊ󡢺ǽé¤ËÊÑ´¹¥­¡¼¤ò²¡¤·¤¿¤È¤­¤Ë
40  * ¹½ÃÛ¤µ¤ì¤ë
41  */
42 struct word_split_info_cache {
43   struct char_node *cnode;
44
45   /* ¥­¥ã¥Ã¥·¥å¹½À®»þ¤Ë»È¤¦¾ðÊó */
46   /* ÀÜÈø¼­¤òõ¤¹¤Î¤Ë»È¤¦ */
47   int *seq_len;/* ¤½¤³¤«¤é»Ï¤Þ¤ëºÇŤÎñ¸ì¤ÎŤµ */
48   /* ÀÜƬ¼­¤òõ¤¹¤Î¤Ë»È¤¦ */
49   int *rev_seq_len;/* ¤½¤³¤Ç½ª¤ï¤ëºÇŤÎñ¸ì¤ÎŤµ */
50   /* Ê¸Àᶭ³¦context¤«¤é¤Î¥³¥Ô¡¼ */
51   int *seg_border;
52   /* ¸¡º÷¤Ç°ìÈÖÀ®ÀÓ¤ÎÎɤ«¤Ã¤¿¥¯¥é¥¹ */
53   enum seg_class* best_seg_class;
54   /*  */
55   struct meta_word **best_mw;
56   /* ¥¢¥í¥±¡¼¥¿ */
57   allocator MwAllocator, WlAllocator;
58 };
59
60 /*
61  * meta_word¤Î¾õÂÖ
62  */
63 enum mw_status {
64   MW_STATUS_NONE,
65   /* mw->mw1¤ËÃæ¿È¤¬Æþ¤Ã¤Æ¤¤¤ë */
66   MW_STATUS_WRAPPED,
67   /* mw-mw1¤Èmw->mw2¤«¤éÏ¢·ë */
68   MW_STATUS_COMBINED,
69   /* Ê£¹ç¸ìÍÑ */
70   MW_STATUS_COMPOUND,
71   /* Ê£¹ç¸ì¤Î¸Ä¡¹¤ÎʸÀá¤ò·ë¹ç¤·¤Æ°ì¤Ä¤ÎʸÀá¤È¤·¤Æ¸«¤¿¤â¤Î */
72   MW_STATUS_COMPOUND_PART,
73   /* OCHAIRE³Ø½¬¤«¤é¼è¤ê½Ð¤¹ */
74   MW_STATUS_OCHAIRE
75 };
76
77
78
79 /* metaword¤Î¼ïÎà¤Ë¤è¤ë½èÍý¤Î°ã¤¤ (metaword.c) */
80 extern struct metaword_type_tab_ {
81   enum metaword_type type;
82   const char *name;
83   enum mw_status status;
84   enum mw_check check;
85 } anthy_metaword_type_tab[];
86
87 /*
88  * 0: ÀÜƬ¼­
89  * 1: ¼«Î©¸ìÉô
90  * 2: ÀÜÈø¼­
91  */
92 #define NR_PARTS 4
93 #define PART_PREFIX 0
94 #define PART_CORE 1
95 #define PART_POSTFIX 2
96 #define PART_DEPWORD 3
97
98 struct part_info {
99   /* ¤³¤Îpart¤ÎŤµ */
100   int from, len;
101   /* ÉÊ»ì */
102   wtype_t wt;
103   seq_ent_t seq;
104   /* ÉÑÅÙ */
105   int freq;
106   /* ÉÕ°¸ì¥¯¥é¥¹ */
107   enum dep_class dc;
108 };
109
110 /*
111  * word_list: Ê¸Àá¤ò·ÁÀ®¤¹¤ë¤â¤Î
112  * ÀÜƬ¸ì¡¢¼«Î©¸ì¡¢ÀÜÈø¸ì¡¢ÉÕ°¸ì¤ò´Þ¤à
113  */
114 struct word_list {
115   /**/
116   int from, len; /* Ê¸ÀáÁ´ÂΠ*/
117   int is_compound; /* Ê£¹ç¸ì¤«¤É¤¦¤« */
118
119   /**/
120   int dep_word_hash;
121   int mw_features;
122   /**/
123   enum seg_class seg_class;
124   enum constraint_stat can_use; /* ¥»¥°¥á¥ó¥È¶­³¦¤Ë¸Ù¤¬¤Ã¤Æ¤¤¤Ê¤¤ */
125
126   /* ´Á»ú¤òÆÀ¤ë¤¿¤á¤Ç¤Ï¤Ê¤¯¤Æ¡¢»¨Â¿¤Ê½èÍý¤Ë»È¤¤¤¿¤¤¾ðÊó */
127   int head_pos; /* lattice¸¡º÷ÍѤÎÉÊ»ì */
128   int tail_ct; /* meta_word¤Î·ë¹çÍѤγèÍÑ·Á */
129
130   /**/
131   int last_part;
132   struct part_info part[NR_PARTS];
133
134   /* ¤³¤Îword_list¤òºî¤Ã¤¿ºÝ¤Î¾ðÊó */
135   int node_id; /* ÉÕ°¸ì¥°¥é¥Õ¤Î¸¡º÷³«»Ï¤Înode¤Îid*/
136
137   /* Æ±¤¸from¤ò»ý¤Äword_list¤Î¥ê¥¹¥È */
138   struct word_list *next;
139 };
140
141
142 /* splitter.c */
143 #define SPLITTER_DEBUG_NONE 0
144 /* wordlist¤Îɽ¼¨ */
145 #define SPLITTER_DEBUG_WL 1
146 /* metaword¤Îɽ¼¨ */
147 #define SPLITTER_DEBUG_MW 2
148 /* lattice¤Î node¤Îɽ¼¨ */
149 #define SPLITTER_DEBUG_LN 4
150 /* ¼«Î©¸ì¤Î¥Þ¥Ã¥Á¤·¤¿ÉÊ»ì */
151 #define SPLITTER_DEBUG_ID 8
152 /**/
153 #define SPLITTER_DEBUG_CAND 16
154
155 int anthy_splitter_debug_flags(void);
156
157
158 /* defined in wordseq.c */
159 /* ¼«Î©¸ì°Ê¹ß¤ÎÀܳ¤Î½èÍý */
160 void anthy_scan_node(struct splitter_context *sc,
161                      struct word_list *wl,
162                      xstr *follow, int node);
163 int anthy_get_node_id_by_name(const char *name);
164 int anthy_init_depword_tab(void);
165 void anthy_quit_depword_tab(void);
166
167 /* depgraph.c */
168 int anthy_get_nr_dep_rule(void);
169 void anthy_get_nth_dep_rule(int, struct wordseq_rule *);
170
171 /* defined in wordlist.c */
172 void anthy_commit_word_list(struct splitter_context *, struct word_list *wl);
173 struct word_list *anthy_alloc_word_list(struct splitter_context *);
174 void anthy_print_word_list(struct splitter_context *, struct word_list *);
175 void anthy_make_word_list_all(struct splitter_context *);
176
177 /* defined in metaword.c */
178 void anthy_commit_meta_word(struct splitter_context *, struct meta_word *mw);
179 void anthy_make_metaword_all(struct splitter_context *);
180 void anthy_print_metaword(struct splitter_context *, struct meta_word *);
181
182 void anthy_mark_border_by_metaword(struct splitter_context* sc,
183                                    struct meta_word* mw);
184
185
186 /* defined in evalborder.c */
187 void anthy_eval_border(struct splitter_context *, int, int, int);
188
189 /* defined at lattice.c */
190 void anthy_mark_borders(struct splitter_context *sc, int from, int to);
191
192 /* defined at seg_class.c */
193 void anthy_set_seg_class(struct word_list* wl);
194
195 /* ÉÊ»ì(anthy_init_splitter¤Ç½é´ü²½¤µ¤ì¤ë) */
196 extern wtype_t anthy_wtype_noun;
197 extern wtype_t anthy_wtype_name_noun;
198 extern wtype_t anthy_wtype_num_noun;
199 extern wtype_t anthy_wtype_prefix;
200 extern wtype_t anthy_wtype_num_prefix;
201 extern wtype_t anthy_wtype_num_postfix;
202 extern wtype_t anthy_wtype_name_postfix;
203 extern wtype_t anthy_wtype_sv_postfix;
204 extern wtype_t anthy_wtype_a_tail_of_v_renyou;
205 extern wtype_t anthy_wtype_v_renyou;
206 extern wtype_t anthy_wtype_noun_tail;/* ¤¤¤ì¡Ö¤¿¤Æ¡×¤È¤« */
207 extern wtype_t anthy_wtype_n1;
208 extern wtype_t anthy_wtype_n10;
209
210 #endif