summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTeodor Sigaev <teodor@sigaev.ru>2016-03-17 17:23:38 +0300
committerTeodor Sigaev <teodor@sigaev.ru>2016-03-17 17:23:38 +0300
commitf4ceed6ceba31a72ed7a726fef05d211641f283c (patch)
tree67e120d2148f9f8093866864d8229eec9e33b9ce /src/include
parent0218e8b3fa7ec72af441ac6f80927bff0d497334 (diff)
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
Diffstat (limited to 'src/include')
-rw-r--r--src/include/tsearch/dicts/spell.h44
1 files changed, 37 insertions, 7 deletions
diff --git a/src/include/tsearch/dicts/spell.h b/src/include/tsearch/dicts/spell.h
index 8116bd20160..cbd51742098 100644
--- a/src/include/tsearch/dicts/spell.h
+++ b/src/include/tsearch/dicts/spell.h
@@ -45,7 +45,7 @@ typedef struct
#define FF_COMPOUNDLAST 0x08
#define FF_COMPOUNDFLAG ( FF_COMPOUNDBEGIN | FF_COMPOUNDMIDDLE | \
FF_COMPOUNDLAST )
-#define FF_DICTFLAGMASK 0x0f
+#define FF_COMPOUNDFLAGMASK 0x0f
typedef struct SPNode
{
@@ -86,7 +86,7 @@ typedef struct spell_struct
*/
typedef struct aff_struct
{
- uint32 flag:16;
+ char *flag;
/* FF_SUFFIX or FF_PREFIX */
uint32 type:1,
flagflags:7,
@@ -146,14 +146,34 @@ typedef struct
bool issuffix;
} CMPDAffix;
+/*
+ * Type of encoding affix flags in Hunspel dictionaries
+ */
typedef enum
{
- FM_CHAR,
- FM_LONG,
- FM_NUM
+ FM_CHAR, /* one character (like ispell) */
+ FM_LONG, /* two characters */
+ FM_NUM /* number, >= 0 and < 65536 */
} 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)
typedef struct
@@ -174,11 +194,21 @@ typedef struct
CMPDAffix *CompoundAffix;
- unsigned char flagval[FLAGNUM_MAXSIZE];
bool usecompound;
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
* set up by NIStartBuild and cleared by NIFinishBuild.
*/