Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8bf358c

Browse files
committed
Improve regression test coverage for src/backend/tsearch/spell.c.
In passing, throw an error if the AF count is too small, rather thanjust silently discarding extra affix entries.Note that the new regression test cases require installing theupdated src/backend/tsearch/dicts files.Arthur ZakirovDiscussion:https://postgr.es/m/20180413113447.GA32474@zakirov.localdomain
1 parentd25c2ee commit8bf358c

File tree

7 files changed

+77
-6
lines changed

7 files changed

+77
-6
lines changed

‎src/backend/tsearch/dicts/hunspell_sample_long.affix

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
FLAG long
22

3-
AF7
3+
AF11
44
AF cZ#1
55
AF cL#2
66
AF sGsJpUsS#3
77
AF sSpB#4
88
AF cZsS#5
9-
AF sScZs\#6
9+
AF sScZs\sE#6
1010
AF sA#7
11+
AF CaCp#8
12+
AF CcCp#9
13+
AF sD#10
14+
AF sB#11
1115

1216
COMPOUNDFLAG cZ
17+
COMPOUNDBEGIN Ca
18+
COMPOUNDMIDDLE Cb
19+
COMPOUNDEND Cc
20+
COMPOUNDPERMITFLAG Cp
1321
ONLYINCOMPOUND cL
1422

1523
PFX pB Y 1
@@ -28,7 +36,18 @@ SFX sS Y 1
2836
SFX sS 0S[^SXZHY]
2937

3038
SFX sA Y 1
31-
SFX sA YIES[^AEIOU]Y
39+
SFX sA YIES[^AEIOU]Y{1}
3240

41+
SFX sB Y 1
42+
SFX sB 0EDK{1}
43+
44+
# Affixes with compound flags
3345
SFX s\ N 1
3446
SFX s\ 0Y/2[^Y]
47+
48+
SFX sE N 1
49+
SFX sE 0S/2[^S]
50+
51+
# Check duplicate affixes
52+
SFX sD N 1
53+
SFX sD 0S/2[^S]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
book/3
2+
book/11
23
booking/4
34
footballklubber
45
foot/5
56
football/1
67
ball/6
78
klubber/1
89
sky/7
10+
ex-/8
11+
machina/9

‎src/backend/tsearch/dicts/hunspell_sample_num.affix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ SFX 302 0ING[^E]
1818
SFX 303 Y 1
1919
SFX 303 0S[^SXZHY]
2020

21+
# Remove ED suffix from lexeme for base words with K ending
22+
SFX 306 Y 1
23+
SFX 306 0EDK{1}
24+
25+
# Just add Y to lexeme for base words with Y ending
26+
SFX 307 Y 1
27+
SFX 307 Y0Y*
28+
2129
SFX 304 Y 1
2230
SFX 304 YIES[^AEIOU]Y
2331

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
book/302,301,202,303
2+
book/306
23
booking/303,201
34
footballklubber
45
foot/101,303
56
football/101
67
ball/303,101,305
78
klubber/101
8-
sky/304
9+
sky/304,307

‎src/backend/tsearch/spell.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,7 @@ NIImportOOAffixes(IspellDict *Conf, const char *filename)
13031303
{
13041304
Conf->useFlagAliases= true;
13051305
naffix=atoi(sflag);
1306-
if (naffix==0)
1306+
if (naffix<=0)
13071307
ereport(ERROR,
13081308
(errcode(ERRCODE_CONFIG_FILE_ERROR),
13091309
errmsg("invalid number of flag vector aliases")));
@@ -1318,14 +1318,19 @@ NIImportOOAffixes(IspellDict *Conf, const char *filename)
13181318
Conf->AffixData[curaffix]=VoidString;
13191319
curaffix++;
13201320
}
1321-
/* Other linesis aliases */
1321+
/* Other linesare aliases */
13221322
else
13231323
{
13241324
if (curaffix<naffix)
13251325
{
13261326
Conf->AffixData[curaffix]=cpstrdup(Conf,sflag);
13271327
curaffix++;
13281328
}
1329+
else
1330+
ereport(ERROR,
1331+
(errcode(ERRCODE_CONFIG_FILE_ERROR),
1332+
errmsg("number of aliases exceeds specified number %d",
1333+
naffix-1)));
13291334
}
13301335
gotonextline;
13311336
}

