Skip to content

Commit a25f420

Browse files
author
Artur Zakirov
committed
affix file is created in current backend to avoid regex_t structure copying
1 parent 8e3f3e1 commit a25f420

10 files changed

+1010
-1637
lines changed

Diff for: Makefile

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1+
# contrib/shared_ispell/Makefile
2+
13
MODULE_big = shared_ispell
2-
OBJS = src/shared_ispell.o src/spell.o
4+
OBJS = src/shared_ispell.o
35

46
EXTENSION = shared_ispell
5-
DATA = sql/shared_ispell--1.0.0.sql
6-
MODULES = shared_ispell
7+
DATA = sql/shared_ispell--1.1.0.sql
78

8-
CFLAGS=`pg_config --includedir-server`
9+
REGRESS = shared_ispell
910

11+
ifdef USE_PGXS
1012
PG_CONFIG = pg_config
1113
PGXS := $(shell $(PG_CONFIG) --pgxs)
1214
include $(PGXS)
13-
14-
all: shared_ispell.so
15-
16-
shared_ispell.so: $(OBJS)
17-
18-
%.o : src/%.c
15+
else
16+
subdir = contrib/shared_ispell
17+
top_builddir = ../..
18+
include $(top_builddir)/src/Makefile.global
19+
include $(top_srcdir)/contrib/contrib-global.mk
20+
endif

Diff for: README.md

+1-10
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,6 @@ If you need just snowball-type dictionaries, this extension is not
1313
really interesting for you. But if you really need an ispell
1414
dictionary, this may save you a lot of resources.
1515

16-
Warning
17-
-------
18-
The extension does not yet handle affixes that require full regular
19-
expressions (regex_t, implemented in regex.h). This is indicated by
20-
an error when initializing the dictionary.
21-
22-
Simple affixes and affixes that can be handled by fast regex subset
23-
(as implemented in regis.h) are handled just fine.
24-
2516

2617
Install
2718
-------
@@ -144,4 +135,4 @@ use this prepared data).
144135

145136
db=# SELECT shared_ispell_reset();
146137

147-
That's all for now ...
138+
That's all for now ...

Diff for: expected/shared_ispell.out

+193
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
CREATE EXTENSION shared_ispell;
2+
-- Test ISpell dictionary with ispell affix file
3+
CREATE TEXT SEARCH DICTIONARY shared_ispell (
4+
Template=shared_ispell,
5+
DictFile=ispell_sample,
6+
AffFile=ispell_sample
7+
);
8+
SELECT ts_lexize('shared_ispell', 'skies');
9+
ts_lexize
10+
-----------
11+
{sky}
12+
(1 row)
13+
14+
SELECT ts_lexize('shared_ispell', 'bookings');
15+
ts_lexize
16+
----------------
17+
{booking,book}
18+
(1 row)
19+
20+
SELECT ts_lexize('shared_ispell', 'booking');
21+
ts_lexize
22+
----------------
23+
{booking,book}
24+
(1 row)
25+
26+
SELECT ts_lexize('shared_ispell', 'foot');
27+
ts_lexize
28+
-----------
29+
{foot}
30+
(1 row)
31+
32+
SELECT ts_lexize('shared_ispell', 'foots');
33+
ts_lexize
34+
-----------
35+
{foot}
36+
(1 row)
37+
38+
SELECT ts_lexize('shared_ispell', 'rebookings');
39+
ts_lexize
40+
----------------
41+
{booking,book}
42+
(1 row)
43+
44+
SELECT ts_lexize('shared_ispell', 'rebooking');
45+
ts_lexize
46+
----------------
47+
{booking,book}
48+
(1 row)
49+
50+
SELECT ts_lexize('shared_ispell', 'rebook');
51+
ts_lexize
52+
-----------
53+
54+
(1 row)
55+
56+
SELECT ts_lexize('shared_ispell', 'unbookings');
57+
ts_lexize
58+
-----------
59+
{book}
60+
(1 row)
61+
62+
SELECT ts_lexize('shared_ispell', 'unbooking');
63+
ts_lexize
64+
-----------
65+
{book}
66+
(1 row)
67+
68+
SELECT ts_lexize('shared_ispell', 'unbook');
69+
ts_lexize
70+
-----------
71+
{book}
72+
(1 row)
73+
74+
SELECT ts_lexize('shared_ispell', 'footklubber');
75+
ts_lexize
76+
----------------
77+
{foot,klubber}
78+
(1 row)
79+
80+
SELECT ts_lexize('shared_ispell', 'footballklubber');
81+
ts_lexize
82+
------------------------------------------------------
83+
{footballklubber,foot,ball,klubber,football,klubber}
84+
(1 row)
85+
86+
SELECT ts_lexize('shared_ispell', 'ballyklubber');
87+
ts_lexize
88+
----------------
89+
{ball,klubber}
90+
(1 row)
91+
92+
SELECT ts_lexize('shared_ispell', 'footballyklubber');
93+
ts_lexize
94+
---------------------
95+
{foot,ball,klubber}
96+
(1 row)
97+
98+
-- Test ISpell dictionary with hunspell affix file
99+
CREATE TEXT SEARCH DICTIONARY shared_hunspell (
100+
Template=shared_ispell,
101+
DictFile=ispell_sample,
102+
AffFile=hunspell_sample
103+
);
104+
SELECT ts_lexize('shared_hunspell', 'skies');
105+
ts_lexize
106+
-----------
107+
{sky}
108+
(1 row)
109+
110+
SELECT ts_lexize('shared_hunspell', 'bookings');
111+
ts_lexize
112+
----------------
113+
{booking,book}
114+
(1 row)
115+
116+
SELECT ts_lexize('shared_hunspell', 'booking');
117+
ts_lexize
118+
----------------
119+
{booking,book}
120+
(1 row)
121+
122+
SELECT ts_lexize('shared_hunspell', 'foot');
123+
ts_lexize
124+
-----------
125+
{foot}
126+
(1 row)
127+
128+
SELECT ts_lexize('shared_hunspell', 'foots');
129+
ts_lexize
130+
-----------
131+
{foot}
132+
(1 row)
133+
134+
SELECT ts_lexize('shared_hunspell', 'rebookings');
135+
ts_lexize
136+
----------------
137+
{booking,book}
138+
(1 row)
139+
140+
SELECT ts_lexize('shared_hunspell', 'rebooking');
141+
ts_lexize
142+
----------------
143+
{booking,book}
144+
(1 row)
145+
146+
SELECT ts_lexize('shared_hunspell', 'rebook');
147+
ts_lexize
148+
-----------
149+
150+
(1 row)
151+
152+
SELECT ts_lexize('shared_hunspell', 'unbookings');
153+
ts_lexize
154+
-----------
155+
{book}
156+
(1 row)
157+
158+
SELECT ts_lexize('shared_hunspell', 'unbooking');
159+
ts_lexize
160+
-----------
161+
{book}
162+
(1 row)
163+
164+
SELECT ts_lexize('shared_hunspell', 'unbook');
165+
ts_lexize
166+
-----------
167+
{book}
168+
(1 row)
169+
170+
SELECT ts_lexize('shared_hunspell', 'footklubber');
171+
ts_lexize
172+
----------------
173+
{foot,klubber}
174+
(1 row)
175+
176+
SELECT ts_lexize('shared_hunspell', 'footballklubber');
177+
ts_lexize
178+
------------------------------------------------------
179+
{footballklubber,foot,ball,klubber,football,klubber}
180+
(1 row)
181+
182+
SELECT ts_lexize('shared_hunspell', 'ballyklubber');
183+
ts_lexize
184+
----------------
185+
{ball,klubber}
186+
(1 row)
187+
188+
SELECT ts_lexize('shared_hunspell', 'footballyklubber');
189+
ts_lexize
190+
---------------------
191+
{foot,ball,klubber}
192+
(1 row)
193+

