如何在数据库中保存同义词(Oracle 文本)

how to save synonyms in database ( Oracle Text )

我正在使用阿拉伯语的 oracle 文本。

我想将同义词列表保存在数据库中 table,因此从中读取域索引 table,知道吗?

我找到了解决方案:

1- 我将我的同义词列表上传到 table 名为 words(包含所有术语及其同义词 ID)和主 table 名为 synset(包含同义词)

2- 创建同义词库:

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

3- 创建一个存储过程来读取我的 table [words] 并创建同义词之间的关系:

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- 将我的查询重写为 select 同义词:

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 

希望这会对某人有所帮助