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 _SUGGESTMGR_HXX_
58 #define _SUGGESTMGR_HXX_
61 #define MAXSWUTF8L (MAXSWL * 4)
65 #define MAXNGRAMSUGS 4
68 // timelimit: max ~1/4 sec (process time on Linux) for a time consuming function
69 #define TIMELIMIT (CLOCKS_PER_SEC >> 2)
71 #define MAXPLUSTIMER 100
73 #define NGRAM_LONGER_WORSE (1 << 0)
74 #define NGRAM_ANY_MISMATCH (1 << 1)
75 #define NGRAM_LOWERING (1 << 2)
77 #include "affixmgr.hxx"
79 #include "hashmgr.hxx"
80 #include "langnum.hxx"
83 enum { LCS_UP
, LCS_LEFT
, LCS_UPLEFT
};
97 struct cs_info
* csconv
;
106 SuggestMgr(const char * tryme
, int maxn
, AffixMgr
*aptr
);
109 int suggest(char*** slst
, const char * word
, int nsug
, int * onlycmpdsug
);
110 int ngsuggest(char ** wlst
, char * word
, int ns
, HashMgr
** pHMgr
, int md
);
111 int suggest_auto(char*** slst
, const char * word
, int nsug
);
112 int suggest_stems(char*** slst
, const char * word
, int nsug
);
113 int suggest_pos_stems(char*** slst
, const char * word
, int nsug
);
115 char * suggest_morph(const char * word
);
116 char * suggest_gen(char ** pl
, int pln
, char * pattern
);
117 char * suggest_morph_for_spelling_error(const char * word
);
120 int testsug(char** wlst
, const char * candidate
, int wl
, int ns
, int cpdsuggest
,
121 int * timer
, clock_t * timelimit
);
122 int checkword(const char *, int, int, int *, clock_t *);
123 int check_forbidden(const char *, int);
125 int capchars(char **, const char *, int, int);
126 int replchars(char**, const char *, int, int);
127 int doubletwochars(char**, const char *, int, int);
128 int forgotchar(char **, const char *, int, int);
129 int swapchar(char **, const char *, int, int);
130 int longswapchar(char **, const char *, int, int);
131 int movechar(char **, const char *, int, int);
132 int extrachar(char **, const char *, int, int);
133 int badcharkey(char **, const char *, int, int);
134 int badchar(char **, const char *, int, int);
135 int twowords(char **, const char *, int, int);
136 int fixstems(char **, const char *, int);
138 int capchars_utf(char **, const w_char
*, int wl
, int, int);
139 int doubletwochars_utf(char**, const w_char
*, int wl
, int, int);
140 int forgotchar_utf(char**, const w_char
*, int wl
, int, int);
141 int extrachar_utf(char**, const w_char
*, int wl
, int, int);
142 int badcharkey_utf(char **, const w_char
*, int wl
, int, int);
143 int badchar_utf(char **, const w_char
*, int wl
, int, int);
144 int swapchar_utf(char **, const w_char
*, int wl
, int, int);
145 int longswapchar_utf(char **, const w_char
*, int, int, int);
146 int movechar_utf(char **, const w_char
*, int, int, int);
148 int mapchars(char**, const char *, int, int);
149 int map_related(const char *, int, char ** wlst
, int, int, const mapentry
*, int, int *, clock_t *);
150 int map_related_utf(w_char
*, int, int, int, char ** wlst
, int, const mapentry
*, int, int *, clock_t *);
151 int ngram(int n
, char * s1
, const char * s2
, int opt
);
152 int mystrlen(const char * word
);
153 int leftcommonsubstring(char * s1
, const char * s2
);
154 int commoncharacterpositions(char * s1
, const char * s2
, int * is_swap
);
155 void bubblesort( char ** rwd
, char ** rwd2
, int * rsc
, int n
);
156 void lcs(const char * s
, const char * s2
, int * l1
, int * l2
, char ** result
);
157 int lcslen(const char * s
, const char* s2
);
158 char * suggest_hentry_gen(hentry
* rv
, char * pattern
);