| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #ifndef __SPELL_H__ |
| #define __SPELL_H__ |
|
|
| #include "regex/regex.h" |
| #include "tsearch/dicts/regis.h" |
| #include "tsearch/ts_public.h" |
|
|
| |
| |
| |
| |
| struct SPNode; |
|
|
| typedef struct |
| { |
| uint32 val:8, |
| isword:1, |
| |
| compoundflag:4, |
| |
| affix:19; |
| struct SPNode *node; |
| } SPNodeData; |
|
|
| |
| |
| |
| |
| #define FF_COMPOUNDONLY 0x01 |
| #define FF_COMPOUNDBEGIN 0x02 |
| #define FF_COMPOUNDMIDDLE 0x04 |
| #define FF_COMPOUNDLAST 0x08 |
| #define FF_COMPOUNDFLAG ( FF_COMPOUNDBEGIN | FF_COMPOUNDMIDDLE | \ |
| FF_COMPOUNDLAST ) |
| #define FF_COMPOUNDFLAGMASK 0x0f |
|
|
| typedef struct SPNode |
| { |
| uint32 length; |
| SPNodeData data[FLEXIBLE_ARRAY_MEMBER]; |
| } SPNode; |
|
|
| #define SPNHDRSZ (offsetof(SPNode,data)) |
|
|
| |
| |
| |
| typedef struct spell_struct |
| { |
| union |
| { |
| |
| |
| |
| |
| char *flag; |
| |
| struct |
| { |
| |
| int affix; |
| |
| int len; |
| } d; |
| } p; |
| char word[FLEXIBLE_ARRAY_MEMBER]; |
| } SPELL; |
|
|
| #define SPELLHDRSZ (offsetof(SPELL, word)) |
|
|
| |
| |
| |
| typedef struct aff_struct |
| { |
| char *flag; |
| |
| uint32 type:1, |
| flagflags:7, |
| issimple:1, |
| isregis:1, |
| replen:14; |
| char *find; |
| char *repl; |
| union |
| { |
| |
| |
| |
| |
| |
| regex_t *pregex; |
| Regis regis; |
| } reg; |
| } AFFIX; |
|
|
| |
| |
| |
| #define FF_COMPOUNDPERMITFLAG 0x10 |
| #define FF_COMPOUNDFORBIDFLAG 0x20 |
| #define FF_CROSSPRODUCT 0x40 |
|
|
| |
| |
| |
| |
| #define FF_SUFFIX 1 |
| #define FF_PREFIX 0 |
|
|
| |
| |
| |
| |
| struct AffixNode; |
|
|
| typedef struct |
| { |
| uint32 val:8, |
| naff:24; |
| AFFIX **aff; |
| struct AffixNode *node; |
| } AffixNodeData; |
|
|
| typedef struct AffixNode |
| { |
| uint32 isvoid:1, |
| length:31; |
| AffixNodeData data[FLEXIBLE_ARRAY_MEMBER]; |
| } AffixNode; |
|
|
| #define ANHRDSZ (offsetof(AffixNode, data)) |
|
|
| typedef struct |
| { |
| char *affix; |
| int len; |
| bool issuffix; |
| } CMPDAffix; |
|
|
| |
| |
| |
| typedef enum |
| { |
| FM_CHAR, |
| FM_LONG, |
| FM_NUM |
| } FlagMode; |
|
|
| |
| |
| |
| |
| typedef struct CompoundAffixFlag |
| { |
| union |
| { |
| |
| char *s; |
| |
| uint32 i; |
| } flag; |
| |
| FlagMode flagMode; |
| uint32 value; |
| } CompoundAffixFlag; |
|
|
| #define FLAGNUM_MAXSIZE (1 << 16) |
|
|
| typedef struct |
| { |
| int maffixes; |
| int naffixes; |
| AFFIX *Affix; |
|
|
| AffixNode *Suffix; |
| AffixNode *Prefix; |
|
|
| SPNode *Dictionary; |
| |
| char **AffixData; |
| int lenAffixData; |
| int nAffixData; |
| bool useFlagAliases; |
|
|
| CMPDAffix *CompoundAffix; |
|
|
| bool usecompound; |
| FlagMode flagMode; |
|
|
| |
| |
| |
|
|
| |
| CompoundAffixFlag *CompoundAffixFlags; |
| |
| int nCompoundAffixFlag; |
| |
| int mCompoundAffixFlag; |
|
|
| |
| |
| |
| |
| MemoryContext buildCxt; |
|
|
| |
| SPELL **Spell; |
| int nspell; |
| int mspell; |
|
|
| |
| char *firstfree; |
| size_t avail; |
| } IspellDict; |
|
|
| extern TSLexeme *NINormalizeWord(IspellDict *Conf, char *word); |
|
|
| extern void NIStartBuild(IspellDict *Conf); |
| extern void NIImportAffixes(IspellDict *Conf, const char *filename); |
| extern void NIImportDictionary(IspellDict *Conf, const char *filename); |
| extern void NISortDictionary(IspellDict *Conf); |
| extern void NISortAffixes(IspellDict *Conf); |
| extern void NIFinishBuild(IspellDict *Conf); |
|
|
| #endif |
|
|