本文整理汇总了Java中org.apache.lucene.benchmark.quality.QualityQuery类的典型用法代码示例。如果您正苦于以下问题:Java QualityQuery类的具体用法?Java QualityQuery怎么用?Java QualityQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QualityQuery类属于org.apache.lucene.benchmark.quality包,在下文中一共展示了QualityQuery类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: parse
import org.apache.lucene.benchmark.quality.QualityQuery; //导入依赖的package包/类
@Override
public Query parse(QualityQuery qq) throws ParseException {
//System.out.println("\n--------\n"+qq.getQueryID());
if(useAugmentedVersion) {
try {
return getAugmentedTermQuery(qq);
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}else{
return getTermQuery(qq);
}
}
开发者ID:sebastian-hofstaetter,项目名称:ir-generalized-translation-models,代码行数:17,代码来源:SimilarityApiParser.java
示例2: report
import org.apache.lucene.benchmark.quality.QualityQuery; //导入依赖的package包/类
/**
* Report a search result for a certain quality query.
* @param qq quality query for which the results are reported.
* @param td search results for the query.
* @param docNameField stored field used for fetching the result doc name.
* @param searcher index access for fetching doc name.
* @throws IOException in case of a problem.
*/
public void report(QualityQuery qq, TopDocs td, String docNameField, IndexSearcher searcher) throws IOException {
if (logger==null) {
return;
}
ScoreDoc sd[] = td.scoreDocs;
String sep = " \t ";
DocNameExtractor xt = new DocNameExtractor(docNameField);
for (int i=0; i<sd.length; i++) {
String docName = xt.docName(searcher,sd[i].doc);
logger.println(
qq.getQueryID() + sep +
"Q0" + sep +
format(docName,20) + sep +
format(""+i,7) + sep +
nf.format(sd[i].score) + sep +
name
);
}
}
开发者ID:europeana,项目名称:search,代码行数:28,代码来源:SubmissionReport.java
示例3: readQueries
import org.apache.lucene.benchmark.quality.QualityQuery; //导入依赖的package包/类
/**
* Read quality queries from trec 1MQ format topics file.
* @param reader where queries are read from.
* @return the result quality queries.
* @throws IOException if cannot read the queries.
*/
public QualityQuery[] readQueries(BufferedReader reader) throws IOException {
ArrayList<QualityQuery> res = new ArrayList<>();
String line;
try {
while (null!=(line=reader.readLine())) {
line = line.trim();
if (line.startsWith("#")) {
continue;
}
// id
int k = line.indexOf(":");
String id = line.substring(0,k).trim();
// qtext
String qtext = line.substring(k+1).trim();
// we got a topic!
HashMap<String,String> fields = new HashMap<>();
fields.put(name,qtext);
//System.out.println("id: "+id+" qtext: "+qtext+" line: "+line);
QualityQuery topic = new QualityQuery(id,fields);
res.add(topic);
}
} finally {
reader.close();
}
// sort result array (by ID)
QualityQuery qq[] = res.toArray(new QualityQuery[0]);
Arrays.sort(qq);
return qq;
}
开发者ID:europeana,项目名称:search,代码行数:36,代码来源:Trec1MQReader.java
示例4: maxRecall
import org.apache.lucene.benchmark.quality.QualityQuery; //导入依赖的package包/类
@Override
public int maxRecall(QualityQuery query) {
QRelJudgement qrj = judgements.get(query.getQueryID());
if (qrj!=null) {
return qrj.maxRecall();
}
return 0;
}
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:TrecJudge.java
示例5: readQueries
import org.apache.lucene.benchmark.quality.QualityQuery; //导入依赖的package包/类
/**
* Read quality queries from trec 1MQ format topics file.
* @param reader where queries are read from.
* @return the result quality queries.
* @throws IOException if cannot read the queries.
*/
public QualityQuery[] readQueries(BufferedReader reader) throws IOException {
ArrayList<QualityQuery> res = new ArrayList<QualityQuery>();
String line;
try {
while (null!=(line=reader.readLine())) {
line = line.trim();
if (line.startsWith("#")) {
continue;
}
// id
int k = line.indexOf(":");
String id = line.substring(0,k).trim();
// qtext
String qtext = line.substring(k+1).trim();
// we got a topic!
HashMap<String,String> fields = new HashMap<String,String>();
fields.put(name,qtext);
//System.out.println("id: "+id+" qtext: "+qtext+" line: "+line);
QualityQuery topic = new QualityQuery(id,fields);
res.add(topic);
}
} finally {
reader.close();
}
// sort result array (by ID)
QualityQuery qq[] = res.toArray(new QualityQuery[0]);
Arrays.sort(qq);
return qq;
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:36,代码来源:Trec1MQReader.java
示例6: parse
import org.apache.lucene.benchmark.quality.QualityQuery; //导入依赖的package包/类
@Override
public Query parse(QualityQuery qq) throws ParseException {
QueryParser qp = queryParser.get();
if (qp==null) {
qp = new QueryParser(Version.LUCENE_CURRENT, indexField, new StandardAnalyzer(Version.LUCENE_CURRENT));
queryParser.set(qp);
}
BooleanQuery bq = new BooleanQuery();
for (int i = 0; i < qqNames.length; i++)
bq.add(qp.parse(QueryParserBase.escape(qq.getValue(qqNames[i]))), BooleanClause.Occur.SHOULD);
return bq;
}
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:14,代码来源:SimpleQQParser.java
示例7: readQueries
import org.apache.lucene.benchmark.quality.QualityQuery; //导入依赖的package包/类
/**
* Read quality queries from trec format topics file.
* @param reader where queries are read from.
* @return the result quality queries.
* @throws IOException if cannot read the queries.
*/
public QualityQuery[] readQueries(BufferedReader reader) throws IOException {
ArrayList<QualityQuery> res = new ArrayList<>();
StringBuilder sb;
try {
while (null!=(sb=read(reader,"<top>",null,false,false))) {
HashMap<String,String> fields = new HashMap<>();
// id
sb = read(reader,"<num>",null,true,false);
int k = sb.indexOf(":");
String id = sb.substring(k+1).trim();
// title
sb = read(reader,"<title>",null,true,false);
k = sb.indexOf(">");
String title = sb.substring(k+1).trim();
// description
read(reader,"<desc>",null,false,false);
sb.setLength(0);
String line = null;
while ((line = reader.readLine()) != null) {
if (line.startsWith("<narr>"))
break;
if (sb.length() > 0) sb.append(' ');
sb.append(line);
}
String description = sb.toString().trim();
// narrative
sb.setLength(0);
while ((line = reader.readLine()) != null) {
if (line.startsWith("</top>"))
break;
if (sb.length() > 0) sb.append(' ');
sb.append(line);
}
String narrative = sb.toString().trim();
// we got a topic!
fields.put("title",title);
fields.put("description",description);
fields.put("narrative", narrative);
QualityQuery topic = new QualityQuery(id,fields);
res.add(topic);
}
} finally {
reader.close();
}
// sort result array (by ID)
QualityQuery qq[] = res.toArray(new QualityQuery[0]);
Arrays.sort(qq);
return qq;
}
开发者ID:europeana,项目名称:search,代码行数:56,代码来源:TrecTopicsReader.java
示例8: isRelevant
import org.apache.lucene.benchmark.quality.QualityQuery; //导入依赖的package包/类
@Override
public boolean isRelevant(String docName, QualityQuery query) {
QRelJudgement qrj = judgements.get(query.getQueryID());
return qrj!=null && qrj.isRelevant(docName);
}
开发者ID:europeana,项目名称:search,代码行数:6,代码来源:TrecJudge.java
示例9: readQueries
import org.apache.lucene.benchmark.quality.QualityQuery; //导入依赖的package包/类
/**
* Read quality queries from trec format topics file.
* @param reader where queries are read from.
* @return the result quality queries.
* @throws IOException if cannot read the queries.
*/
public QualityQuery[] readQueries(BufferedReader reader) throws IOException {
ArrayList<QualityQuery> res = new ArrayList<QualityQuery>();
StringBuilder sb;
try {
while (null!=(sb=read(reader,"<top>",null,false,false))) {
HashMap<String,String> fields = new HashMap<String,String>();
// id
sb = read(reader,"<num>",null,true,false);
int k = sb.indexOf(":");
String id = sb.substring(k+1).trim();
// title
sb = read(reader,"<title>",null,true,false);
k = sb.indexOf(">");
String title = sb.substring(k+1).trim();
// description
read(reader,"<desc>",null,false,false);
sb.setLength(0);
String line = null;
while ((line = reader.readLine()) != null) {
if (line.startsWith("<narr>"))
break;
if (sb.length() > 0) sb.append(' ');
sb.append(line);
}
String description = sb.toString().trim();
// narrative
sb.setLength(0);
while ((line = reader.readLine()) != null) {
if (line.startsWith("</top>"))
break;
if (sb.length() > 0) sb.append(' ');
sb.append(line);
}
String narrative = sb.toString().trim();
// we got a topic!
fields.put("title",title);
fields.put("description",description);
fields.put("narrative", narrative);
QualityQuery topic = new QualityQuery(id,fields);
res.add(topic);
}
} finally {
reader.close();
}
// sort result array (by ID)
QualityQuery qq[] = res.toArray(new QualityQuery[0]);
Arrays.sort(qq);
return qq;
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:56,代码来源:TrecTopicsReader.java
示例10: main
import org.apache.lucene.benchmark.quality.QualityQuery; //导入依赖的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();
}
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:32,代码来源:PrecisionRecall.java
注:本文中的org.apache.lucene.benchmark.quality.QualityQuery类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论