~ubuntu-branches/debian/stretch/mudlet/stretch

« back to all changes in this revision

Viewing changes to src/hunspell/hunspell.hxx

  • Committer: Bazaar Package Importer
  • Author(s): Craig Small
  • Date: 2011-05-14 20:12:49 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110514201249-184gqx5jjqam02lg
Tags: 2.0-rc5-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include "hunvisapi.h"
2
 
 
3
 
#include "hashmgr.hxx"
4
 
#include "affixmgr.hxx"
5
 
#include "suggestmgr.hxx"
6
 
#include "langnum.hxx"
7
 
 
8
 
#define  SPELL_COMPOUND  (1 << 0)
9
 
#define  SPELL_FORBIDDEN (1 << 1)
10
 
#define  SPELL_ALLCAP    (1 << 2)
11
 
#define  SPELL_NOCAP     (1 << 3)
12
 
#define  SPELL_INITCAP   (1 << 4)
13
 
 
14
 
#define  SPELL_XML "<?xml?>"
15
 
 
16
 
#define MAXDIC 20
17
 
#define MAXSUGGESTION 15
18
 
#define MAXSHARPS 5
19
 
 
20
 
#ifndef _MYSPELLMGR_HXX_
21
 
#define _MYSPELLMGR_HXX_
22
 
 
23
 
class LIBHUNSPELL_DLL_EXPORTED Hunspell
24
 
