Search in sources :

Example 1 with SearchWebCollection

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();
}
Also used : Path(java.nio.file.Path) RerankerCascade(io.anserini.rerank.RerankerCascade) TopicReader(io.anserini.search.query.TopicReader) IdentityReranker(io.anserini.rerank.IdentityReranker) BM25Similarity(org.apache.lucene.search.similarities.BM25Similarity) SearchWebCollection(io.anserini.search.SearchWebCollection)

Aggregations

IdentityReranker (io.anserini.rerank.IdentityReranker)1 RerankerCascade (io.anserini.rerank.RerankerCascade)1 SearchWebCollection (io.anserini.search.SearchWebCollection)1 TopicReader (io.anserini.search.query.TopicReader)1 Path (java.nio.file.Path)1 BM25Similarity (org.apache.lucene.search.similarities.BM25Similarity)1