Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / extensions / spellcheck / hunspell / src / suggestmgr.hxx
blobcbb14e6cd821af5648af68bdbdfdb3a8cb032cde
1 /******* BEGIN LICENSE BLOCK *******
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 *
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/
8 *
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
12 * License.
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)
21 * Davide Prina
22 * Giuseppe Modugno
23 * Gianluca Turconi
24 * Simon Brouwer
25 * Noll Janos
26 * Biro Arpad
27 * Goldman Eleonora
28 * Sarlos Tamas
29 * Bencsath Boldizsar
30 * Halacsy Peter
31 * Dvornik Laszlo
32 * Gefferth Andras
33 * Nagy Viktor
34 * Varga Daniel
35 * Chris Halls
36 * Rene Engelhard
37 * Bram Moolenaar
38 * Dafydd Jones
39 * Harri Pitkanen
40 * Andras Timar
41 * Tor Lillqvist
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_
60 #define MAXSWL 100
61 #define MAXSWUTF8L (MAXSWL * 4)
62 #define MAX_ROOTS 100
63 #define MAX_WORDS 100
64 #define MAX_GUESS 200
65 #define MAXNGRAMSUGS 4
66 #define MAXPHONSUGS 2
68 // timelimit: max ~1/4 sec (process time on Linux) for a time consuming function
69 #define TIMELIMIT (CLOCKS_PER_SEC >> 2)
70 #define MINTIMER 100
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"
78 #include "atypes.hxx"
79 #include "hashmgr.hxx"
80 #include "langnum.hxx"
81 #include <time.h>
83 enum { LCS_UP, LCS_LEFT, LCS_UPLEFT };
85 class SuggestMgr
87 char * ckey;
88 int ckeyl;
89 w_char * ckey_utf;
91 char * ctry;
92 int ctryl;
93 w_char * ctry_utf;
95 AffixMgr* pAMgr;
96 int maxSug;
97 struct cs_info * csconv;
98 int utf8;
99 int langnum;
100 int nosplitsugs;
101 int maxngramsugs;
102 int complexprefixes;
105 public:
106 SuggestMgr(const char * tryme, int maxn, AffixMgr *aptr);
107 ~SuggestMgr();
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);
119 private:
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);
162 #endif