add --shared
[pylucene.git] / lucene-java-3.4.0 / lucene / contrib / benchmark / src / java / org / apache / lucene / benchmark / quality / package.html
1 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
2 <!--
3  Licensed to the Apache Software Foundation (ASF) under one or more
4  contributor license agreements.  See the NOTICE file distributed with
5  this work for additional information regarding copyright ownership.
6  The ASF licenses this file to You under the Apache License, Version 2.0
7  (the "License"); you may not use this file except in compliance with
8  the License.  You may obtain a copy of the License at
9
10      http://www.apache.org/licenses/LICENSE-2.0
11
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  See the License for the specific language governing permissions and
16  limitations under the License.
17 -->
18 <html>
19 <body>
20 <h2>Search Quality Benchmarking.</h2>
21 <p>
22 This package allows to benchmark search quality of a Lucene application.
23 <p>
24 In order to use this package you should provide:
25 <ul>
26   <li>A <a href="../../search/Searcher.html">searcher</a>.</li>
27   <li><a href="QualityQuery.html">Quality queries</a>.</li>
28   <li><a href="Judge.html">Judging object</a>.</li>
29   <li><a href="utils/SubmissionReport.html">Reporting object</a>.</li>
30 </ul>
31 <p>
32 For benchmarking TREC collections with TREC QRels, take a look at the 
33 <a href="trec/package-summary.html">trec package</a>.
34 <p>
35 Here is a sample code used to run the TREC 2006 queries 701-850 on the .Gov2 collection:
36
37 <pre>
38     File topicsFile = new File("topics-701-850.txt");
39     File qrelsFile = new File("qrels-701-850.txt");
40     Searcher searcher = new IndexSearcher("index");
41
42     int maxResults = 1000;
43     String docNameField = "docname"; 
44     
45     PrintWriter logger = new PrintWriter(System.out,true); 
46
47     // use trec utilities to read trec topics into quality queries
48     TrecTopicsReader qReader = new TrecTopicsReader();
49     QualityQuery qqs[] = qReader.readQueries(new BufferedReader(new FileReader(topicsFile)));
50     
51     // prepare judge, with trec utilities that read from a QRels file
52     Judge judge = new TrecJudge(new BufferedReader(new FileReader(qrelsFile)));
53     
54     // validate topics & judgments match each other
55     judge.validateData(qqs, logger);
56     
57     // set the parsing of quality queries into Lucene queries.
58     QualityQueryParser qqParser = new SimpleQQParser("title", "body");
59     
60     // run the benchmark
61     QualityBenchmark qrun = new QualityBenchmark(qqs, qqParser, searcher, docNameField);
62     SubmissionReport submitLog = null;
63     QualityStats stats[] = qrun.execute(maxResults, judge, submitLog, logger);
64     
65     // print an avarage sum of the results
66     QualityStats avg = QualityStats.average(stats);
67     avg.log("SUMMARY",2,logger, "  ");
68 </pre>
69
70 <p>
71 Some immediate ways to modify this program to your needs are:
72 <ul>
73   <li>To run on different formats of queries and judgements provide your own 
74       <a href="Judge.html">Judge</a> and 
75       <a href="QualityQuery.html">Quality queries</a>.</li>
76   <li>Create sophisticated Lucene queries by supplying a different 
77   <a href="QualityQueryParser.html">Quality query parser</a>.</li>
78 </ul>
79
80 </body>
81
82 </html>