2003-07-21 18:27:44 +08:00
|
|
|
#ifndef __SPELL_H__
|
|
|
|
#define __SPELL_H__
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
2004-05-31 21:29:43 +08:00
|
|
|
#include "regex/regex.h"
|
2003-12-10 23:54:58 +08:00
|
|
|
#include "c.h"
|
2003-11-18 01:34:35 +08:00
|
|
|
|
2005-01-25 23:24:38 +08:00
|
|
|
#include "regis.h"
|
|
|
|
#include "dict.h"
|
|
|
|
|
2003-11-18 01:34:35 +08:00
|
|
|
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;
|
2003-11-18 01:34:35 +08:00
|
|
|
|
2003-12-10 23:54:58 +08:00
|
|
|
#define SPNHRDSZ (sizeof(uint32))
|
2003-11-18 01:34:35 +08:00
|
|
|
|
|
|
|
|
2003-08-04 08:43:34 +08:00
|
|
|
typedef struct spell_struct
|
|
|
|
{
|
|
|
|
char *word;
|
2004-08-29 13:07:03 +08:00
|
|
|
union
|
|
|
|
{
|
2003-11-18 01:34:35 +08:00
|
|
|
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;
|
2005-01-12 00:07:55 +08:00
|
|
|
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
|
2003-11-18 01:34:35 +08:00
|
|
|
|
|
|
|
struct AffixNode;
|
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
2003-12-10 23:54:58 +08:00
|
|
|
uint32
|
2004-08-29 13:07:03 +08:00
|
|
|
val:8,
|
|
|
|
naff:24;
|
|
|
|
AFFIX **aff;
|
2003-11-18 01:34:35 +08:00
|
|
|
struct AffixNode *node;
|
2004-08-29 13:07:03 +08:00
|
|
|
} AffixNodeData;
|
2003-11-18 01:34:35 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
typedef struct AffixNode
|
|
|
|
{
|
|
|
|
uint32 isvoid:1,
|
|
|
|
length:31;
|
|
|
|
AffixNodeData data[1];
|
|
|
|
} AffixNode;
|
2003-11-18 01:34:35 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
#define ANHRDSZ (sizeof(uint32))
|
2003-11-18 01:34:35 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char *affix;
|
|
|
|
int len;
|
|
|
|
} CMPDAffix;
|
2003-11-18 01:34:35 +08:00
|
|
|
|
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;
|
2003-11-18 01:34:35 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
AffixNode *Suffix;
|
|
|
|
AffixNode *Prefix;
|
2003-11-18 01:34:35 +08:00
|
|
|
|
2004-08-29 13:07:03 +08:00
|
|
|
SPNode *Dictionary;
|
|
|
|
char **AffixData;
|
|
|
|
CMPDAffix *CompoundAffix;
|
2003-08-04 08:43:34 +08:00
|
|
|
|
|
|
|
} IspellDict;
|
|
|
|
|
2005-01-25 23:24:38 +08:00
|
|
|
TSLexeme *NINormalizeWord(IspellDict * Conf, char *word);
|
2003-11-18 01:34:35 +08:00
|
|
|
int NIImportAffixes(IspellDict * Conf, const char *filename);
|
|
|
|
int NIImportDictionary(IspellDict * Conf, const char *filename);
|
2003-08-04 08:43:34 +08:00
|
|
|
|
2003-11-18 01:34:35 +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
|