1 /******* BEGIN LICENSE BLOCK *******
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
14 * The Initial Developers of the Original Code are Kevin Hendricks (MySpell)
15 * and László Németh (Hunspell). Portions created by the Initial Developers
16 * are Copyright (C) 2002-2005 the Initial Developers. All Rights Reserved.
18 * Contributor(s): Kevin Hendricks (kevin.hendricks@sympatico.ca)
19 * David Einstein (deinst@world.std.com)
20 * László Németh (nemethl@gyorsposta.hu)
43 * Alternatively, the contents of this file may be used under the terms of
44 * either the GNU General Public License Version 2 or later (the "GPL"), or
45 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
46 * in which case the provisions of the GPL or the LGPL are applicable instead
47 * of those above. If you wish to allow use of your version of this file only
48 * under the terms of either the GPL or the LGPL, and not to allow others to
49 * use your version of this file under the terms of the MPL, indicate your
50 * decision by deleting the provisions above and replace them with the notice
51 * and other provisions required by the GPL or the LGPL. If you do not delete
52 * the provisions above, a recipient may use your version of this file under
53 * the terms of any one of the MPL, the GPL or the LGPL.
55 ******* END LICENSE BLOCK *******/
57 #ifndef _AFFIXMGR_HXX_
58 #define _AFFIXMGR_HXX_
61 #ifdef __SUNPRO_CC // for SunONE Studio compiler
70 #include "baseaffix.hxx"
71 #include "hashmgr.hxx"
73 #include "replist.hxx"
75 // check flag duplication
76 #define dupSFX (1 << 0)
77 #define dupPFX (1 << 1)
82 AffEntry
* pStart
[SETSIZE
];
83 AffEntry
* sStart
[SETSIZE
];
84 AffEntry
* pFlag
[SETSIZE
];
85 AffEntry
* sFlag
[SETSIZE
];
92 struct cs_info
* csconv
;
100 FLAG compoundforbidflag
;
101 FLAG compoundpermitflag
;
102 int checkcompounddup
;
103 int checkcompoundrep
;
104 int checkcompoundcase
;
105 int checkcompoundtriple
;
106 int simplifiedtriple
;
112 replentry
* reptable
;
113 RepList
* iconvtable
;
114 RepList
* oconvtable
;
120 patentry
* checkcpdtable
;
123 flagentry
* defcpdtable
;
131 w_char
* cpdvowels_utf16
;
132 int cpdvowels_utf16_len
;
133 char * cpdsyllablenum
;
134 const char * pfxappnd
; // BUG: not stateless
135 const char * sfxappnd
; // BUG: not stateless
136 FLAG sfxflag
; // BUG: not stateless
137 char * derived
; // BUG: not stateless
138 AffEntry
* sfx
; // BUG: not stateless
139 AffEntry
* pfx
; // BUG: not stateless
142 unsigned short * wordchars_utf16
;
143 int wordchars_utf16_len
;
145 unsigned short * ignorechars_utf16
;
146 int ignorechars_utf16_len
;
158 int havecontclass
; // boolean variable
159 char contclasses
[CONTSIZE
]; // flags of possible continuing classes (twofold affix)
163 AffixMgr(const char * affpath
, HashMgr
** ptr
, int * md
,
164 const char * key
= NULL
);
166 struct hentry
* affix_check(const char * word
, int len
,
167 const unsigned short needflag
= (unsigned short) 0,
168 char in_compound
= IN_CPD_NOT
);
169 struct hentry
* prefix_check(const char * word
, int len
,
170 char in_compound
, const FLAG needflag
= FLAG_NULL
);
171 inline int isSubset(const char * s1
, const char * s2
);
172 struct hentry
* prefix_check_twosfx(const char * word
, int len
,
173 char in_compound
, const FLAG needflag
= FLAG_NULL
);
174 inline int isRevSubset(const char * s1
, const char * end_of_s2
, int len
);
175 struct hentry
* suffix_check(const char * word
, int len
, int sfxopts
,
176 AffEntry
* ppfx
, char ** wlst
, int maxSug
, int * ns
,
177 const FLAG cclass
= FLAG_NULL
, const FLAG needflag
= FLAG_NULL
,
178 char in_compound
= IN_CPD_NOT
);
179 struct hentry
* suffix_check_twosfx(const char * word
, int len
,
180 int sfxopts
, AffEntry
* ppfx
, const FLAG needflag
= FLAG_NULL
);
182 char * affix_check_morph(const char * word
, int len
,
183 const FLAG needflag
= FLAG_NULL
, char in_compound
= IN_CPD_NOT
);
184 char * prefix_check_morph(const char * word
, int len
,
185 char in_compound
, const FLAG needflag
= FLAG_NULL
);
186 char * suffix_check_morph (const char * word
, int len
, int sfxopts
,
187 AffEntry
* ppfx
, const FLAG cclass
= FLAG_NULL
,
188 const FLAG needflag
= FLAG_NULL
, char in_compound
= IN_CPD_NOT
);
190 char * prefix_check_twosfx_morph(const char * word
, int len
,
191 char in_compound
, const FLAG needflag
= FLAG_NULL
);
192 char * suffix_check_twosfx_morph(const char * word
, int len
,
193 int sfxopts
, AffEntry
* ppfx
, const FLAG needflag
= FLAG_NULL
);
195 char * morphgen(char * ts
, int wl
, const unsigned short * ap
,
196 unsigned short al
, char * morph
, char * targetmorph
, int level
);
198 int expand_rootword(struct guessword
* wlst
, int maxn
, const char * ts
,
199 int wl
, const unsigned short * ap
, unsigned short al
, char * bad
,
202 short get_syllable (const char * word
, int wlen
);
203 int cpdrep_check(const char * word
, int len
);
204 int cpdpat_check(const char * word
, int len
, hentry
* r1
, hentry
* r2
);
205 int defcpd_check(hentry
*** words
, short wnum
, hentry
* rv
,
206 hentry
** rwords
, char all
);
207 int cpdcase_check(const char * word
, int len
);
208 inline int candidate_check(const char * word
, int len
);
209 void setcminmax(int * cmin
, int * cmax
, const char * word
, int len
);
210 struct hentry
* compound_check(const char * word
, int len
, short wordnum
,
211 short numsyllable
, short maxwordnum
, short wnum
, hentry
** words
,
212 char hu_mov_rule
, char is_sug
);
214 int compound_check_morph(const char * word
, int len
, short wordnum
,
215 short numsyllable
, short maxwordnum
, short wnum
, hentry
** words
,
216 char hu_mov_rule
, char ** result
, char * partresult
);
218 struct hentry
* lookup(const char * word
);
220 struct replentry
* get_reptable();
221 RepList
* get_iconvtable();
222 RepList
* get_oconvtable();
223 struct phonetable
* get_phonetable();
225 struct mapentry
* get_maptable();
227 char ** get_breaktable();
228 char * get_encoding();
230 char * get_key_string();
231 char * get_try_string();
232 const char * get_wordchars();
233 unsigned short * get_wordchars_utf16(int * len
);
235 unsigned short * get_ignore_utf16(int * len
);
237 FLAG
get_compoundflag();
238 FLAG
get_compoundbegin();
239 FLAG
get_forbiddenword();
240 FLAG
get_nosuggest();
241 FLAG
get_needaffix();
242 FLAG
get_onlyincompound();
243 FLAG
get_compoundroot();
244 FLAG
get_lemma_present();
246 char * get_possible_root();
247 const char * get_prefix();
248 const char * get_suffix();
249 const char * get_derived();
250 const char * get_version();
251 const int have_contclass();
253 int get_complexprefixes();
254 char * get_suffixed(char );
255 int get_maxngramsugs();
256 int get_nosplitsugs();
257 int get_sugswithdots(void);
258 FLAG
get_keepcase(void);
259 int get_checksharps(void);
260 char * encode_flag(unsigned short aflag
);
264 int parse_file(const char * affpath
, const char * key
);
265 int parse_flag(char * line
, unsigned short * out
, FileMgr
* af
);
266 int parse_num(char * line
, int * out
, FileMgr
* af
);
267 int parse_cpdsyllable(char * line
, FileMgr
* af
);
268 int parse_reptable(char * line
, FileMgr
* af
);
269 int parse_convtable(char * line
, FileMgr
* af
, RepList
** rl
, const char * keyword
);
270 int parse_phonetable(char * line
, FileMgr
* af
);
271 int parse_maptable(char * line
, FileMgr
* af
);
272 int parse_breaktable(char * line
, FileMgr
* af
);
273 int parse_checkcpdtable(char * line
, FileMgr
* af
);
274 int parse_defcpdtable(char * line
, FileMgr
* af
);
275 int parse_affix(char * line
, const char at
, FileMgr
* af
, char * dupflags
);
277 void reverse_condition(char *);
278 void debugflag(char * result
, unsigned short flag
);
280 int encodeit(struct affentry
* ptr
, char * cs
);
281 int build_pfxtree(AffEntry
* pfxptr
);
282 int build_sfxtree(AffEntry
* sfxptr
);
283 int process_pfx_order();
284 int process_sfx_order();
285 AffEntry
* process_pfx_in_order(AffEntry
* ptr
, AffEntry
* nptr
);
286 AffEntry
* process_sfx_in_order(AffEntry
* ptr
, AffEntry
* nptr
);
287 int process_pfx_tree_to_list();
288 int process_sfx_tree_to_list();
289 int redundant_condition(char, char * strip
, int stripl
,
290 const char * cond
, int);