• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kspell2
 

kspell2

  • kspell2
  • plugins
  • ispell
ispell_checker.h
1 /* vim: set sw=8: -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* kspell2 - adopted from Enchant
3  * Copyright (C) 2003 Dom Lachowicz
4  * Copyright (C) 2004 Zack Rusin <zack@kde.org>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  * In addition, as a special exception, Dom Lachowicz
22  * gives permission to link the code of this program with
23  * non-LGPL Spelling Provider libraries (eg: a MSFT Office
24  * spell checker backend) and distribute linked combinations including
25  * the two. You must obey the GNU Lesser General Public License in all
26  * respects for all of the code used other than said providers. If you modify
27  * this file, you may extend this exception to your version of the
28  * file, but you are not obligated to do so. If you do not wish to
29  * do so, delete this exception statement from your version.
30  */
31 
32 #ifndef ISPELL_CHECKER_H
33 #define ISPELL_CHECKER_H
34 
35 #include "ispell.h"
36 
37 #include <tqstringlist.h>
38 #include <tqvaluelist.h>
39 #include <tqtextcodec.h>
40 #include <tqstring.h>
41 
42 
43 class ISpellChecker
44 {
45 public:
46  ISpellChecker();
47  ~ISpellChecker();
48 
49  bool checkWord(const TQString& word);
50  TQStringList suggestWord(const TQString& word);
51 
52  bool requestDictionary (const char * szLang);
53  static TQValueList<TQString> allDics();
54 private:
55  ISpellChecker(const ISpellChecker&); // no impl
56  void operator=(const ISpellChecker&); // no impl
57 
58  TQString loadDictionary (const char * szLang );
59  bool loadDictionaryForLanguage ( const char * szLang );
60  void setDictionaryEncoding ( const TQString& hashname, const char * enc );
61 
62  //
63  // The member functions after this point were formerly global functions
64  // passed a context structure pointer...
65  //
66 
67  void try_autodetect_charset(const char * inEncoding);
68 
69  //
70  // From ispell correct.c
71  //
72 
73  int casecmp P ((char * a, char * b, int canonical));
74  void makepossibilities P ((ichar_t * word));
75  int insert P ((ichar_t * word));
76 #ifndef NO_CAPITALIZATION_SUPPORT
77  void wrongcapital P ((ichar_t * word));
78 #endif /* NO_CAPITALIZATION_SUPPORT */
79  void wrongletter P ((ichar_t * word));
80  void extraletter P ((ichar_t * word));
81  void missingletter P ((ichar_t * word));
82  void missingspace P ((ichar_t * word));
83  int compoundgood P ((ichar_t * word, int pfxopts));
84  void transposedletter P ((ichar_t * word));
85  int ins_cap P ((ichar_t * word, ichar_t * pattern));
86  int save_cap P ((ichar_t * word, ichar_t * pattern,
87  ichar_t savearea[MAX_CAPS][INPUTWORDLEN + MAXAFFIXLEN]));
88  int ins_root_cap P ((ichar_t * word, ichar_t * pattern,
89  int prestrip, int preadd, int sufstrip, int sufadd,
90  struct dent * firstdent, struct flagent * pfxent,
91  struct flagent * sufent));
92  void save_root_cap P ((ichar_t * word, ichar_t * pattern,
93  int prestrip, int preadd, int sufstrip, int sufadd,
94  struct dent * firstdent, struct flagent * pfxent,
95  struct flagent * sufent,
96  ichar_t savearea[MAX_CAPS][INPUTWORDLEN + MAXAFFIXLEN],
97  int * nsaved));
98 
99  //
100  // From ispell good.c
101  //
102 
103  int good (ichar_t* w, int ignoreflagbits, int allhits, int pfxopts, int sfxopts);
104  void chk_aff (ichar_t* word, ichar_t* ucword, int len, int ignoreflagbits, int allhits, int pfxopts, int sfxopts);
105  int linit(char*);
106  struct dent * ispell_lookup (ichar_t* s, int dotree);
107  int strtoichar (ichar_t* out, char* in, int outlen, int canonical);
108  int ichartostr (char* out, ichar_t* in, int outlen, int canonical);
109  char * ichartosstr (ichar_t* in, int canonical);
110  int findfiletype (const char * name, int searchnames, int * deformatter);
111  long whatcap (ichar_t* word);
112 
113  /*
114  HACK: macros replaced with function implementations
115  so we could do a side-effect-free check for unicode
116  characters which aren't in hashheader
117  */
118  char myupper(ichar_t c);
119  char mylower(ichar_t c);
120  int myspace(ichar_t c);
121  char iswordch(ichar_t c);
122  char isboundarych(ichar_t c);
123  char isstringstart(ichar_t c);
124  ichar_t mytolower(ichar_t c);
125  ichar_t mytoupper(ichar_t c);
126 
127 #ifndef ICHAR_IS_CHAR
128  int cap_ok (ichar_t* word, struct success* hit, int len);
129 
130  int hash (ichar_t* s, int hashtblsize);
131 #endif
132 
133  //
134  // From ispell lookup.c
135  //
136 
137  void clearindex P ((struct flagptr * indexp));
138  void initckch P ((char *));
139 
140  void alloc_ispell_struct();
141  void free_ispell_struct();
142 
143  //
144  // From ispell makedent.c
145  //
146 
147  int addvheader P ((struct dent * ent));
148  void upcase P ((ichar_t * string));
149  void lowcase P ((ichar_t * string));
150  void chupcase P ((char * s));
151 
152  int stringcharlen P ((char * bufp, int canonical));
153  ichar_t * strtosichar P ((char * in, int canonical));
154  char * printichar P ((int in));
155 
156  //
157  // From ispell tgood.c
158  //
159 
160  void pfx_list_chk P ((ichar_t * word, ichar_t * ucword,
161  int len, int optflags, int sfxopts, struct flagptr * ind,
162  int ignoreflagbits, int allhits));
163  void chk_suf P ((ichar_t * word, ichar_t * ucword, int len,
164  int optflags, struct flagent * pfxent, int ignoreflagbits,
165  int allhits));
166  void suf_list_chk P ((ichar_t * word, ichar_t * ucword, int len,
167  struct flagptr * ind, int optflags, struct flagent * pfxent,
168  int ignoreflagbits, int allhits));
169  int expand_pre P ((char * croot, ichar_t * rootword,
170  MASKTYPE mask[], int option, char * extra));
171  int pr_pre_expansion P ((char * croot, ichar_t * rootword,
172  struct flagent * flent, MASKTYPE mask[], int option,
173  char * extra));
174  int expand_suf P ((char * croot, ichar_t * rootword,
175  MASKTYPE mask[], int optflags, int option, char * extra));
176  int pr_suf_expansion P ((char * croot, ichar_t * rootword,
177  struct flagent * flent, int option, char * extra));
178  void forcelc P ((ichar_t * dst, int len));
179 
180  /* this is used for converting form unsigned short to UCS-4 */
181 
182  int deftflag; /* NZ for TeX mode by default */
183  int prefstringchar; /* Preferred string character type */
184  bool m_bSuccessfulInit;
185 
186  //
187  // The members after this point were formerly global variables
188  // in the original ispell code
189  //
190 
191  char * m_BC; /* backspace if not ^H */
192  char * m_cd; /* clear to end of display */
193  char * m_cl; /* clear display */
194  char * m_cm; /* cursor movement */
195  char * m_ho; /* home */
196  char * m_nd; /* non-destructive space */
197  char * m_so; /* standout */
198  char * m_se; /* standout end */
199  int m_sg; /* space taken by so/se */
200  char * m_ti; /* terminal initialization sequence */
201  char * m_te; /* terminal termination sequence */
202  int m_li; /* lines */
203  int m_co; /* columns */
204 
205  char m_ctoken[INPUTWORDLEN + MAXAFFIXLEN]; /* Current token as char */
206  ichar_t m_itoken[INPUTWORDLEN + MAXAFFIXLEN]; /* Ctoken as ichar_t str */
207 
208  int m_numhits; /* number of hits in dictionary lookups */
209  struct success
210  m_hits[MAX_HITS]; /* table of hits gotten in lookup */
211 
212  char * m_hashstrings; /* Strings in hash table */
213  struct hashheader
214  m_hashheader; /* Header of hash table */
215  struct dent *
216  m_hashtbl; /* Main hash table, for dictionary */
217  int m_hashsize; /* Size of main hash table */
218 
219  char m_hashname[MAXPATHLEN]; /* Name of hash table file */
220 
221  int m_aflag; /* NZ if -a or -A option specified */
222  int m_cflag; /* NZ if -c (crunch) option */
223  int m_lflag; /* NZ if -l (list) option */
224  int m_incfileflag; /* whether xgets() acts exactly like gets() */
225  int m_nodictflag; /* NZ if dictionary not needed */
226 
227  int m_uerasechar; /* User's erase character, from stty */
228  int m_ukillchar; /* User's kill character */
229 
230  unsigned int m_laststringch; /* Number of last string character */
231  int m_defdupchar; /* Default duplicate string type */
232 
233  int m_numpflags; /* Number of prefix flags in table */
234  int m_numsflags; /* Number of suffix flags in table */
235  struct flagptr m_pflagindex[SET_SIZE + MAXSTRINGCHARS];
236  /* Fast index to pflaglist */
237  struct flagent * m_pflaglist; /* Prefix flag control list */
238  struct flagptr m_sflagindex[SET_SIZE + MAXSTRINGCHARS];
239  /* Fast index to sflaglist */
240  struct flagent * m_sflaglist; /* Suffix flag control list */
241 
242  struct strchartype * /* String character type collection */
243  m_chartypes;
244 
245  FILE * m_infile; /* File being corrected */
246  FILE * m_outfile; /* Corrected copy of infile */
247 
248  char * m_askfilename; /* File specified in -f option */
249 
250  int m_changes; /* NZ if changes made to cur. file */
251  int m_readonly; /* NZ if current file is readonly */
252  int m_quit; /* NZ if we're done with this file */
253 
254 #define MAXPOSSIBLE 100 /* Max no. of possibilities to generate */
255 
256  char m_possibilities[MAXPOSSIBLE][INPUTWORDLEN + MAXAFFIXLEN];
257  /* Table of possible corrections */
258  int m_pcount; /* Count of possibilities generated */
259  int m_maxposslen; /* Length of longest possibility */
260  int m_easypossibilities; /* Number of "easy" corrections found */
261  /* ..(defined as those using legal affixes) */
262 
263  /*
264  * The following array contains a list of characters that should be tried
265  * in "missingletter." Note that lowercase characters are omitted.
266  */
267  int m_Trynum; /* Size of "Try" array */
268  ichar_t m_Try[SET_SIZE + MAXSTRINGCHARS];
269 
270  TQTextCodec *m_translate_in; /* Selected translation from/to Unicode */
271 };
272 
273 #endif /* ISPELL_CHECKER_H */

kspell2

Skip menu "kspell2"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

kspell2

Skip menu "kspell2"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kspell2 by doxygen 1.9.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |