OSDN Git Service

updated igit.exe (fixes for dir status etc)
[tortoisegit/TortoiseGitJp.git] / ext / hunspell / hunspell.hxx
1 #include "license.hunspell"
2 #include "license.myspell"
3
4 #include "hashmgr.hxx"
5 #include "affixmgr.hxx"
6 #include "suggestmgr.hxx"
7 #include "csutil.hxx"
8 #include "langnum.hxx"
9 //#include "config.h"
10
11 #define  SPELL_COMPOUND  (1 << 0)
12 #define  SPELL_FORBIDDEN (1 << 1)
13
14 #define NOCAP   0
15 #define INITCAP 1
16 #define ALLCAP  2
17 #define HUHCAP  3
18 #define HUHINITCAP  4
19
20 #define MAXSUGGESTION 15
21 #define MAXSHARPS 5
22
23 #ifdef W32
24 #define DLLTEST2_API __declspec(dllexport)
25 #endif
26
27 #ifndef _MYSPELLMGR_HXX_
28 #define _MYSPELLMGR_HXX_
29
30 #ifdef W32
31 class DLLTEST2_API Hunspell
32 #else
33 class Hunspell
34 #endif
35 {
36   AffixMgr*       pAMgr;
37   HashMgr*        pHMgr;
38   SuggestMgr*     pSMgr;
39   char *          encoding;
40   struct cs_info * csconv;
41   int             langnum;
42   int             utf8;
43   int             complexprefixes;
44   char**          wordbreak;
45
46 public:
47
48   /* Hunspell(aff, dic) - constructor of Hunspell class
49    * input: path of affix file and dictionary file
50    */
51   
52   Hunspell(const char * affpath, const char * dpath);
53
54   ~Hunspell();
55
56   /* spell(word) - spellcheck word
57    * output: 0 = bad word, not 0 = good word
58    *   
59    * plus output:
60    *   info: information bit array, fields:
61    *     SPELL_COMPOUND  = a compound word 
62    *     SPELL_FORBIDDEN = an explicit forbidden word
63    *   root: root (stem), when input is a word with affix(es)
64    */
65    
66   int spell(const char * word, int * info = NULL, char ** root = NULL);
67
68   /* suggest(suggestions, word) - search suggestions
69    * input: pointer to an array of strings pointer and the (bad) word
70    *   array of strings pointer (here *slst) may not be initialized
71    * output: number of suggestions in string array, and suggestions in
72    *   a newly allocated array of strings (*slts will be NULL when number
73    *   of suggestion equals 0.)
74    */
75
76   int suggest(char*** slst, const char * word);
77   char * get_dic_encoding();
78
79   /* handling custom dictionary */
80   
81   int put_word(const char * word);
82
83   /* pattern is a sample dictionary word 
84    * put word into custom dictionary with affix flags of pattern word
85    */
86   
87   int put_word_pattern(const char * word, const char * pattern);
88
89   /* other */
90
91   /* get extra word characters definied in affix file for tokenization */
92   const char * get_wordchars();
93   unsigned short * get_wordchars_utf16(int * len);
94
95   struct cs_info * get_csconv();
96   const char * get_version();
97
98   /* experimental functions */
99
100 #ifdef HUNSPELL_EXPERIMENTAL
101   /* suffix is an affix flag string, similarly in dictionary files */
102   
103   int put_word_suffix(const char * word, const char * suffix);
104   
105   /* morphological analysis */
106   
107   char * morph(const char * word);
108   int analyze(char*** out, const char *word);
109
110   char * morph_with_correction(const char * word);
111
112   /* stemmer function */
113   
114   int stem(char*** slst, const char * word);
115
116   /* spec. suggestions */
117   int suggest_auto(char*** slst, const char * word);
118   int suggest_pos_stems(char*** slst, const char * word);
119   char * get_possible_root();
120 #endif
121
122 private:
123    int    cleanword(char *, const char *, int * pcaptype, int * pabbrev);
124    int    cleanword2(char *, const char *, w_char *, int * w_len, int * pcaptype, int * pabbrev);
125    void   mkinitcap(char *);
126    int    mkinitcap2(char * p, w_char * u, int nc);
127    int    mkinitsmall2(char * p, w_char * u, int nc);
128    void   mkallcap(char *);
129    int    mkallcap2(char * p, w_char * u, int nc);
130    void   mkallsmall(char *);
131    int    mkallsmall2(char * p, w_char * u, int nc);
132    struct hentry * checkword(const char *, int * info, char **root);
133    char * sharps_u8_l1(char * dest, char * source);
134    hentry * spellsharps(char * base, char *, int, int, char * tmp, int * info, char **root);
135    int    is_keepcase(const hentry * rv);
136    int    insert_sug(char ***slst, char * word, int *ns);
137
138 };
139
140 #endif