本文整理汇总了Java中org.apache.lucene.benchmark.quality.utils.SubmissionReport类的典型用法代码示例。如果您正苦于以下问题:Java SubmissionReport类的具体用法?Java SubmissionReport怎么用?Java SubmissionReport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SubmissionReport类属于org.apache.lucene.benchmark.quality.utils包,在下文中一共展示了SubmissionReport类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.apache.lucene.benchmark.quality.utils.SubmissionReport; //导入依赖的package包/类
/**
* Run the quality benchmark.
* @param judge the judge that can tell if a certain result doc is relevant for a certain quality query.
* If null, no judgements would be made. Usually null for a submission run.
* @param submitRep submission report is created if non null.
* @param qualityLog If not null, quality run data would be printed for each query.
* @return QualityStats of each quality query that was executed.
* @throws Exception if quality benchmark failed to run.
*/
public QualityStats [] execute(Judge judge, SubmissionReport submitRep,
PrintWriter qualityLog) throws Exception {
int nQueries = Math.min(maxQueries, qualityQueries.length);
QualityStats stats[] = new QualityStats[nQueries];
for (int i=0; i<nQueries; i++) {
QualityQuery qq = qualityQueries[i];
// generate query
Query q = qqParser.parse(qq);
// search with this query
long t1 = System.currentTimeMillis();
TopDocs td = searcher.search(q,null,maxResults);
long searchTime = System.currentTimeMillis()-t1;
//most likely we either submit or judge, but check both
if (judge!=null) {
stats[i] = analyzeQueryResults(qq, q, td, judge, qualityLog, searchTime);
}
if (submitRep!=null) {
submitRep.report(qq,td,docNameField,searcher);
}
}
if (submitRep!=null) {
submitRep.flush();
}
return stats;
}
示例2: main
import org.apache.lucene.benchmark.quality.utils.SubmissionReport; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
if (args.length < 4 || args.length > 5) {
System.err.println("Usage: QueryDriver <topicsFile> <qrelsFile> <submissionFile> <indexDir> [querySpec]");
System.err.println("topicsFile: input file containing queries");
System.err.println("qrelsFile: input file containing relevance judgements");
System.err.println("submissionFile: output submission file for trec_eval");
System.err.println("indexDir: index directory");
System.err.println("querySpec: string composed of fields to use in query consisting of T=title,D=description,N=narrative:");
System.err.println("\texample: TD (query on Title + Description). The default is T (title only)");
System.exit(1);
}
File topicsFile = new File(args[0]);
File qrelsFile = new File(args[1]);
SubmissionReport submitLog = new SubmissionReport(new PrintWriter(args[2], IOUtils.UTF_8 /* huh, no nio.Charset ctor? */), "lucene");
FSDirectory dir = FSDirectory.open(new File(args[3]));
String fieldSpec = args.length == 5 ? args[4] : "T"; // default to Title-only if not specified.
IndexReader reader = DirectoryReader.open(dir);
IndexSearcher searcher = new IndexSearcher(reader);
int maxResults = 1000;
String docNameField = "docname";
PrintWriter logger = new PrintWriter(new OutputStreamWriter(System.out, Charset.defaultCharset()), true);
// use trec utilities to read trec topics into quality queries
TrecTopicsReader qReader = new TrecTopicsReader();
QualityQuery qqs[] = qReader.readQueries(new BufferedReader(IOUtils.getDecodingReader(topicsFile, StandardCharsets.UTF_8)));
// prepare judge, with trec utilities that read from a QRels file
Judge judge = new TrecJudge(new BufferedReader(IOUtils.getDecodingReader(qrelsFile, StandardCharsets.UTF_8)));
// validate topics & judgments match each other
judge.validateData(qqs, logger);
Set<String> fieldSet = new HashSet<>();
if (fieldSpec.indexOf('T') >= 0) fieldSet.add("title");
if (fieldSpec.indexOf('D') >= 0) fieldSet.add("description");
if (fieldSpec.indexOf('N') >= 0) fieldSet.add("narrative");
// set the parsing of quality queries into Lucene queries.
QualityQueryParser qqParser = new SimpleQQParser(fieldSet.toArray(new String[0]), "body");
// run the benchmark
QualityBenchmark qrun = new QualityBenchmark(qqs, qqParser, searcher, docNameField);
qrun.setMaxResults(maxResults);
QualityStats stats[] = qrun.execute(judge, submitLog, logger);
// print an avarage sum of the results
QualityStats avg = QualityStats.average(stats);
avg.log("SUMMARY", 2, logger, " ");
reader.close();
dir.close();
}
示例3: main
import org.apache.lucene.benchmark.quality.utils.SubmissionReport; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
if (args.length < 4 || args.length > 5) {
System.err.println("Usage: QueryDriver <topicsFile> <qrelsFile> <submissionFile> <indexDir> [querySpec]");
System.err.println("topicsFile: input file containing queries");
System.err.println("qrelsFile: input file containing relevance judgements");
System.err.println("submissionFile: output submission file for trec_eval");
System.err.println("indexDir: index directory");
System.err.println("querySpec: string composed of fields to use in query consisting of T=title,D=description,N=narrative:");
System.err.println("\texample: TD (query on Title + Description). The default is T (title only)");
System.exit(1);
}
File topicsFile = new File(args[0]);
File qrelsFile = new File(args[1]);
SubmissionReport submitLog = new SubmissionReport(new PrintWriter(args[2], "UTF-8"), "lucene");
FSDirectory dir = FSDirectory.open(new File(args[3]));
String fieldSpec = args.length == 5 ? args[4] : "T"; // default to Title-only if not specified.
IndexReader reader = DirectoryReader.open(dir);
IndexSearcher searcher = new IndexSearcher(reader);
int maxResults = 1000;
String docNameField = "docname";
PrintWriter logger = new PrintWriter(new OutputStreamWriter(System.out, Charset.defaultCharset()), true);
// use trec utilities to read trec topics into quality queries
TrecTopicsReader qReader = new TrecTopicsReader();
QualityQuery qqs[] = qReader.readQueries(new BufferedReader(IOUtils.getDecodingReader(topicsFile, IOUtils.CHARSET_UTF_8)));
// prepare judge, with trec utilities that read from a QRels file
Judge judge = new TrecJudge(new BufferedReader(IOUtils.getDecodingReader(qrelsFile, IOUtils.CHARSET_UTF_8)));
// validate topics & judgments match each other
judge.validateData(qqs, logger);
Set<String> fieldSet = new HashSet<String>();
if (fieldSpec.indexOf('T') >= 0) fieldSet.add("title");
if (fieldSpec.indexOf('D') >= 0) fieldSet.add("description");
if (fieldSpec.indexOf('N') >= 0) fieldSet.add("narrative");
// set the parsing of quality queries into Lucene queries.
QualityQueryParser qqParser = new SimpleQQParser(fieldSet.toArray(new String[0]), "body");
// run the benchmark
QualityBenchmark qrun = new QualityBenchmark(qqs, qqParser, searcher, docNameField);
qrun.setMaxResults(maxResults);
QualityStats stats[] = qrun.execute(judge, submitLog, logger);
// print an avarage sum of the results
QualityStats avg = QualityStats.average(stats);
avg.log("SUMMARY", 2, logger, " ");
reader.close();
dir.close();
}
示例4: main
import org.apache.lucene.benchmark.quality.utils.SubmissionReport; //导入依赖的package包/类
public static void main(String[] args) throws Throwable {
File topicsFile = new File("aos/lucene/benchmark/topics.txt");
File qrelsFile = new File("aos/lucene/benchmark/qrels.txt");
Directory dir = FSDirectory.open(new File("indexes/MeetLucene"));
IndexReader reader = DirectoryReader.open(dir);
IndexSearcher searcher = new IndexSearcher(reader);
String docNameField = "filename";
PrintWriter LOGGER = new PrintWriter(System.out, true);
TrecTopicsReader qReader = new TrecTopicsReader();
QualityQuery qqs[] = qReader.readQueries(new BufferedReader(new FileReader(topicsFile)));
Judge judge = new TrecJudge(new BufferedReader(new FileReader(qrelsFile)));
judge.validateData(qqs, LOGGER);
QualityQueryParser qqParser = new SimpleQQParser("title", "contents");
QualityBenchmark qrun = new QualityBenchmark(qqs, qqParser, searcher, docNameField);
SubmissionReport submitLog = null;
QualityStats stats[] = qrun.execute(judge, submitLog, LOGGER);
QualityStats avg = QualityStats.average(stats);
avg.log("SUMMARY", 2, LOGGER, " ");
dir.close();
}