Indri和Terrier搜索引擎的使用
來源:程序員人生 發布時間:2014-11-13 08:37:20 閱讀次數:7200次
介紹
Indri和Terrier都是開源的搜索引擎,其中Indri作為Lemur項目的1個重要部份,具有強大的查詢接口,易建索引,可擴大,高效力等優點。可以在SourceForge Lemur Project Page中下載。Terrier也是IR領域非常有影響力的開源搜索引擎,Terrier是Glasgow大學用Java語言編寫的,具有高效靈活及易于部署等特點,目前最新的版本為Terrier
4.0,可在Terrier官網下載。
不管Indri還是Terrier全部進程,需要先建立索引,然后根據自定義的query phrases(查詢短語,固然也能夠是句子),在已建立的索引上查詢,并返回1個結果,類似以下(后面會具體講授每列的含義):

兩個搜索引擎的使用關鍵在于它們的配置文件,接下來說解如何配置
文本格式
<DOC>
<DOCNO>2011⑴2-05⑵0_1323118648⑺cfd066125ff1daf479748f81346895d</DOCNO>
<date>12/05/2011 (MM/DD/YYYY)</date>
<SOURCE>arxiv</SOURCE>
<TEXT> S and Î? production in pp interactions at â??s = 0.9 and 7 TeV measured with the....</TEXT>
</DOC>
1、Indri
Indri建索引
<parameters>
<memory>16G<memory>
<index>path/to/index</index> //建完索引后,這些索引結果文件寄存的位置,如/home/tempUser/myindex
<stemmer>
<name>krovetz</name> //詞干化工具,也即分詞,這個是默許的,可以選擇其他的
</stemmer>
<corpus>
<path>path/to/original/file/directory</path> //原始需要建立索引的文件目錄
<class>trectext</class> //需要建立甚么格式的索引,有xml, txt, trectext, web
</corpus>
<field>
<name>DOCNO</name> //文本ID號
</field>
<field> //如果需要用到時間信息,需加此field,
<name>date</name>
<numeric>true</numeric>
<parserName>DateFieldAnnotator</parserName>
</field>
</parameters>
Indri查詢
配置文件<span style="font-size:14px;"><parameters>
<index>path1/to/index</index>
<index>path2/to/index</index>
<rule>method:dirichlet,mu:1000</rule> //內置方法,用狄利克雷,參數值1000
<count>1000</count> //每一個查詢值返回1000條記錄,可以自己設置
<query> //第1個查詢
<number>001</number> //編號自己定義
//如果文本的發布日期在兩個時間段之間的,則在其文本中查詢“Abbotsford Arts Centre”,根據其內置算法,計算query phrases與文本的相干度值
<text>#scoreif(#datebetween(10/05/2011 01/26/2012) #1(Abbotsford Arts Centre))</text>
</query>
<query> //第2個查詢
<number>003</number>
<text>#scoreif(#datebetween(10/05/2011 08/08/2012) #1(Andy Billig))</text>
</query>
<trecFormat>true</trecFormat>
<queryOffset>1</queryOffset>
<runID>query_id</runID> //自定義queryID
</parameters></span>
Indri查詢語言
1、Combining Beliefs
#combine,#weight, #not, #max, #or, #band(boolean and)
#wsum, #wand(weighted and)
#weight( 1 #1(Abbotsford Arts Centre) 0.5 #1(office) 0.5 #1(band))
2、Filter Operators
scoreif(#datebetween(10/05/2011 01/26/2012) #1(Abbotsford Arts Centre))
3、Numeric Field Operator
#less( F N ) matches numeric field extents of type Fif value < N
#greater( F N ), #between(F N_low N_high ) , #equals(F N )
4、Date Field Operator
#dateafter( D ),
#datebefore( D ),
#datebetween( D_low D_high ),
#dateequals( D )
查詢結果文件:
其中:
第1列:表示第003query
第2列:不用理睬
第3列:DOCNO
第4列:排名
第5列:具體排序值
第6列:query_id
Terrier
未完待續
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