oracleoracle-text

how to save synonyms in database ( Oracle Text )


I am using oracle text for Arabic language.

I want to save the synonyms list in a database table, so the domain index read from this table, any idea ?


Solution

  • I found a solution :

    1- I uploaded my synonyms list to a table called words( contains all the terms and their synonyms' IDs ) and master table called synset (contains synonyms)

    2- create thesaurus :

    begin
      ctx_thes.create_thesaurus ('MyThesaurus');
    end;
    

    3- create a stored procedure to read from my table [words] and create relationship between synonyms:

    create or replace procedure CreateSynonyms is
      CURSOR syn_cur is    select s.name_abstract,w.root,w.word_abstract 
      from p words  w , synset s 
      where w.synset_id=s.synset_id and w.root<>s.name_abstract and w.word_abstract<> s.name_abstract
      order by s.synset_id;
      syn_rec syn_cur%rowtype;
    BEGIN
    OPEN syn_cur;
    LOOP
      FETCH syn_cur into syn_rec;
      EXIT WHEN syn_cur%notfound;
      begin
        ctx_thes.create_relation ('MyThesurus', syn_rec.name_abstract, 'syn', syn_rec.word_abstract);
      END LOOP;
    END;
    

    4- rewrite my query to select synonyms:

    select  /*+ FIRST_ROWS(1)*/  sentence_id,score(1) as sc, isn  
              where contains(PROCESSED_TEXT,'<query>
    <textquery>
       search for somthing here
     <progression>
     <seq><rewrite>transform((TOKENS,  "{", "}", ","))</rewrite></seq>
     <seq><rewrite>transform((TOKENS,  "syn(", ",listing)", " , "))</rewrite>/seq>
     </progression>
     </textquery>
     <score datatype="INTEGER" algorithm="COUNT"/></query>',1)>0 
    

    Hope this will help someone