4 #include "affixmgr.hxx"
5 #include "suggestmgr.hxx"
8 #ifdef HUNSPELL_CHROME_CLIENT
9 #include "third_party/hunspell/google/bdict_reader.h"
12 #define SPELL_XML "<?xml?>"
15 #define MAXSUGGESTION 15
18 #define HUNSPELL_OK (1 << 0)
19 #define HUNSPELL_OK_WARN (1 << 1)
21 #ifndef _MYSPELLMGR_HXX_
22 #define _MYSPELLMGR_HXX_
24 class LIBHUNSPELL_DLL_EXPORTED Hunspell
27 HashMgr
* pHMgr
[MAXDIC
];
30 #ifndef HUNSPELL_CHROME_CLIENT // We are using BDict instead.
34 struct cs_info
* csconv
;
40 #ifdef HUNSPELL_CHROME_CLIENT
41 // Not owned by us, owned by the Hunspell object.
42 hunspell::BDictReader
* bdict_reader
;
47 /* Hunspell(aff, dic) - constructor of Hunspell class
48 * input: path of affix file and dictionary file
51 #ifdef HUNSPELL_CHROME_CLIENT
52 Hunspell(const unsigned char* bdict_data
, size_t bdict_length
);
54 Hunspell(const char * affpath
, const char * dpath
, const char * key
= NULL
);
58 #ifndef HUNSPELL_CHROME_CLIENT
59 /* load extra dictionaries (only dic files) */
60 int add_dic(const char * dpath
, const char * key
= NULL
);
63 /* spell(word) - spellcheck word
64 * output: 0 = bad word, not 0 = good word
67 * info: information bit array, fields:
68 * SPELL_COMPOUND = a compound word
69 * SPELL_FORBIDDEN = an explicit forbidden word
70 * root: root (stem), when input is a word with affix(es)
73 int spell(const char * word
, int * info
= NULL
, char ** root
= NULL
);
75 /* suggest(suggestions, word) - search suggestions
76 * input: pointer to an array of strings pointer and the (bad) word
77 * array of strings pointer (here *slst) may not be initialized
78 * output: number of suggestions in string array, and suggestions in
79 * a newly allocated array of strings (*slts will be NULL when number
80 * of suggestion equals 0.)
83 int suggest(char*** slst
, const char * word
);
85 /* deallocate suggestion lists */
87 void free_list(char *** slst
, int n
);
89 char * get_dic_encoding();
91 /* morphological functions */
93 /* analyze(result, word) - morphological analysis of the word */
95 int analyze(char*** slst
, const char * word
);
97 /* stem(result, word) - stemmer function */
99 int stem(char*** slst
, const char * word
);
101 /* stem(result, analysis, n) - get stems from a morph. analysis
103 * char ** result, result2;
104 * int n1 = analyze(&result, "words");
105 * int n2 = stem(&result2, result, n1);
108 int stem(char*** slst
, char ** morph
, int n
);
110 /* generate(result, word, word2) - morphological generation by example(s) */
112 int generate(char*** slst
, const char * word
, const char * word2
);
114 /* generate(result, word, desc, n) - generation by morph. description(s)
117 * char * affix = "is:plural"; // description depends from dictionaries, too
118 * int n = generate(&result, "word", &affix, 1);
119 * for (int i = 0; i < n; i++) printf("%s\n", result[i]);
122 int generate(char*** slst
, const char * word
, char ** desc
, int n
);
124 /* functions for run-time modification of the dictionary */
126 /* add word to the run-time dictionary */
128 int add(const char * word
);
130 /* add word to the run-time dictionary with affix flags of
131 * the example (a dictionary word): Hunspell will recognize
132 * affixed forms of the new word, too.
135 int add_with_affix(const char * word
, const char * example
);
137 /* remove word from the run-time dictionary */
139 int remove(const char * word
);
143 /* get extra word characters definied in affix file for tokenization */
144 const char * get_wordchars();
145 unsigned short * get_wordchars_utf16(int * len
);
147 struct cs_info
* get_csconv();
148 const char * get_version();
150 int get_langnum() const;
152 /* experimental and deprecated functions */
154 #ifdef HUNSPELL_EXPERIMENTAL
155 /* suffix is an affix flag string, similarly in dictionary files */
156 int put_word_suffix(const char * word
, const char * suffix
);
157 char * morph_with_correction(const char * word
);
159 /* spec. suggestions */
160 int suggest_auto(char*** slst
, const char * word
);
161 int suggest_pos_stems(char*** slst
, const char * word
);
165 int cleanword(char *, const char *, int * pcaptype
, int * pabbrev
);
166 int cleanword2(char *, const char *, w_char
*, int * w_len
, int * pcaptype
, int * pabbrev
);
167 void mkinitcap(char *);
168 int mkinitcap2(char * p
, w_char
* u
, int nc
);
169 int mkinitsmall2(char * p
, w_char
* u
, int nc
);
170 void mkallcap(char *);
171 int mkallcap2(char * p
, w_char
* u
, int nc
);
172 void mkallsmall(char *);
173 int mkallsmall2(char * p
, w_char
* u
, int nc
);
174 struct hentry
* checkword(const char *, int * info
, char **root
);
175 char * sharps_u8_l1(char * dest
, char * source
);
176 hentry
* spellsharps(char * base
, char *, int, int, char * tmp
, int * info
, char **root
);
177 int is_keepcase(const hentry
* rv
);
178 int insert_sug(char ***slst
, char * word
, int ns
);
179 void cat_result(char * result
, char * st
);
180 char * stem_description(const char * desc
);
181 int spellml(char*** slst
, const char * word
);
182 int get_xml_par(char * dest
, const char * par
, int maxl
);
183 const char * get_xml_pos(const char * s
, const char * attr
);
184 int get_xml_list(char ***slst
, char * list
, const char * tag
);
185 int check_xml_par(const char * q
, const char * attr
, const char * value
);