improvements for dict_xsyn extended synonym dictionary

From: karpov(at)sao(dot)ru (Sergey V(dot) Karpov)
To: pgsql-hackers(at)postgresql(dot)org
Subject: improvements for dict_xsyn extended synonym dictionary
Date: 2009-07-14 19:35:28
Message-ID: 877hyboy67.fsf@sao.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Greetings,

attached is a simple patch that extends the functionality of dict_xsyn
extended synonym dictionary (from contrib) by adding the following
configuration option:

- "mode" option controls the current dictionary mode of operation. Can be one of:

- in "simple" mode it accepts the original word and returns all synonyms
as ORed lis.

- when mode is "symmetric", the dictionary accepts the original word or
any of its synonyms, and return all others as ORed list.

- in "map" regime it accepts any synonym and returns the original word
instead of it. Also, it accepts and returns the original word
itself, even if keeporig is false.

Default for this option is "simple" to keep compatibility with original
version.

Quick example:

> cat $SHAREDIR/tsearch_data/my_rules.syn
word syn1 syn2 syn3

mydb# ALTER TEXT SEARCH DICTIONARY xsyn (RULES='my_rules', KEEPORIG=false, MODE='simple');
ALTER TEXT SEARCH DICTIONARY

mydb=# SELECT ts_lexize('xsyn', 'word');
ts_lexize
-----------------------
{syn1,syn2,syn3}

mydb# ALTER TEXT SEARCH DICTIONARY xsyn (RULES='my_rules', KEEPORIG=true, MODE='simple');
ALTER TEXT SEARCH DICTIONARY

mydb=# SELECT ts_lexize('xsyn', 'word');
ts_lexize
-----------------------
{word,syn1,syn2,syn3}

mydb# ALTER TEXT SEARCH DICTIONARY xsyn (RULES='my_rules', KEEPORIG=false, MODE='symmetric');
ALTER TEXT SEARCH DICTIONARY

mydb=# SELECT ts_lexize('xsyn', 'syn1');
ts_lexize
-----------------------
{word,syn2,syn3}

mydb# ALTER TEXT SEARCH DICTIONARY xsyn (RULES='my_rules', KEEPORIG=false, MODE='map');
ALTER TEXT SEARCH DICTIONARY

mydb=# SELECT ts_lexize('xsyn', 'syn1');
ts_lexize
-----------------------
{word}

Thanks for your attention.

Sergey Karpov.

Attachment Content-Type Size
dict_xsyn_extended.diff.gz application/octet-stream 2.8 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2009-07-14 19:36:14 Re: more than one index in a single heap pass?
Previous Message Andrew Dunstan 2009-07-14 19:33:14 more than one index in a single heap pass?