‎src/test/regress/expected/tsdicts.out

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,12 @@ SELECT ts_lexize('hunspell_long', 'unbook');
263263
{book}
264264
(1 row)
265265

266+
SELECT ts_lexize('hunspell_long', 'booked');
267+
ts_lexize
268+
-----------
269+
{book}
270+
(1 row)
271+
266272
SELECT ts_lexize('hunspell_long', 'footklubber');
267273
ts_lexize
268274
----------------
@@ -281,12 +287,24 @@ SELECT ts_lexize('hunspell_long', 'ballyklubber');
281287
{ball,klubber}
282288
(1 row)
283289

290+
SELECT ts_lexize('hunspell_long', 'ballsklubber');
291+
ts_lexize
292+
----------------
293+
{ball,klubber}
294+
(1 row)
295+
284296
SELECT ts_lexize('hunspell_long', 'footballyklubber');
285297
ts_lexize
286298
---------------------
287299
{foot,ball,klubber}
288300
(1 row)
289301

302+
SELECT ts_lexize('hunspell_long', 'ex-machina');
303+
ts_lexize
304+
---------------
305+
{ex-,machina}
306+
(1 row)
307+
290308
-- Test ISpell dictionary with hunspell affix file with FLAG num parameter
291309
CREATE TEXT SEARCH DICTIONARY hunspell_num (
292310
Template=ispell,
@@ -299,6 +317,12 @@ SELECT ts_lexize('hunspell_num', 'skies');
299317
{sky}
300318
(1 row)
301319

320+
SELECT ts_lexize('hunspell_num', 'sk');
321+
ts_lexize
322+
-----------
323+
{sky}
324+
(1 row)
325+
302326
SELECT ts_lexize('hunspell_num', 'bookings');
303327
ts_lexize
304328
----------------
@@ -359,6 +383,12 @@ SELECT ts_lexize('hunspell_num', 'unbook');
359383
{book}
360384
(1 row)
361385

386+
SELECT ts_lexize('hunspell_num', 'booked');
387+
ts_lexize
388+
-----------
389+
{book}
390+
(1 row)
391+
362392
SELECT ts_lexize('hunspell_num', 'footklubber');
363393
ts_lexize
364394
----------------

‎src/test/regress/sql/tsdicts.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,14 @@ SELECT ts_lexize('hunspell_long', 'rebook');
6666
SELECT ts_lexize('hunspell_long','unbookings');
6767
SELECT ts_lexize('hunspell_long','unbooking');
6868
SELECT ts_lexize('hunspell_long','unbook');
69+
SELECT ts_lexize('hunspell_long','booked');
6970

7071
SELECT ts_lexize('hunspell_long','footklubber');
7172
SELECT ts_lexize('hunspell_long','footballklubber');
7273
SELECT ts_lexize('hunspell_long','ballyklubber');
74+
SELECT ts_lexize('hunspell_long','ballsklubber');
7375
SELECT ts_lexize('hunspell_long','footballyklubber');
76+
SELECT ts_lexize('hunspell_long','ex-machina');
7477

7578
-- Test ISpell dictionary with hunspell affix file with FLAG num parameter
7679
CREATETEXT SEARCH DICTIONARY hunspell_num (
@@ -80,6 +83,7 @@ CREATE TEXT SEARCH DICTIONARY hunspell_num (
8083
);
8184

8285
SELECT ts_lexize('hunspell_num','skies');
86+
SELECT ts_lexize('hunspell_num','sk');
8387
SELECT ts_lexize('hunspell_num','bookings');
8488
SELECT ts_lexize('hunspell_num','booking');
8589
SELECT ts_lexize('hunspell_num','foot');
@@ -90,6 +94,7 @@ SELECT ts_lexize('hunspell_num', 'rebook');
9094
SELECT ts_lexize('hunspell_num','unbookings');
9195
SELECT ts_lexize('hunspell_num','unbooking');
9296
SELECT ts_lexize('hunspell_num','unbook');
97+
SELECT ts_lexize('hunspell_num','booked');
9398

9499
SELECT ts_lexize('hunspell_num','footklubber');
95100
SELECT ts_lexize('hunspell_num','footballklubber');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp