01: package org.apache.lucene.benchmark.quality.trec;
02:
03: import org.apache.lucene.benchmark.quality.trec.TrecJudge;
04: import org.apache.lucene.benchmark.quality.trec.TrecTopicsReader;
05: import org.apache.lucene.benchmark.quality.utils.SimpleQQParser;
06: import org.apache.lucene.benchmark.quality.utils.SubmissionReport;
07: import org.apache.lucene.benchmark.quality.*;
08: import org.apache.lucene.search.IndexSearcher;
09: import org.apache.lucene.search.Searcher;
10:
11: import java.io.BufferedReader;
12: import java.io.File;
13: import java.io.FileReader;
14: import java.io.PrintWriter;
15:
16: /**
17: *
18: *
19: **/
20: public class QueryDriver {
21: public static void main(String[] args) throws Exception {
22:
23: File topicsFile = new File(args[0]);
24: File qrelsFile = new File(args[1]);
25: Searcher searcher = new IndexSearcher(args[3]);
26:
27: int maxResults = 1000;
28: String docNameField = "docname";
29:
30: PrintWriter logger = new PrintWriter(System.out, true);
31:
32: // use trec utilities to read trec topics into quality queries
33: TrecTopicsReader qReader = new TrecTopicsReader();
34: QualityQuery qqs[] = qReader.readQueries(new BufferedReader(
35: new FileReader(topicsFile)));
36:
37: // prepare judge, with trec utilities that read from a QRels file
38: Judge judge = new TrecJudge(new BufferedReader(new FileReader(
39: qrelsFile)));
40:
41: // validate topics & judgments match each other
42: judge.validateData(qqs, logger);
43:
44: // set the parsing of quality queries into Lucene queries.
45: QualityQueryParser qqParser = new SimpleQQParser("title",
46: "body");
47:
48: // run the benchmark
49: QualityBenchmark qrun = new QualityBenchmark(qqs, qqParser,
50: searcher, docNameField);
51: qrun.setMaxResults(maxResults);
52: SubmissionReport submitLog = null;
53: QualityStats stats[] = qrun.execute(judge, submitLog, logger);
54:
55: // print an avarage sum of the results
56: QualityStats avg = QualityStats.average(stats);
57: avg.log("SUMMARY", 2, logger, " ");
58: }
59: }
|