improvements for dict_xsyn extended synonym dictionary - Mailing list pgsql-hackers

From karpov@sao.ru (Sergey V. Karpov)
Subject improvements for dict_xsyn extended synonym dictionary
Date
Msg-id 877hyboy67.fsf@sao.ru
Whole thread Raw
Responses Re: improvements for dict_xsyn extended synonym dictionary - RRR
List 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

pgsql-hackers by date:

Previous
From: Jamie Fox
Date:
Subject: Re: [GENERAL] large object does not exist after pg_migrator
Next
From: Andrew Dunstan
Date:
Subject: navigation menu for documents