00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef ISPELL_CHECKER_H
00033 #define ISPELL_CHECKER_H
00034
00035 #include "ispell.h"
00036
00037 #include <qstringlist.h>
00038 #include <qvaluelist.h>
00039 #include <qtextcodec.h>
00040 #include <qstring.h>
00041
00042
00043 class ISpellChecker
00044 {
00045 public:
00046 ISpellChecker();
00047 ~ISpellChecker();
00048
00049 bool checkWord(const QString& word);
00050 QStringList suggestWord(const QString& word);
00051
00052 bool requestDictionary (const char * szLang);
00053 static QValueList<QString> allDics();
00054 private:
00055 ISpellChecker(const ISpellChecker&);
00056 void operator=(const ISpellChecker&);
00057
00058 QString loadDictionary (const char * szLang );
00059 bool loadDictionaryForLanguage ( const char * szLang );
00060 void setDictionaryEncoding ( const QString& hashname, const char * enc );
00061
00062
00063
00064
00065
00066
00067 void try_autodetect_charset(const char * inEncoding);
00068
00069
00070
00071
00072
00073 int casecmp P ((char * a, char * b, int canonical));
00074 void makepossibilities P ((ichar_t * word));
00075 int insert P ((ichar_t * word));
00076 #ifndef NO_CAPITALIZATION_SUPPORT
00077 void wrongcapital P ((ichar_t * word));
00078 #endif
00079 void wrongletter P ((ichar_t * word));
00080 void extraletter P ((ichar_t * word));
00081 void missingletter P ((ichar_t * word));
00082 void missingspace P ((ichar_t * word));
00083 int compoundgood P ((ichar_t * word, int pfxopts));
00084 void transposedletter P ((ichar_t * word));
00085 int ins_cap P ((ichar_t * word, ichar_t * pattern));
00086 int save_cap P ((ichar_t * word, ichar_t * pattern,
00087 ichar_t savearea[MAX_CAPS][INPUTWORDLEN + MAXAFFIXLEN]));
00088 int ins_root_cap P ((ichar_t * word, ichar_t * pattern,
00089 int prestrip, int preadd, int sufstrip, int sufadd,
00090 struct dent * firstdent, struct flagent * pfxent,
00091 struct flagent * sufent));
00092 void save_root_cap P ((ichar_t * word, ichar_t * pattern,
00093 int prestrip, int preadd, int sufstrip, int sufadd,
00094 struct dent * firstdent, struct flagent * pfxent,
00095 struct flagent * sufent,
00096 ichar_t savearea[MAX_CAPS][INPUTWORDLEN + MAXAFFIXLEN],
00097 int * nsaved));
00098
00099
00100
00101
00102
00103 int good (ichar_t* w, int ignoreflagbits, int allhits, int pfxopts, int sfxopts);
00104 void chk_aff (ichar_t* word, ichar_t* ucword, int len, int ignoreflagbits, int allhits, int pfxopts, int sfxopts);
00105 int linit(char*);
00106 struct dent * ispell_lookup (ichar_t* s, int dotree);
00107 int strtoichar (ichar_t* out, char* in, int outlen, int canonical);
00108 int ichartostr (char* out, ichar_t* in, int outlen, int canonical);
00109 char * ichartosstr (ichar_t* in, int canonical);
00110 int findfiletype (const char * name, int searchnames, int * deformatter);
00111 long whatcap (ichar_t* word);
00112
00113
00114
00115
00116
00117
00118 char myupper(ichar_t c);
00119 char mylower(ichar_t c);
00120 int myspace(ichar_t c);
00121 char iswordch(ichar_t c);
00122 char isboundarych(ichar_t c);
00123 char isstringstart(ichar_t c);
00124 ichar_t mytolower(ichar_t c);
00125 ichar_t mytoupper(ichar_t c);
00126
00127 #ifndef ICHAR_IS_CHAR
00128 int cap_ok (ichar_t* word, struct success* hit, int len);
00129
00130 int hash (ichar_t* s, int hashtblsize);
00131 #endif
00132
00133
00134
00135
00136
00137 void clearindex P ((struct flagptr * indexp));
00138 void initckch P ((char *));
00139
00140 void alloc_ispell_struct();
00141 void free_ispell_struct();
00142
00143
00144
00145
00146
00147 int addvheader P ((struct dent * ent));
00148 void upcase P ((ichar_t * string));
00149 void lowcase P ((ichar_t * string));
00150 void chupcase P ((char * s));
00151
00152 int stringcharlen P ((char * bufp, int canonical));
00153 ichar_t * strtosichar P ((char * in, int canonical));
00154 char * printichar P ((int in));
00155
00156
00157
00158
00159
00160 void pfx_list_chk P ((ichar_t * word, ichar_t * ucword,
00161 int len, int optflags, int sfxopts, struct flagptr * ind,
00162 int ignoreflagbits, int allhits));
00163 void chk_suf P ((ichar_t * word, ichar_t * ucword, int len,
00164 int optflags, struct flagent * pfxent, int ignoreflagbits,
00165 int allhits));
00166 void suf_list_chk P ((ichar_t * word, ichar_t * ucword, int len,
00167 struct flagptr * ind, int optflags, struct flagent * pfxent,
00168 int ignoreflagbits, int allhits));
00169 int expand_pre P ((char * croot, ichar_t * rootword,
00170 MASKTYPE mask[], int option, char * extra));
00171 int pr_pre_expansion P ((char * croot, ichar_t * rootword,
00172 struct flagent * flent, MASKTYPE mask[], int option,
00173 char * extra));
00174 int expand_suf P ((char * croot, ichar_t * rootword,
00175 MASKTYPE mask[], int optflags, int option, char * extra));
00176 int pr_suf_expansion P ((char * croot, ichar_t * rootword,
00177 struct flagent * flent, int option, char * extra));
00178 void forcelc P ((ichar_t * dst, int len));
00179
00180
00181
00182 int deftflag;
00183 int prefstringchar;
00184 bool m_bSuccessfulInit;
00185
00186
00187
00188
00189
00190
00191 char * m_BC;
00192 char * m_cd;
00193 char * m_cl;
00194 char * m_cm;
00195 char * m_ho;
00196 char * m_nd;
00197 char * m_so;
00198 char * m_se;
00199 int m_sg;
00200 char * m_ti;
00201 char * m_te;
00202 int m_li;
00203 int m_co;
00204
00205 char m_ctoken[INPUTWORDLEN + MAXAFFIXLEN];
00206 ichar_t m_itoken[INPUTWORDLEN + MAXAFFIXLEN];
00207
00208 int m_numhits;
00209 struct success
00210 m_hits[MAX_HITS];
00211
00212 char * m_hashstrings;
00213 struct hashheader
00214 m_hashheader;
00215 struct dent *
00216 m_hashtbl;
00217 int m_hashsize;
00218
00219 char m_hashname[MAXPATHLEN];
00220
00221 int m_aflag;
00222 int m_cflag;
00223 int m_lflag;
00224 int m_incfileflag;
00225 int m_nodictflag;
00226
00227 int m_uerasechar;
00228 int m_ukillchar;
00229
00230 unsigned int m_laststringch;
00231 int m_defdupchar;
00232
00233 int m_numpflags;
00234 int m_numsflags;
00235 struct flagptr m_pflagindex[SET_SIZE + MAXSTRINGCHARS];
00236
00237 struct flagent * m_pflaglist;
00238 struct flagptr m_sflagindex[SET_SIZE + MAXSTRINGCHARS];
00239
00240 struct flagent * m_sflaglist;
00241
00242 struct strchartype *
00243 m_chartypes;
00244
00245 FILE * m_infile;
00246 FILE * m_outfile;
00247
00248 char * m_askfilename;
00249
00250 int m_changes;
00251 int m_readonly;
00252 int m_quit;
00253
00254 #define MAXPOSSIBLE 100
00255
00256 char m_possibilities[MAXPOSSIBLE][INPUTWORDLEN + MAXAFFIXLEN];
00257
00258 int m_pcount;
00259 int m_maxposslen;
00260 int m_easypossibilities;
00261
00262
00263
00264
00265
00266
00267 int m_Trynum;
00268 ichar_t m_Try[SET_SIZE + MAXSTRINGCHARS];
00269
00270 QTextCodec *m_translate_in;
00271 };
00272
00273 #endif