use of io.anserini.search.SearchArgs in project Anserini by castorini.
the class EndToEndTest method createDefaultSearchArgs.
protected SearchArgs createDefaultSearchArgs() {
SearchArgs searchArgs = new SearchArgs();
// required
searchArgs.index = this.indexPath;
searchArgs.output = this.searchOutputPrefix + this.topicReader;
searchArgs.topicReader = this.topicReader;
searchArgs.topics = new String[] { this.topicFile };
searchArgs.bm25 = true;
// optional
searchArgs.topicfield = "title";
searchArgs.searchtweets = false;
searchArgs.hits = 1000;
searchArgs.keepstop = false;
return searchArgs;
}
use of io.anserini.search.SearchArgs in project Anserini by castorini.
the class EndToEndTest method testSearching.
@Test
public void testSearching() {
// Subclasses will override this method and provide the ground truth.
setSearchGroundTruth();
try {
for (Map.Entry<String, SearchArgs> entry : testQueries.entrySet()) {
SearchCollection searcher = new SearchCollection(entry.getValue());
searcher.runTopics();
Map<String, List<String>> actualQuery = searcher.getQueries();
searcher.close();
// check query tokens
if (!queryTokens.isEmpty()) {
assertEquals(queryTokens, actualQuery);
}
checkRankingResults(entry.getKey(), entry.getValue().output);
// Remember to cleanup run files.
cleanup.add(new File(entry.getValue().output));
}
} catch (Exception e) {
System.out.println("Test Searching failed: ");
e.printStackTrace();
fail();
}
}
use of io.anserini.search.SearchArgs in project Anserini by castorini.
the class JsonVectorEndToEndTest method setSearchGroundTruth.
@Override
protected void setSearchGroundTruth() {
topicReader = "TsvInt";
topicFile = "src/test/resources/sample_topics/json_vector_topics.tsv";
SearchArgs searchArg = createDefaultSearchArgs().impact();
searchArg.pretokenized = true;
testQueries.put("impact", searchArg);
queryTokens.put("1", new ArrayList<>());
queryTokens.get("1").add("f35");
queryTokens.put("2", new ArrayList<>());
queryTokens.get("2").add("f3");
queryTokens.put("3", new ArrayList<>());
queryTokens.get("3").add("f4");
referenceRunOutput.put("impact", new String[] { "1 Q0 doc2 1 8.000000 Anserini", "2 Q0 doc1 1 1.000000 Anserini", "3 Q0 doc1 1 4.000000 Anserini", "3 Q0 doc2 2 3.000000 Anserini" });
}
use of io.anserini.search.SearchArgs in project Anserini by castorini.
the class PretokenizedIndexEndToEndTest method setSearchGroundTruth.
@Override
protected void setSearchGroundTruth() {
topicReader = "TsvInt";
topicFile = "src/test/resources/sample_topics/json_topics.tsv";
SearchArgs searchArg = createDefaultSearchArgs().bm25();
searchArg.pretokenized = true;
testQueries.put("bm25", searchArg);
queryTokens.put("1", new ArrayList<>());
queryTokens.get("1").add("##ing");
queryTokens.get("1").add("##vert");
referenceRunOutput.put("bm25", new String[] { "1 Q0 2000001 1 0.922400 Anserini" });
}
use of io.anserini.search.SearchArgs in project Anserini by castorini.
the class TrecEndToEndPassageTest method setSearchGroundTruth.
@Override
protected void setSearchGroundTruth() {
topicReader = "Trec";
topicFile = "src/test/resources/sample_topics/Trec";
SearchArgs args;
args = createDefaultSearchArgs().bm25();
args.selectMaxPassage = true;
testQueries.put("bm25v1", args);
referenceRunOutput.put("bm25v1", new String[] { "1 Q0 TREC_DOC_1 1 0.343200 Anserini", "1 Q0 WSJ_1 2 0.068700 Anserini" });
args = createDefaultSearchArgs().bm25();
args.selectMaxPassage = true;
args.selectMaxPassage_hits = 1;
testQueries.put("bm25v2", args);
referenceRunOutput.put("bm25v2", new String[] { "1 Q0 TREC_DOC_1 1 0.343200 Anserini" });
args = createDefaultSearchArgs().qld();
args.selectMaxPassage = true;
testQueries.put("qld", args);
referenceRunOutput.put("qld", new String[] { "1 Q0 TREC_DOC_1 1 0.002500 Anserini", "1 Q0 WSJ_1 2 0.000000 Anserini" });
args = createDefaultSearchArgs().qljm();
args.selectMaxPassage = true;
testQueries.put("qljm", args);
referenceRunOutput.put("qljm", new String[] { "1 Q0 TREC_DOC_1 1 4.872300 Anserini", "1 Q0 WSJ_1 2 1.658200 Anserini" });
args = createDefaultSearchArgs().inl2();
args.selectMaxPassage = true;
testQueries.put("inl2", args);
referenceRunOutput.put("inl2", new String[] { "1 Q0 TREC_DOC_1 1 0.133200 Anserini", "1 Q0 WSJ_1 2 0.021100 Anserini" });
args = createDefaultSearchArgs().spl();
args.selectMaxPassage = true;
testQueries.put("spl", args);
referenceRunOutput.put("spl", new String[] { "1 Q0 TREC_DOC_1 1 0.446100 Anserini", "1 Q0 WSJ_1 2 0.115900 Anserini" });
args = createDefaultSearchArgs().f2exp();
args.selectMaxPassage = true;
testQueries.put("f2exp", args);
referenceRunOutput.put("f2exp", new String[] { "1 Q0 TREC_DOC_1 1 1.434700 Anserini", "1 Q0 WSJ_1 2 0.536200 Anserini" });
args = createDefaultSearchArgs().f2log();
args.selectMaxPassage = true;
testQueries.put("f2log", args);
referenceRunOutput.put("f2log", new String[] { "1 Q0 TREC_DOC_1 1 0.548500 Anserini", "1 Q0 WSJ_1 2 0.139500 Anserini" });
}
Aggregations