Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Multi-word synonyms

Catfive LanderAug 5 2008 — edited Aug 19 2008
In an earlier thread, Barbara very kindly supplied me with a SYNS function to generate a search string with synonyms discovered in a thesaurus for any particular suplpied search word:
create or replace function syns
    (p_words in varchar2)
    return varchar2
  as
    v_words_in  varchar2 (32767) := ltrim (p_words) || ' ';
    v_words_out varchar2 (32767);
  begin
    while instr (v_words_in, '  ') > 0 loop
     v_words_in := replace (v_words_in, '  ', ' ');
    end loop;
     while length (v_words_in) > 1 loop
       v_words_out := v_words_out
         || ' AND ('
         || ctx_thes.syn (substr (v_words_in, 1, instr (v_words_in, ' ') - 1))
         || ')';
       v_words_in := substr (v_words_in, instr (v_words_in, ' ') + 1);
     end loop;
    return ltrim (v_words_out, ' AND');
  end syns;
My problem is that when a user submits a compund noun ("bok choi") for example, that doesn't get 'synned' properly, because the function sees 'bok' and 'choi' as two separate words. The existence of a thesaurus relation for 'bok choi SYN pak choi' doesn't therefore get picked up:
SQL> exec ctx_thes.create_relation('DEFAULT','bok choi','SYN','pak choi');

PL/SQL procedure successfully completed.

SQL> select syns('bok choi') from dual;

SYNS('BOKCHOI')
---------------------------------------------------------------------------
({BOK}) AND ({CHOI})
The same effect happens for, say, 'bell pepper'/'sweet pepper'

How do I get proper synonyming for a multi-word search "word", please? I'm sorry my PL/SQL is not good enough to work it out for myself!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 16 2008
Added on Aug 5 2008
18 comments
3,098 views