mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
Improve support of Hunspell in ispell dictionary.
Now it's possible to load recent version of Hunspell for several languages. To handle these dictionaries Hunspell patch adds support for: * FLAG long - sets the double extended ASCII character flag type * FLAG num - sets the decimal number flag type (from 1 to 65535) * AF parameter - alias for flag's set Also it moves test dictionaries into separate directory. Author: Artur Zakirov with editorization by me
This commit is contained in:
@ -191,6 +191,198 @@ SELECT ts_lexize('hunspell', 'footballyklubber');
|
||||
{foot,ball,klubber}
|
||||
(1 row)
|
||||
|
||||
-- Test ISpell dictionary with hunspell affix file with FLAG long parameter
|
||||
CREATE TEXT SEARCH DICTIONARY hunspell_long (
|
||||
Template=ispell,
|
||||
DictFile=hunspell_sample_long,
|
||||
AffFile=hunspell_sample_long
|
||||
);
|
||||
SELECT ts_lexize('hunspell_long', 'skies');
|
||||
ts_lexize
|
||||
-----------
|
||||
{sky}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_long', 'bookings');
|
||||
ts_lexize
|
||||
----------------
|
||||
{booking,book}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_long', 'booking');
|
||||
ts_lexize
|
||||
----------------
|
||||
{booking,book}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_long', 'foot');
|
||||
ts_lexize
|
||||
-----------
|
||||
{foot}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_long', 'foots');
|
||||
ts_lexize
|
||||
-----------
|
||||
{foot}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_long', 'rebookings');
|
||||
ts_lexize
|
||||
----------------
|
||||
{booking,book}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_long', 'rebooking');
|
||||
ts_lexize
|
||||
----------------
|
||||
{booking,book}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_long', 'rebook');
|
||||
ts_lexize
|
||||
-----------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_long', 'unbookings');
|
||||
ts_lexize
|
||||
-----------
|
||||
{book}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_long', 'unbooking');
|
||||
ts_lexize
|
||||
-----------
|
||||
{book}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_long', 'unbook');
|
||||
ts_lexize
|
||||
-----------
|
||||
{book}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_long', 'footklubber');
|
||||
ts_lexize
|
||||
----------------
|
||||
{foot,klubber}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_long', 'footballklubber');
|
||||
ts_lexize
|
||||
------------------------------------------------------
|
||||
{footballklubber,foot,ball,klubber,football,klubber}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_long', 'ballyklubber');
|
||||
ts_lexize
|
||||
----------------
|
||||
{ball,klubber}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_long', 'footballyklubber');
|
||||
ts_lexize
|
||||
---------------------
|
||||
{foot,ball,klubber}
|
||||
(1 row)
|
||||
|
||||
-- Test ISpell dictionary with hunspell affix file with FLAG num parameter
|
||||
CREATE TEXT SEARCH DICTIONARY hunspell_num (
|
||||
Template=ispell,
|
||||
DictFile=hunspell_sample_num,
|
||||
AffFile=hunspell_sample_num
|
||||
);
|
||||
SELECT ts_lexize('hunspell_num', 'skies');
|
||||
ts_lexize
|
||||
-----------
|
||||
{sky}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_num', 'bookings');
|
||||
ts_lexize
|
||||
----------------
|
||||
{booking,book}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_num', 'booking');
|
||||
ts_lexize
|
||||
----------------
|
||||
{booking,book}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_num', 'foot');
|
||||
ts_lexize
|
||||
-----------
|
||||
{foot}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_num', 'foots');
|
||||
ts_lexize
|
||||
-----------
|
||||
{foot}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_num', 'rebookings');
|
||||
ts_lexize
|
||||
----------------
|
||||
{booking,book}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_num', 'rebooking');
|
||||
ts_lexize
|
||||
----------------
|
||||
{booking,book}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_num', 'rebook');
|
||||
ts_lexize
|
||||
-----------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_num', 'unbookings');
|
||||
ts_lexize
|
||||
-----------
|
||||
{book}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_num', 'unbooking');
|
||||
ts_lexize
|
||||
-----------
|
||||
{book}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_num', 'unbook');
|
||||
ts_lexize
|
||||
-----------
|
||||
{book}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_num', 'footklubber');
|
||||
ts_lexize
|
||||
----------------
|
||||
{foot,klubber}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_num', 'footballklubber');
|
||||
ts_lexize
|
||||
------------------------------------------------------
|
||||
{footballklubber,foot,ball,klubber,football,klubber}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_num', 'ballyklubber');
|
||||
ts_lexize
|
||||
----------------
|
||||
{ball,klubber}
|
||||
(1 row)
|
||||
|
||||
SELECT ts_lexize('hunspell_num', 'footballyklubber');
|
||||
ts_lexize
|
||||
---------------------
|
||||
{foot,ball,klubber}
|
||||
(1 row)
|
||||
|
||||
-- Synonim dictionary
|
||||
CREATE TEXT SEARCH DICTIONARY synonym (
|
||||
Template=synonym,
|
||||
@ -277,6 +469,48 @@ SELECT to_tsquery('hunspell_tst', 'footballyklubber:b & rebookings:A & sky');
|
||||
'foot':B & 'ball':B & 'klubber':B & ( 'booking':A | 'book':A ) & 'sky'
|
||||
(1 row)
|
||||
|
||||
-- Test ispell dictionary with hunspell affix with FLAG long in configuration
|
||||
ALTER TEXT SEARCH CONFIGURATION hunspell_tst ALTER MAPPING
|
||||
REPLACE hunspell WITH hunspell_long;
|
||||
SELECT to_tsvector('hunspell_tst', 'Booking the skies after rebookings for footballklubber from a foot');
|
||||
to_tsvector
|
||||
----------------------------------------------------------------------------------------------------
|
||||
'ball':7 'book':1,5 'booking':1,5 'foot':7,10 'football':7 'footballklubber':7 'klubber':7 'sky':3
|
||||
(1 row)
|
||||
|
||||
SELECT to_tsquery('hunspell_tst', 'footballklubber');
|
||||
to_tsquery
|
||||
------------------------------------------------------------------------------
|
||||
( 'footballklubber' | 'foot' & 'ball' & 'klubber' ) | 'football' & 'klubber'
|
||||
(1 row)
|
||||
|
||||
SELECT to_tsquery('hunspell_tst', 'footballyklubber:b & rebookings:A & sky');
|
||||
to_tsquery
|
||||
------------------------------------------------------------------------
|
||||
'foot':B & 'ball':B & 'klubber':B & ( 'booking':A | 'book':A ) & 'sky'
|
||||
(1 row)
|
||||
|
||||
-- Test ispell dictionary with hunspell affix with FLAG num in configuration
|
||||
ALTER TEXT SEARCH CONFIGURATION hunspell_tst ALTER MAPPING
|
||||
REPLACE hunspell_long WITH hunspell_num;
|
||||
SELECT to_tsvector('hunspell_tst', 'Booking the skies after rebookings for footballklubber from a foot');
|
||||
to_tsvector
|
||||
----------------------------------------------------------------------------------------------------
|
||||
'ball':7 'book':1,5 'booking':1,5 'foot':7,10 'football':7 'footballklubber':7 'klubber':7 'sky':3
|
||||
(1 row)
|
||||
|
||||
SELECT to_tsquery('hunspell_tst', 'footballklubber');
|
||||
to_tsquery
|
||||
------------------------------------------------------------------------------
|
||||
( 'footballklubber' | 'foot' & 'ball' & 'klubber' ) | 'football' & 'klubber'
|
||||
(1 row)
|
||||
|
||||
SELECT to_tsquery('hunspell_tst', 'footballyklubber:b & rebookings:A & sky');
|
||||
to_tsquery
|
||||
------------------------------------------------------------------------
|
||||
'foot':B & 'ball':B & 'klubber':B & ( 'booking':A | 'book':A ) & 'sky'
|
||||
(1 row)
|
||||
|
||||
-- Test synonym dictionary in configuration
|
||||
CREATE TEXT SEARCH CONFIGURATION synonym_tst (
|
||||
COPY=english
|
||||
|
@ -48,6 +48,54 @@ SELECT ts_lexize('hunspell', 'footballklubber');
|
||||
SELECT ts_lexize('hunspell', 'ballyklubber');
|
||||
SELECT ts_lexize('hunspell', 'footballyklubber');
|
||||
|
||||
-- Test ISpell dictionary with hunspell affix file with FLAG long parameter
|
||||
CREATE TEXT SEARCH DICTIONARY hunspell_long (
|
||||
Template=ispell,
|
||||
DictFile=hunspell_sample_long,
|
||||
AffFile=hunspell_sample_long
|
||||
);
|
||||
|
||||
SELECT ts_lexize('hunspell_long', 'skies');
|
||||
SELECT ts_lexize('hunspell_long', 'bookings');
|
||||
SELECT ts_lexize('hunspell_long', 'booking');
|
||||
SELECT ts_lexize('hunspell_long', 'foot');
|
||||
SELECT ts_lexize('hunspell_long', 'foots');
|
||||
SELECT ts_lexize('hunspell_long', 'rebookings');
|
||||
SELECT ts_lexize('hunspell_long', 'rebooking');
|
||||
SELECT ts_lexize('hunspell_long', 'rebook');
|
||||
SELECT ts_lexize('hunspell_long', 'unbookings');
|
||||
SELECT ts_lexize('hunspell_long', 'unbooking');
|
||||
SELECT ts_lexize('hunspell_long', 'unbook');
|
||||
|
||||
SELECT ts_lexize('hunspell_long', 'footklubber');
|
||||
SELECT ts_lexize('hunspell_long', 'footballklubber');
|
||||
SELECT ts_lexize('hunspell_long', 'ballyklubber');
|
||||
SELECT ts_lexize('hunspell_long', 'footballyklubber');
|
||||
|
||||
-- Test ISpell dictionary with hunspell affix file with FLAG num parameter
|
||||
CREATE TEXT SEARCH DICTIONARY hunspell_num (
|
||||
Template=ispell,
|
||||
DictFile=hunspell_sample_num,
|
||||
AffFile=hunspell_sample_num
|
||||
);
|
||||
|
||||
SELECT ts_lexize('hunspell_num', 'skies');
|
||||
SELECT ts_lexize('hunspell_num', 'bookings');
|
||||
SELECT ts_lexize('hunspell_num', 'booking');
|
||||
SELECT ts_lexize('hunspell_num', 'foot');
|
||||
SELECT ts_lexize('hunspell_num', 'foots');
|
||||
SELECT ts_lexize('hunspell_num', 'rebookings');
|
||||
SELECT ts_lexize('hunspell_num', 'rebooking');
|
||||
SELECT ts_lexize('hunspell_num', 'rebook');
|
||||
SELECT ts_lexize('hunspell_num', 'unbookings');
|
||||
SELECT ts_lexize('hunspell_num', 'unbooking');
|
||||
SELECT ts_lexize('hunspell_num', 'unbook');
|
||||
|
||||
SELECT ts_lexize('hunspell_num', 'footklubber');
|
||||
SELECT ts_lexize('hunspell_num', 'footballklubber');
|
||||
SELECT ts_lexize('hunspell_num', 'ballyklubber');
|
||||
SELECT ts_lexize('hunspell_num', 'footballyklubber');
|
||||
|
||||
-- Synonim dictionary
|
||||
CREATE TEXT SEARCH DICTIONARY synonym (
|
||||
Template=synonym,
|
||||
@ -94,6 +142,22 @@ SELECT to_tsvector('hunspell_tst', 'Booking the skies after rebookings for footb
|
||||
SELECT to_tsquery('hunspell_tst', 'footballklubber');
|
||||
SELECT to_tsquery('hunspell_tst', 'footballyklubber:b & rebookings:A & sky');
|
||||
|
||||
-- Test ispell dictionary with hunspell affix with FLAG long in configuration
|
||||
ALTER TEXT SEARCH CONFIGURATION hunspell_tst ALTER MAPPING
|
||||
REPLACE hunspell WITH hunspell_long;
|
||||
|
||||
SELECT to_tsvector('hunspell_tst', 'Booking the skies after rebookings for footballklubber from a foot');
|
||||
SELECT to_tsquery('hunspell_tst', 'footballklubber');
|
||||
SELECT to_tsquery('hunspell_tst', 'footballyklubber:b & rebookings:A & sky');
|
||||
|
||||
-- Test ispell dictionary with hunspell affix with FLAG num in configuration
|
||||
ALTER TEXT SEARCH CONFIGURATION hunspell_tst ALTER MAPPING
|
||||
REPLACE hunspell_long WITH hunspell_num;
|
||||
|
||||
SELECT to_tsvector('hunspell_tst', 'Booking the skies after rebookings for footballklubber from a foot');
|
||||
SELECT to_tsquery('hunspell_tst', 'footballklubber');
|
||||
SELECT to_tsquery('hunspell_tst', 'footballyklubber:b & rebookings:A & sky');
|
||||
|
||||
-- Test synonym dictionary in configuration
|
||||
CREATE TEXT SEARCH CONFIGURATION synonym_tst (
|
||||
COPY=english
|
||||
|
Reference in New Issue
Block a user