use of io.anserini.search.SearchWebCollection in project Anserini by castorini.
the class SearchTimeUtil method main.
public static void main(String[] args) throws IOException, ParseException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, InstantiationException {
if (args.length != 1) {
System.err.println("Usage: SearchTimeUtil <indexDir>");
System.err.println("indexDir: index directory");
System.exit(1);
}
String[] topics = { "topics.web.1-50.txt", "topics.web.51-100.txt", "topics.web.101-150.txt", "topics.web.151-200.txt", "topics.web.201-250.txt", "topics.web.251-300.txt" };
SearchWebCollection searcher = new SearchWebCollection(args[0]);
for (String topicFile : topics) {
Path topicsFile = Paths.get("src/resources/topics-and-qrels/", topicFile);
TopicReader tr = (TopicReader) Class.forName("io.anserini.search.query." + "Webxml" + "TopicReader").getConstructor(Path.class).newInstance(topicsFile);
SortedMap<Integer, String> queries = tr.read();
for (int i = 1; i <= 3; i++) {
final long start = System.nanoTime();
String submissionFile = File.createTempFile(topicFile + "_" + i, ".tmp").getAbsolutePath();
RerankerCascade cascade = new RerankerCascade();
cascade.add(new IdentityReranker());
searcher.search(queries, submissionFile, new BM25Similarity(0.9f, 0.4f), 1000, cascade);
final long durationMillis = TimeUnit.MILLISECONDS.convert(System.nanoTime() - start, TimeUnit.NANOSECONDS);
System.out.println(topicFile + "_" + i + " search completed in " + DurationFormatUtils.formatDuration(durationMillis, "mm:ss:SSS"));
}
}
searcher.close();
}
Aggregations