postgresql/contrib/tsearch2/ispell/spell.h

131 lines
2.0 KiB
C
Raw Normal View History

2003-07-21 18:27:44 +08:00
#ifndef __SPELL_H__
#define __SPELL_H__
#include <sys/types.h>
#include "regex/regex.h"
#include "c.h"
#include "regis.h"
#include "dict.h"
struct SPNode;
2004-08-29 13:07:03 +08:00
typedef struct
{
uint32
val:8,
isword:1,
compoundallow:1,
affix:22;
struct SPNode *node;
} SPNodeData;
typedef struct SPNode
{
uint32 length;
SPNodeData data[1];
} SPNode;
#define SPNHRDSZ (sizeof(uint32))
2003-08-04 08:43:34 +08:00
typedef struct spell_struct
{
char *word;
2004-08-29 13:07:03 +08:00
union
{
char flag[16];
2004-08-29 13:07:03 +08:00
struct
{
int affix;
int len;
} d;
} p;
2003-08-04 08:43:34 +08:00
} SPELL;
typedef struct aff_struct
{
2004-08-29 13:07:03 +08:00
uint32
flag:8,
type:2,
compile:1,
flagflags:3,
issimple:1,
isregis:1,
unused:1,
replen:16;
char *mask;
char *find;
char *repl;
2004-08-29 13:07:03 +08:00
union
{
regex_t regex;
Regis regis;
} reg;
2003-08-04 08:43:34 +08:00
} AFFIX;
2004-08-29 13:07:03 +08:00
#define FF_CROSSPRODUCT 0x01
#define FF_COMPOUNDWORD 0x02
#define FF_COMPOUNDONLYAFX 0x04
#define FF_SUFFIX 2
#define FF_PREFIX 1
struct AffixNode;
2004-08-29 13:07:03 +08:00
typedef struct
{
uint32
2004-08-29 13:07:03 +08:00
val:8,
naff:24;
AFFIX **aff;
struct AffixNode *node;
2004-08-29 13:07:03 +08:00
} AffixNodeData;
2004-08-29 13:07:03 +08:00
typedef struct AffixNode
{
uint32 isvoid:1,
length:31;
AffixNodeData data[1];
} AffixNode;
2004-08-29 13:07:03 +08:00
#define ANHRDSZ (sizeof(uint32))
2004-08-29 13:07:03 +08:00
typedef struct
{
char *affix;
int len;
} CMPDAffix;
2003-08-04 08:43:34 +08:00
typedef struct
{
int maffixes;
int naffixes;
AFFIX *Affix;
2004-08-29 13:07:03 +08:00
char compoundcontrol;
2003-08-04 08:43:34 +08:00
int nspell;
int mspell;
SPELL *Spell;
2004-08-29 13:07:03 +08:00
AffixNode *Suffix;
AffixNode *Prefix;
2004-08-29 13:07:03 +08:00
SPNode *Dictionary;
char **AffixData;
CMPDAffix *CompoundAffix;
2003-08-04 08:43:34 +08:00
} IspellDict;
TSLexeme *NINormalizeWord(IspellDict * Conf, char *word);
int NIImportAffixes(IspellDict * Conf, const char *filename);
int NIImportDictionary(IspellDict * Conf, const char *filename);
2003-08-04 08:43:34 +08:00
int NIAddSpell(IspellDict * Conf, const char *word, const char *flag);
int NIAddAffix(IspellDict * Conf, int flag, char flagflags, const char *mask, const char *find, const char *repl, int type);
void NISortDictionary(IspellDict * Conf);
void NISortAffixes(IspellDict * Conf);
void NIFree(IspellDict * Conf);
2003-07-21 18:27:44 +08:00
#endif