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!