4 #include "affixmgr.hxx"
5 #include "suggestmgr.hxx"
8 #define SPELL_XML "<?xml?>"
11 #define MAXSUGGESTION 15
14 #define HUNSPELL_OK (1 << 0)
15 #define HUNSPELL_OK_WARN (1 << 1)
17 #ifndef _MYSPELLMGR_HXX_
18 #define _MYSPELLMGR_HXX_
20 class LIBHUNSPELL_DLL_EXPORTED Hunspell
23 HashMgr
* pHMgr
[MAXDIC
];
28 struct cs_info
* csconv
;
36 /* Hunspell(aff, dic) - constructor of Hunspell class
37 * input: path of affix file and dictionary file
40 Hunspell(const char * affpath
, const char * dpath
, const char * key
= NULL
);
43 /* load extra dictionaries (only dic files) */
44 int add_dic(const char * dpath
, const char * key
= NULL
);
46 /* spell(word) - spellcheck word
47 * output: 0 = bad word, not 0 = good word
50 * info: information bit array, fields:
51 * SPELL_COMPOUND = a compound word
52 * SPELL_FORBIDDEN = an explicit forbidden word
53 * root: root (stem), when input is a word with affix(es)
56 int spell(const char * word
, int * info
= NULL
, char ** root
= NULL
);
58 /* suggest(suggestions, word) - search suggestions
59 * input: pointer to an array of strings pointer and the (bad) word
60 * array of strings pointer (here *slst) may not be initialized
61 * output: number of suggestions in string array, and suggestions in
62 * a newly allocated array of strings (*slts will be NULL when number
63 * of suggestion equals 0.)
66 int suggest(char*** slst
, const char * word
);
68 /* deallocate suggestion lists */
70 void free_list(char *** slst
, int n
);
72 char * get_dic_encoding();
74 /* morphological functions */
76 /* analyze(result, word) - morphological analysis of the word */
78 int analyze(char*** slst
, const char * word
);
80 /* stem(result, word) - stemmer function */
82 int stem(char*** slst
, const char * word
);
84 /* stem(result, analysis, n) - get stems from a morph. analysis
86 * char ** result, result2;
87 * int n1 = analyze(&result, "words");
88 * int n2 = stem(&result2, result, n1);
91 int stem(char*** slst
, char ** morph
, int n
);
93 /* generate(result, word, word2) - morphological generation by example(s) */
95 int generate(char*** slst
, const char * word
, const char * word2
);
97 /* generate(result, word, desc, n) - generation by morph. description(s)
100 * char * affix = "is:plural"; // description depends from dictionaries, too
101 * int n = generate(&result, "word", &affix, 1);
102 * for (int i = 0; i < n; i++) printf("%s\n", result[i]);
105 int generate(char*** slst
, const char * word
, char ** desc
, int n
);
107 /* functions for run-time modification of the dictionary */
109 /* add word to the run-time dictionary */
111 int add(const char * word
);
113 /* add word to the run-time dictionary with affix flags of
114 * the example (a dictionary word): Hunspell will recognize
115 * affixed forms of the new word, too.
118 int add_with_affix(const char * word
, const char * example
);
120 /* remove word from the run-time dictionary */
122 int remove(const char * word
);
126 /* get extra word characters definied in affix file for tokenization */
127 const char * get_wordchars();
128 unsigned short * get_wordchars_utf16(int * len
);
130 struct cs_info
* get_csconv();
131 const char * get_version();
133 int get_langnum() const;
135 /* experimental and deprecated functions */
137 #ifdef HUNSPELL_EXPERIMENTAL
138 /* suffix is an affix flag string, similarly in dictionary files */
139 int put_word_suffix(const char * word
, const char * suffix
);
140 char * morph_with_correction(const char * word
);
142 /* spec. suggestions */
143 int suggest_auto(char*** slst
, const char * word
);
144 int suggest_pos_stems(char*** slst
, const char * word
);
148 int cleanword(char *, const char *, int * pcaptype
, int * pabbrev
);
149 int cleanword2(char *, const char *, w_char
*, int * w_len
, int * pcaptype
, int * pabbrev
);
150 void mkinitcap(char *);
151 int mkinitcap2(char * p
, w_char
* u
, int nc
);
152 int mkinitsmall2(char * p
, w_char
* u
, int nc
);
153 void mkallcap(char *);
154 int mkallcap2(char * p
, w_char
* u
, int nc
);
155 void mkallsmall(char *);
156 int mkallsmall2(char * p
, w_char
* u
, int nc
);
157 struct hentry
* checkword(const char *, int * info
, char **root
);
158 char * sharps_u8_l1(char * dest
, char * source
);
159 hentry
* spellsharps(char * base
, char *, int, int, char * tmp
, int * info
, char **root
);
160 int is_keepcase(const hentry
* rv
);
161 int insert_sug(char ***slst
, char * word
, int ns
);
162 void cat_result(char * result
, char * st
);
163 char * stem_description(const char * desc
);
164 int spellml(char*** slst
, const char * word
);
165 int get_xml_par(char * dest
, const char * par
, int maxl
);
166 const char * get_xml_pos(const char * s
, const char * attr
);
167 int get_xml_list(char ***slst
, char * list
, const char * tag
);
168 int check_xml_par(const char * q
, const char * attr
, const char * value
);