Search in sources :

Example 1 with SearchCollection

use of io.anserini.search.SearchCollection 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();
    }
}
Also used : SearchArgs(io.anserini.search.SearchArgs) SearchCollection(io.anserini.search.SearchCollection) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) File(java.io.File) NotStoredException(io.anserini.index.NotStoredException) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

NotStoredException (io.anserini.index.NotStoredException)1 SearchArgs (io.anserini.search.SearchArgs)1 SearchCollection (io.anserini.search.SearchCollection)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Test (org.junit.Test)1