<DOC> <DOCNO>2011-12-05-20_1323118648-7cfd066125ff1daf479748f81346895d</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>
<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>
<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> //第一个查询 <number>001</number> //编号自定义 //假设文本的公布日期在两个时间段之间的,则在其文本中查询“Abbotsford Arts Centre”,依据其内置算法。计算query phrases与文本的相关度值 <text>#scoreif(#datebetween(10/05/2011 01/26/2012) #1(Abbotsford Arts Centre))</text> </query> <query> //第二个查询 <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>
export JAVA_HOME="Absolute_Path_of_Java_Installation"
建索引:
1)定位到terrier文件夹
cd terrier2)收集须要建索引的文档
./bin/trec_setup.sh "Absolute_Path_To_Collection_Files"这里须要指定绝对路径。比方须要建索引的文件集在/home/hadoop/kba/kba2014/trecdata/2011-10文件夹下(该文件夹下都为文件。不是文件夹,Files已经是最后一层文件夹了),则上面的Absolute_Path_To_Collection_Files即为 /home/hadoop/kba/kba2014/trecdata/2011-10执行后在etc文件夹下生成例如以下图:
collection.spec里面的内容例如以下:
/home/hadoop/kba/kba2014/trecdata/2011-10/2011-10-05-01.trectext /home/hadoop/kba/kba2014/trecdata/2011-10/2011-10-05-03.trectext /home/hadoop/kba/kba2014/trecdata/2011-10/2011-10-05-05.trectext /home/hadoop/kba/kba2014/trecdata/2011-10/2011-10-05-07.trectext /home/hadoop/kba/kba2014/trecdata/2011-10/2011-10-05-08.trectext /home/hadoop/kba/kba2014/trecdata/2011-10/2011-10-05-11.trectext /home/hadoop/kba/kba2014/trecdata/2011-10/2011-10-05-12.trectext /home/hadoop/kba/kba2014/trecdata/2011-10/2011-10-05-13.trectext /home/hadoop/kba/kba2014/trecdata/2011-10/2011-10-05-14.trectext
#default controls for query expansion querying.postprocesses.order=QueryExpansion querying.postprocesses.controls=qe:QueryExpansion #default controls for the web-based interface. SimpleDecorate #is the simplest metadata decorator. For more control, see Decorate. querying.postfilters.order=SimpleDecorate,SiteFilter,Scope querying.postfilters.controls=decorate:SimpleDecorate,site:SiteFilter,scope:Scope #default and allowed controls querying.default.controls= querying.allowed.controls=scope,qe,qemodel,start,end,site,scope #document tags specification #for processing the contents of #the documents, ignoring DOCHDR TrecDocTags.doctag=DOC TrecDocTags.idtag=DOCNO TrecDocTags.skip=DOCHDR #set to true if the tags can be of various case TrecDocTags.casesensitive=false #query tags specification TrecQueryTags.doctag=TOP TrecQueryTags.idtag=NUM TrecQueryTags.process=TOP,NUM,TITLE TrecQueryTags.skip=DESC,NARR #stop-words file stopwords.filename=stopword-list.txt #the processing stages a term goes through termpipelines=Stopwords,PorterStemmer
<DOC> <DOCNO>id</DOCNO> <TEXT>text content</TEXT> </DOC>
<TOP> <NUM>003</NUM> //这个相当于你自己给这个query定一个id。所以能够随便写 <TITLE>"Abbotsford Arts Centre" office band "Abbotsford Arts Centre May" company "Abbotsford Arts Centre" </TITLE> //Query Phrases </TOP>
collection.spec=/absolute/path/to/your.spec terrier.index.path=/absolute/path/to/index/path //你想把你的建好的index放在哪个文件夹 trec.results.file=/absolute/path/to/resultfile.res //你想想把你的query结果放在哪个文件 ignore.low.idf.terms=false //假设某个词的逆文档频率idf非常低,还是要考虑,而不是丢弃 matching.retrieved_set_size=40000 //query后结果有多少条,假设test.query文件写了非常多个query,那么这么多个query的返回的结果不大于40000,注意此时不是单个query的结果数
./bin/trec_terrier.sh -r -Dtrec.model=PL2 -c 10.99 -Dtrec.topics=/path/to/your.query
-r表示retrieve,
-Dtrec.model表示用什么model去检索,这里用到了PL2模型。详细可在 terrier weighting model中查看
-c表示參数,后面10.99表示參数值
-Dtrec.topics表示your.query文件的详细路径
假设有多个索引文件。多个不同的query。怎么办?
比方对5个文件集分别建立索引,有5个query分别要在相应的索引文件中面找怎么办,因为是共用terrier.properties配置文件的。
所以你能够通过写一个shell脚本。针对不同的文件集。配置相应的collection.spec, terrier.index.path, trec.results.file.
终于得到的结果和开头indri的结果类似。
原文:http://www.cnblogs.com/gcczhongduan/p/5260451.html