Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
c63c1946
Commit
c63c1946
authored
Nov 17, 2003
by
Teodor Sigaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize. Improve ispell support for compound words. This work was sponsored by ABC Startsiden AS.
parent
6a04c571
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
706 additions
and
294 deletions
+706
-294
contrib/tsearch2/dict_ispell.c
contrib/tsearch2/dict_ispell.c
+6
-6
contrib/tsearch2/ispell/spell.c
contrib/tsearch2/ispell/spell.c
+629
-276
contrib/tsearch2/ispell/spell.h
contrib/tsearch2/ispell/spell.h
+71
-12
No files found.
contrib/tsearch2/dict_ispell.c
View file @
c63c1946
...
...
@@ -27,7 +27,7 @@ Datum spell_lexize(PG_FUNCTION_ARGS);
static
void
freeDictISpell
(
DictISpell
*
d
)
{
FreeIspell
(
&
(
d
->
obj
));
NIFree
(
&
(
d
->
obj
));
freestoplist
(
&
(
d
->
stoplist
));
free
(
d
);
}
...
...
@@ -71,7 +71,7 @@ spell_init(PG_FUNCTION_ARGS)
(
errcode
(
ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE
),
errmsg
(
"dictionary already loaded"
)));
}
if
(
ImportDictionary
(
&
(
d
->
obj
),
pcfg
->
value
))
if
(
NI
ImportDictionary
(
&
(
d
->
obj
),
pcfg
->
value
))
{
freeDictISpell
(
d
);
ereport
(
ERROR
,
...
...
@@ -90,7 +90,7 @@ spell_init(PG_FUNCTION_ARGS)
(
errcode
(
ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE
),
errmsg
(
"affixes already loaded"
)));
}
if
(
ImportAffixes
(
&
(
d
->
obj
),
pcfg
->
value
))
if
(
NI
ImportAffixes
(
&
(
d
->
obj
),
pcfg
->
value
))
{
freeDictISpell
(
d
);
ereport
(
ERROR
,
...
...
@@ -132,8 +132,8 @@ spell_init(PG_FUNCTION_ARGS)
if
(
affloaded
&&
dictloaded
)
{
SortDictionary
(
&
(
d
->
obj
));
SortAffixes
(
&
(
d
->
obj
));
NI
SortDictionary
(
&
(
d
->
obj
));
NI
SortAffixes
(
&
(
d
->
obj
));
}
else
if
(
!
affloaded
)
{
...
...
@@ -168,7 +168,7 @@ spell_lexize(PG_FUNCTION_ARGS)
res
=
palloc
(
sizeof
(
char
*
)
*
2
);
txt
=
pnstrdup
(
in
,
PG_GETARG_INT32
(
2
));
res
=
NormalizeWord
(
&
(
d
->
obj
),
txt
);
res
=
N
IN
ormalizeWord
(
&
(
d
->
obj
),
txt
);
pfree
(
txt
);
if
(
res
==
NULL
)
...
...
contrib/tsearch2/ispell/spell.c
View file @
c63c1946
This diff is collapsed.
Click to expand it.
contrib/tsearch2/ispell/spell.h
View file @
c63c1946
...
...
@@ -4,15 +4,43 @@
#include <sys/types.h>
#include <regex.h>
struct
SPNode
;
typedef
struct
{
u_int32_t
val:
8
,
isword:
1
,
compoundallow:
1
,
affix:
22
;
struct
SPNode
*
node
;
}
SPNodeData
;
typedef
struct
SPNode
{
u_int32_t
length
;
SPNodeData
data
[
1
];
}
SPNode
;
#define SPNHRDSZ (sizeof(u_int32_t))
typedef
struct
spell_struct
{
char
*
word
;
char
flag
[
10
];
union
{
char
flag
[
16
];
struct
{
int
affix
;
int
len
;
}
d
;
}
p
;
}
SPELL
;
typedef
struct
aff_struct
{
char
flag
;
char
flagflags
;
char
type
;
char
mask
[
33
];
char
find
[
16
];
...
...
@@ -22,35 +50,66 @@ typedef struct aff_struct
char
compile
;
}
AFFIX
;
#define FF_CROSSPRODUCT 0x01
#define FF_COMPOUNDWORD 0x02
#define FF_COMPOUNDONLYAFX 0x04
struct
AffixNode
;
typedef
struct
{
u_int32_t
val:
8
,
naff:
24
;
AFFIX
**
aff
;
struct
AffixNode
*
node
;
}
AffixNodeData
;
typedef
struct
AffixNode
{
u_int32_t
length
;
AffixNodeData
data
[
1
];
}
AffixNode
;
#define ANHRDSZ (sizeof(u_int32_t))
typedef
struct
Tree_struct
{
int
Left
[
256
],
Right
[
256
];
}
Tree_struct
;
typedef
struct
{
char
*
affix
;
int
len
;
}
CMPDAffix
;
typedef
struct
{
int
maffixes
;
int
naffixes
;
AFFIX
*
Affix
;
char
compoundcontrol
;
int
nspell
;
int
mspell
;
SPELL
*
Spell
;
Tree_struct
SpellTree
;
Tree_struct
PrefixTree
;
Tree_struct
SuffixTree
;
AffixNode
*
Suffix
;
AffixNode
*
Prefix
;
SPNode
*
Dictionary
;
char
**
AffixData
;
CMPDAffix
*
CompoundAffix
;
}
IspellDict
;
char
**
NormalizeWord
(
IspellDict
*
Conf
,
char
*
word
);
int
ImportAffixes
(
IspellDict
*
Conf
,
const
char
*
filename
);
int
ImportDictionary
(
IspellDict
*
Conf
,
const
char
*
filename
);
char
**
N
IN
ormalizeWord
(
IspellDict
*
Conf
,
char
*
word
);
int
NI
ImportAffixes
(
IspellDict
*
Conf
,
const
char
*
filename
);
int
NI
ImportDictionary
(
IspellDict
*
Conf
,
const
char
*
filename
);
int
AddSpell
(
IspellDict
*
Conf
,
const
char
*
word
,
const
char
*
flag
);
int
AddAffix
(
IspellDict
*
Conf
,
int
flag
,
const
char
*
mask
,
const
char
*
find
,
const
char
*
repl
,
int
type
);
void
SortDictionary
(
IspellDict
*
Conf
);
void
SortAffixes
(
IspellDict
*
Conf
);
void
FreeIspell
(
IspellDict
*
Conf
);
int
NI
AddSpell
(
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
NI
SortDictionary
(
IspellDict
*
Conf
);
void
NI
SortAffixes
(
IspellDict
*
Conf
);
void
NIFree
(
IspellDict
*
Conf
);
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment