Commit f4ceed6c authored by Teodor Sigaev's avatar Teodor Sigaev

Improve support of Hunspell

- allow to use non-ascii characters as affix flag. Non-numeric affix flags now
  are stored as string instead of numeric value of character.
- allow to use 0 as affix flag in numeric encoded affixes

That adds support for arabian, hungarian, turkish and
brazilian portuguese languages.

Author: Artur Zakirov with heavy editorization by me
parent 0218e8b3
This diff is collapsed.
...@@ -45,7 +45,7 @@ typedef struct ...@@ -45,7 +45,7 @@ typedef struct
#define FF_COMPOUNDLAST 0x08 #define FF_COMPOUNDLAST 0x08
#define FF_COMPOUNDFLAG ( FF_COMPOUNDBEGIN | FF_COMPOUNDMIDDLE | \ #define FF_COMPOUNDFLAG ( FF_COMPOUNDBEGIN | FF_COMPOUNDMIDDLE | \
FF_COMPOUNDLAST ) FF_COMPOUNDLAST )
#define FF_DICTFLAGMASK 0x0f #define FF_COMPOUNDFLAGMASK 0x0f
typedef struct SPNode typedef struct SPNode
{ {
...@@ -86,7 +86,7 @@ typedef struct spell_struct ...@@ -86,7 +86,7 @@ typedef struct spell_struct
*/ */
typedef struct aff_struct typedef struct aff_struct
{ {
uint32 flag:16; char *flag;
/* FF_SUFFIX or FF_PREFIX */ /* FF_SUFFIX or FF_PREFIX */
uint32 type:1, uint32 type:1,
flagflags:7, flagflags:7,
...@@ -146,14 +146,34 @@ typedef struct ...@@ -146,14 +146,34 @@ typedef struct
bool issuffix; bool issuffix;
} CMPDAffix; } CMPDAffix;
/*
* Type of encoding affix flags in Hunspel dictionaries
*/
typedef enum typedef enum
{ {
FM_CHAR, FM_CHAR, /* one character (like ispell) */
FM_LONG, FM_LONG, /* two characters */
FM_NUM FM_NUM /* number, >= 0 and < 65536 */
} FlagMode; } FlagMode;
#define FLAGCHAR_MAXSIZE (1 << 8) /*
* Structure to store Hunspell options. Flag representation depends on flag
* type. These flags are about support of compound words.
*/
typedef struct CompoundAffixFlag
{
union
{
/* Flag name if flagMode is FM_CHAR or FM_LONG */
char *s;
/* Flag name if flagMode is FM_NUM */
uint32 i;
} flag;
/* we don't have a bsearch_arg version, so, copy FlagMode */
FlagMode flagMode;
uint32 value;
} CompoundAffixFlag;
#define FLAGNUM_MAXSIZE (1 << 16) #define FLAGNUM_MAXSIZE (1 << 16)
typedef struct typedef struct
...@@ -174,10 +194,20 @@ typedef struct ...@@ -174,10 +194,20 @@ typedef struct
CMPDAffix *CompoundAffix; CMPDAffix *CompoundAffix;
unsigned char flagval[FLAGNUM_MAXSIZE];
bool usecompound; bool usecompound;
FlagMode flagMode; FlagMode flagMode;
/*
* All follow fields are actually needed only for initialization
*/
/* Array of Hunspell options in affix file */
CompoundAffixFlag *CompoundAffixFlags;
/* number of entries in CompoundAffixFlags array */
int nCompoundAffixFlag;
/* allocated length of CompoundAffixFlags array */
int mCompoundAffixFlag;
/* /*
* Remaining fields are only used during dictionary construction; they are * Remaining fields are only used during dictionary construction; they are
* set up by NIStartBuild and cleared by NIFinishBuild. * set up by NIStartBuild and cleared by NIFinishBuild.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment