Skip to content

Commit

Permalink
Fix tests: use indexes and check various forms with tsquery
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Zakirov committed May 31, 2016
1 parent 141f536 commit ddbac4a
Show file tree
Hide file tree
Showing 12 changed files with 463 additions and 331 deletions.
86 changes: 45 additions & 41 deletions hunspell_de_de/expected/hunspell_de_de.out
Original file line number Diff line number Diff line change
@@ -1,55 +1,59 @@
CREATE EXTENSION hunspell_de_de;
SELECT ts_lexize('german_hunspell', 'überwachung');
ts_lexize
--------------
{überwachen}
(1 row)

SELECT ts_lexize('german_hunspell', 'etikettierung');
ts_lexize
----------------
{etikettieren}
(1 row)

SELECT ts_lexize('german_hunspell', 'vernehmen');
ts_lexize
--------------------
{vernehmen,nehmen}
CREATE TABLE table1(name varchar);
INSERT INTO table1 VALUES ('etikettierung'), ('vernehmen'), ('verteilen'),
('bereits'), ('wahrnehmung');
SELECT d.* FROM table1 AS t, LATERAL ts_debug('german_hunspell', t.name) AS d;
alias | description | token | dictionaries | dictionary | lexemes
-----------+-----------------+---------------+-------------------------------+-----------------+-------------------------------
asciiword | Word, all ASCII | etikettierung | {german_hunspell,german_stem} | german_hunspell | {etikettieren}
asciiword | Word, all ASCII | vernehmen | {german_hunspell,german_stem} | german_hunspell | {vernehmen,nehmen}
asciiword | Word, all ASCII | verteilen | {german_hunspell,german_stem} | german_hunspell | {verteilen,teilen,teile,teil}
asciiword | Word, all ASCII | bereits | {german_hunspell,german_stem} | german_hunspell | {bereit}
asciiword | Word, all ASCII | wahrnehmung | {german_hunspell,german_stem} | german_hunspell | {wahrnehmen}
(5 rows)

CREATE INDEX name_idx ON table1 USING GIN (to_tsvector('german_hunspell', "name"));
SELECT * FROM table1 WHERE to_tsvector('german_hunspell', name)
@@ to_tsquery('german_hunspell', 'vernehmen');
name
-----------
vernehmen
(1 row)

SELECT ts_lexize('german_hunspell', 'verteilen');
ts_lexize
-------------------------------
{verteilen,teilen,teile,teil}
SELECT * FROM table1 WHERE to_tsvector('german_hunspell', name)
@@ to_tsquery('german_hunspell', 'bereits');
name
---------
bereits
(1 row)

SELECT ts_lexize('german_hunspell', 'bereits');
ts_lexize
-----------
{bereit}
SELECT * FROM table1 WHERE to_tsvector('german_hunspell', name)
@@ to_tsquery('german_hunspell', 'wahrnehmung');
name
-------------
wahrnehmung
(1 row)

SELECT ts_lexize('german_hunspell', 'üblichen');
ts_lexize
DROP INDEX name_idx;
CREATE INDEX name_idx ON table1 USING GIST (to_tsvector('german_hunspell', "name"));
SELECT * FROM table1 WHERE to_tsvector('german_hunspell', name)
@@ to_tsquery('german_hunspell', 'vernehmen');
name
-----------
{üblich}
vernehmen
(1 row)

SELECT ts_lexize('german_hunspell', 'wahrnehmung');
ts_lexize
--------------
{wahrnehmen}
SELECT * FROM table1 WHERE to_tsvector('german_hunspell', name)
@@ to_tsquery('german_hunspell', 'bereits');
name
---------
bereits
(1 row)

SELECT ts_lexize('german_hunspell', 'maßen');
ts_lexize
-----------
{maß}
(1 row)

SELECT ts_lexize('german_hunspell', 'füße');
ts_lexize
-----------
{fuß}
SELECT * FROM table1 WHERE to_tsvector('german_hunspell', name)
@@ to_tsquery('german_hunspell', 'wahrnehmung');
name
-------------
wahrnehmung
(1 row)

31 changes: 22 additions & 9 deletions hunspell_de_de/sql/hunspell_de_de.sql
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
CREATE EXTENSION hunspell_de_de;

SELECT ts_lexize('german_hunspell', 'überwachung');
SELECT ts_lexize('german_hunspell', 'etikettierung');
SELECT ts_lexize('german_hunspell', 'vernehmen');
SELECT ts_lexize('german_hunspell', 'verteilen');
SELECT ts_lexize('german_hunspell', 'bereits');
SELECT ts_lexize('german_hunspell', 'üblichen');
SELECT ts_lexize('german_hunspell', 'wahrnehmung');
SELECT ts_lexize('german_hunspell', 'maßen');
SELECT ts_lexize('german_hunspell', 'füße');
CREATE TABLE table1(name varchar);
INSERT INTO table1 VALUES ('etikettierung'), ('vernehmen'), ('verteilen'),
('bereits'), ('wahrnehmung');

SELECT d.* FROM table1 AS t, LATERAL ts_debug('german_hunspell', t.name) AS d;

CREATE INDEX name_idx ON table1 USING GIN (to_tsvector('german_hunspell', "name"));
SELECT * FROM table1 WHERE to_tsvector('german_hunspell', name)
@@ to_tsquery('german_hunspell', 'vernehmen');
SELECT * FROM table1 WHERE to_tsvector('german_hunspell', name)
@@ to_tsquery('german_hunspell', 'bereits');
SELECT * FROM table1 WHERE to_tsvector('german_hunspell', name)
@@ to_tsquery('german_hunspell', 'wahrnehmung');

DROP INDEX name_idx;
CREATE INDEX name_idx ON table1 USING GIST (to_tsvector('german_hunspell', "name"));
SELECT * FROM table1 WHERE to_tsvector('german_hunspell', name)
@@ to_tsquery('german_hunspell', 'vernehmen');
SELECT * FROM table1 WHERE to_tsvector('german_hunspell', name)
@@ to_tsquery('german_hunspell', 'bereits');
SELECT * FROM table1 WHERE to_tsvector('german_hunspell', name)
@@ to_tsquery('german_hunspell', 'wahrnehmung');
120 changes: 68 additions & 52 deletions hunspell_en_us/expected/hunspell_en_us.out
Original file line number Diff line number Diff line change
@@ -1,61 +1,77 @@
CREATE EXTENSION hunspell_en_us;
SELECT ts_lexize('english_hunspell', 'stories');
ts_lexize
-----------
{story}
(1 row)
CREATE TABLE table1(name varchar);
INSERT INTO table1 VALUES ('leaves'), ('leaved'), ('leaving'),
('inability'), ('abilities'), ('disability'), ('ability');
SELECT d.* FROM table1 AS t, LATERAL ts_debug('english_hunspell', t.name) AS d;
alias | description | token | dictionaries | dictionary | lexemes
-----------+-----------------+------------+---------------------------------+------------------+-----------
asciiword | Word, all ASCII | leaves | {english_hunspell,english_stem} | english_hunspell | {leave}
asciiword | Word, all ASCII | leaved | {english_hunspell,english_stem} | english_hunspell | {leave}
asciiword | Word, all ASCII | leaving | {english_hunspell,english_stem} | english_hunspell | {leave}
asciiword | Word, all ASCII | inability | {english_hunspell,english_stem} | english_hunspell | {ability}
asciiword | Word, all ASCII | abilities | {english_hunspell,english_stem} | english_hunspell | {ability}
asciiword | Word, all ASCII | disability | {english_hunspell,english_stem} | english_hunspell | {ability}
asciiword | Word, all ASCII | ability | {english_hunspell,english_stem} | english_hunspell | {ability}
(7 rows)

SELECT ts_lexize('english_hunspell', 'traveled');
ts_lexize
-------------------
{traveled,travel}
(1 row)
CREATE INDEX name_idx ON table1 USING GIN (to_tsvector('english_hunspell', "name"));
SELECT * FROM table1 WHERE to_tsvector('english_hunspell', name)
@@ to_tsquery('english_hunspell', 'leaving');
name
---------
leaves
leaved
leaving
(3 rows)

SELECT ts_lexize('english_hunspell', 'eaten');
ts_lexize
-------------
{eaten,eat}
(1 row)

SELECT ts_lexize('english_hunspell', 'I''m');
ts_lexize
-----------
{i'm}
(1 row)

SELECT ts_lexize('english_hunspell', 'Saturdays');
ts_lexize
SELECT * FROM table1 WHERE to_tsvector('english_hunspell', name)
@@ to_tsquery('english_hunspell', 'abilities');
name
------------
{saturday}
(1 row)

SELECT ts_lexize('english_hunspell', 'healthcare');
ts_lexize
--------------
{healthcare}
(1 row)
inability
abilities
disability
ability
(4 rows)

SELECT ts_lexize('english_hunspell', 'generally');
ts_lexize
-----------
{general}
(1 row)
SELECT * FROM table1 WHERE to_tsvector('english_hunspell', name)
@@ to_tsquery('english_hunspell', 'ability');
name
------------
inability
abilities
disability
ability
(4 rows)

SELECT ts_lexize('english_hunspell', 'integrating');
ts_lexize
-------------
{integrate}
(1 row)
DROP INDEX name_idx;
CREATE INDEX name_idx ON table1 USING GIST (to_tsvector('english_hunspell', "name"));
SELECT * FROM table1 WHERE to_tsvector('english_hunspell', name)
@@ to_tsquery('english_hunspell', 'leaving');
name
---------
leaves
leaved
leaving
(3 rows)

SELECT ts_lexize('english_hunspell', 'lankiness''s');
ts_lexize
-------------
{lankiness}
(1 row)
SELECT * FROM table1 WHERE to_tsvector('english_hunspell', name)
@@ to_tsquery('english_hunspell', 'abilities');
name
------------
inability
abilities
disability
ability
(4 rows)

SELECT ts_lexize('english_hunspell', 'rewritten');
ts_lexize
-----------
{written}
(1 row)
SELECT * FROM table1 WHERE to_tsvector('english_hunspell', name)
@@ to_tsquery('english_hunspell', 'ability');
name
------------
inability
abilities
disability
ability
(4 rows)

32 changes: 22 additions & 10 deletions hunspell_en_us/sql/hunspell_en_us.sql
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
CREATE EXTENSION hunspell_en_us;

SELECT ts_lexize('english_hunspell', 'stories');
SELECT ts_lexize('english_hunspell', 'traveled');
SELECT ts_lexize('english_hunspell', 'eaten');
SELECT ts_lexize('english_hunspell', 'I''m');
SELECT ts_lexize('english_hunspell', 'Saturdays');
SELECT ts_lexize('english_hunspell', 'healthcare');
SELECT ts_lexize('english_hunspell', 'generally');
SELECT ts_lexize('english_hunspell', 'integrating');
SELECT ts_lexize('english_hunspell', 'lankiness''s');
SELECT ts_lexize('english_hunspell', 'rewritten');
CREATE TABLE table1(name varchar);
INSERT INTO table1 VALUES ('leaves'), ('leaved'), ('leaving'),
('inability'), ('abilities'), ('disability'), ('ability');

SELECT d.* FROM table1 AS t, LATERAL ts_debug('english_hunspell', t.name) AS d;

CREATE INDEX name_idx ON table1 USING GIN (to_tsvector('english_hunspell', "name"));
SELECT * FROM table1 WHERE to_tsvector('english_hunspell', name)
@@ to_tsquery('english_hunspell', 'leaving');
SELECT * FROM table1 WHERE to_tsvector('english_hunspell', name)
@@ to_tsquery('english_hunspell', 'abilities');
SELECT * FROM table1 WHERE to_tsvector('english_hunspell', name)
@@ to_tsquery('english_hunspell', 'ability');

DROP INDEX name_idx;
CREATE INDEX name_idx ON table1 USING GIST (to_tsvector('english_hunspell', "name"));
SELECT * FROM table1 WHERE to_tsvector('english_hunspell', name)
@@ to_tsquery('english_hunspell', 'leaving');
SELECT * FROM table1 WHERE to_tsvector('english_hunspell', name)
@@ to_tsquery('english_hunspell', 'abilities');
SELECT * FROM table1 WHERE to_tsvector('english_hunspell', name)
@@ to_tsquery('english_hunspell', 'ability');
Loading

0 comments on commit ddbac4a

Please sign in to comment.