Diff for: shared_ispell.control

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# shared ispell dictionary
22
comment = 'Provides shared ispell dictionaries.'
3-
default_version = '1.0.0'
3+
default_version = '1.1.0'
44
relocatable = true
55

66
module_pathname = '$libdir/shared_ispell'
File renamed without changes.

Diff for: sql/shared_ispell.sql

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
CREATE EXTENSION shared_ispell;
2+
3+
-- Test ISpell dictionary with ispell affix file
4+
CREATE TEXT SEARCH DICTIONARY shared_ispell (
5+
Template=shared_ispell,
6+
DictFile=ispell_sample,
7+
AffFile=ispell_sample
8+
);
9+
10+
SELECT ts_lexize('shared_ispell', 'skies');
11+
SELECT ts_lexize('shared_ispell', 'bookings');
12+
SELECT ts_lexize('shared_ispell', 'booking');
13+
SELECT ts_lexize('shared_ispell', 'foot');
14+
SELECT ts_lexize('shared_ispell', 'foots');
15+
SELECT ts_lexize('shared_ispell', 'rebookings');
16+
SELECT ts_lexize('shared_ispell', 'rebooking');
17+
SELECT ts_lexize('shared_ispell', 'rebook');
18+
SELECT ts_lexize('shared_ispell', 'unbookings');
19+
SELECT ts_lexize('shared_ispell', 'unbooking');
20+
SELECT ts_lexize('shared_ispell', 'unbook');
21+
22+
SELECT ts_lexize('shared_ispell', 'footklubber');
23+
SELECT ts_lexize('shared_ispell', 'footballklubber');
24+
SELECT ts_lexize('shared_ispell', 'ballyklubber');
25+
SELECT ts_lexize('shared_ispell', 'footballyklubber');
26+
27+
-- Test ISpell dictionary with hunspell affix file
28+
CREATE TEXT SEARCH DICTIONARY shared_hunspell (
29+
Template=shared_ispell,
30+
DictFile=ispell_sample,
31+
AffFile=hunspell_sample
32+
);
33+
34+
SELECT ts_lexize('shared_hunspell', 'skies');
35+
SELECT ts_lexize('shared_hunspell', 'bookings');
36+
SELECT ts_lexize('shared_hunspell', 'booking');
37+
SELECT ts_lexize('shared_hunspell', 'foot');
38+
SELECT ts_lexize('shared_hunspell', 'foots');
39+
SELECT ts_lexize('shared_hunspell', 'rebookings');
40+
SELECT ts_lexize('shared_hunspell', 'rebooking');
41+
SELECT ts_lexize('shared_hunspell', 'rebook');
42+
SELECT ts_lexize('shared_hunspell', 'unbookings');
43+
SELECT ts_lexize('shared_hunspell', 'unbooking');
44+
SELECT ts_lexize('shared_hunspell', 'unbook');
45+
46+
SELECT ts_lexize('shared_hunspell', 'footklubber');
47+
SELECT ts_lexize('shared_hunspell', 'footballklubber');
48+
SELECT ts_lexize('shared_hunspell', 'ballyklubber');
49+
SELECT ts_lexize('shared_hunspell', 'footballyklubber');

0 commit comments

Comments
 (0)