{
25
 
  AffixMgr*       pAMgr;
26
 
  HashMgr*        pHMgr[MAXDIC];
27
 
  int             maxdic;
28
 
  SuggestMgr*     pSMgr;
29
 
  char *          affixpath;
30
 
  char *          encoding;
31
 
  struct cs_info * csconv;
32
 
  int             langnum;
33
 
  int             utf8;
34
 
  int             complexprefixes;
35
 
  char**          wordbreak;
36
 
 
37
 
public:
38
 
 
39
 
  /* Hunspell(aff, dic) - constructor of Hunspell class
40
 
   * input: path of affix file and dictionary file
41
 
   */
42
 
 
43
 
  Hunspell(const char * affpath, const char * dpath, const char * key = NULL);
44
 
  ~Hunspell();
45
 
 
46
 
  /* load extra dictionaries (only dic files) */
47
 
  int add_dic(const char * dpath, const char * key = NULL);
48
 
 
49
 
  /* spell(word) - spellcheck word
50
 
   * output: 0 = bad word, not 0 = good word
51
 
   *   
52
 
   * plus output:
53
 
   *   info: information bit array, fields:
54
 
   *     SPELL_COMPOUND  = a compound word 
55
 
   *     SPELL_FORBIDDEN = an explicit forbidden word
56
 
   *   root: root (stem), when input is a word with affix(es)
57
 
   */
58
 
   
59
 
  int spell(const char * word, int * info = NULL, char ** root = NULL);
60
 
 
61
 
  /* suggest(suggestions, word) - search suggestions
62
 
   * input: pointer to an array of strings pointer and the (bad) word
63
 
   *   array of strings pointer (here *slst) may not be initialized
64
 
   * output: number of suggestions in string array, and suggestions in
65
 
   *   a newly allocated array of strings (*slts will be NULL when number
66
 
   *   of suggestion equals 0.)
67
 
   */
68
 
 
69
 
  int suggest(char*** slst, const char * word);
70
 
 
71
 
  /* deallocate suggestion lists */
72
 
 
73
 
  void free_list(char *** slst, int n);
74
 
 
75
 
  char * get_dic_encoding();
76
 
 
77
 
 /* morphological functions */
78
 
 
79
 
 /* analyze(result, word) - morphological analysis of the word */
80
 
 
81
 
  int analyze(char*** slst, const char * word);
82
 
 
83
 
 /* stem(result, word) - stemmer function */
84
 
  
85
 
  int stem(char*** slst, const char * word);
86
 
  
87
 
 /* stem(result, analysis, n) - get stems from a morph. analysis
88
 
  * example:
89
 
  * char ** result, result2;
90
 
  * int n1 = analyze(&result, "words");
91
 
  * int n2 = stem(&result2, result, n1);   
92
 
  */
93
 
 
94
 
  int stem(char*** slst, char ** morph, int n);
95
 
 
96
 
 /* generate(result, word, word2) - morphological generation by example(s) */
97
 
 
98
 
  int generate(char*** slst, const char * word, const char * word2);
99
 
 
100
 
 /* generate(result, word, desc, n) - generation by morph. description(s)
101
 
  * example:
102
 
  * char ** result;
103
 
  * char * affix = "is:plural"; // description depends from dictionaries, too
104
 
  * int n = generate(&result, "word", &affix, 1);
105
 
  * for (int i = 0; i < n; i++) printf("%s\n", result[i]);
106
 
  */
107
 
 
108
 
  int generate(char*** slst, const char * word, char ** desc, int n);
109
 
 
110
 
  /* functions for run-time modification of the dictionary */
111
 
 
112
 
  /* add word to the run-time dictionary */
113
 
  
114
 
  int add(const char * word);
115
 
 
116
 
  /* add word to the run-time dictionary with affix flags of
117
 
   * the example (a dictionary word): Hunspell will recognize
118
 
   * affixed forms of the new word, too.
119
 
   */
120
 
  
121
 
  int add_with_affix(const char * word, const char * example);
122
 
 
123
 
  /* remove word from the run-time dictionary */
124
 
 
125
 
  int remove(const char * word);
126
 
 
127
 
  /* other */
128
 
 
129
 
  /* get extra word characters definied in affix file for tokenization */
130
 
  const char * get_wordchars();
131
 
  unsigned short * get_wordchars_utf16(int * len);
132
 
 
133
 
  struct cs_info * get_csconv();
134
 
  const char * get_version();
135
 
 
136
 
  int get_langnum() const;
137
 
  
138
 
  /* experimental and deprecated functions */
139
 
 
140
 
#ifdef HUNSPELL_EXPERIMENTAL
141
 
  /* suffix is an affix flag string, similarly in dictionary files */  
142
 
  int put_word_suffix(const char * word, const char * suffix);
143
 
  char * morph_with_correction(const char * word);
144
 
 
145
 
  /* spec. suggestions */
146
 
  int suggest_auto(char*** slst, const char * word);
147
 
  int suggest_pos_stems(char*** slst, const char * word);
148
 
#endif
149
 
 
150
 
private:
151
 
   int    cleanword(char *, const char *, int * pcaptype, int * pabbrev);
152
 
   int    cleanword2(char *, const char *, w_char *, int * w_len, int * pcaptype, int * pabbrev);
153
 
   void   mkinitcap(char *);
154
 
   int    mkinitcap2(char * p, w_char * u, int nc);
155
 
   int    mkinitsmall2(char * p, w_char * u, int nc);
156
 
   void   mkallcap(char *);
157
 
   int    mkallcap2(char * p, w_char * u, int nc);
158
 
   void   mkallsmall(char *);
159
 
   int    mkallsmall2(char * p, w_char * u, int nc);
160
 
   struct hentry * checkword(const char *, int * info, char **root);
161
 
   char * sharps_u8_l1(char * dest, char * source);
162
 
   hentry * spellsharps(char * base, char *, int, int, char * tmp, int * info, char **root);
163
 
   int    is_keepcase(const hentry * rv);
164
 
   int    insert_sug(char ***slst, char * word, int ns);
165
 
   void   cat_result(char * result, char * st);
166
 
   char * stem_description(const char * desc);
167
 
   int    spellml(char*** slst, const char * word);
168
 
   int    get_xml_par(char * dest, const char * par, int maxl);
169
 
   const char * get_xml_pos(const char * s, const char * attr);
170
 
   int    get_xml_list(char ***slst, char * list, const char * tag);
171
 
   int    check_xml_par(const char * q, const char * attr, const char * value);
172
 
 
173
 
};
174
 
 
175
 
#endif