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

时间:2015-03-25 11:37:25

标签: oracle oracle-text

我正在使用oracle text for Arabic language。

我想将同义词列表保存在数据库表中,所以从这个表中读取域索引,有什么想法吗?

1 个答案:

答案 0 :(得分:1)

我找到了解决方案:

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

2-创建词库:

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

3-创建一个存储过程以从我的表[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  /*+ 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 

希望这会有所帮助