Search in sources :

Example 36 with KrillCollection

use of de.ids_mannheim.korap.KrillCollection in project Krill by KorAP.

the class TestKrill method searchJSON2.

@Test
public void searchJSON2() throws IOException {
    // Construct index
    KrillIndex ki = new KrillIndex();
    // Indexing test files
    for (String i : new String[] { "00001", "00002", "00003", "00004", "00005", "00006", "02439", "00012-fakemeta", "00030-fakemeta" /*
                  "02035-substring",
                  "05663-unbalanced",
                  "07452-deep"
                */
    }) {
        ki.addDoc(getClass().getResourceAsStream("/wiki/" + i + ".json.gz"), true);
    }
    ;
    ki.commit();
    String json = getJsonString(getClass().getResource("/queries/metaquery4.jsonld").getFile());
    Krill ks = new Krill(json);
    Result kr = ks.apply(ki);
    assertEquals(kr.getTotalResults(), 1);
    ks = new Krill(json);
    // Ignore the collection part of the query!
    ks.setCollection(new KrillCollection());
    kr = ks.apply(ki);
    assertEquals(kr.getTotalResults(), 5);
    json = getJsonString(getClass().getResource("/queries/metaquery5.jsonld").getFile());
    ks = new Krill(json);
    kr = ks.apply(ki);
    assertEquals(kr.getTotalResults(), 1);
    json = getJsonString(getClass().getResource("/queries/metaquery6.jsonld").getFile());
    ks = new Krill(json);
    kr = ks.apply(ki);
    assertEquals(kr.getTotalResults(), 1);
}
Also used : Krill(de.ids_mannheim.korap.Krill) TestSimple.getJsonString(de.ids_mannheim.korap.TestSimple.getJsonString) KrillIndex(de.ids_mannheim.korap.KrillIndex) KrillCollection(de.ids_mannheim.korap.KrillCollection) Result(de.ids_mannheim.korap.response.Result) Test(org.junit.Test)

Example 37 with KrillCollection

use of de.ids_mannheim.korap.KrillCollection in project Krill by KorAP.

the class TestWPDIndex method testCase4.

/**
 * Element distance exclusion
 */
@Test
public void testCase4() throws IOException {
    SpanDistanceQuery sq = createElementDistanceQuery("s", "s:weg", "s:fahren", 1, 1, false, true);
    ks = new Krill(sq);
    kr = ks.apply(ki);
    assertEquals(kr.getTotalResults(), 979);
    // 0.8s
    // Check if it includes some results
    /*
        BooleanFilter bf = new BooleanFilter();
        bf.or("ID", "WPD_BBB.04463", "WPD_III.00758");
        */
    KrillCollection kc = new KrillCollection();
    CollectionBuilder cb = new CollectionBuilder();
    kc.fromBuilder(cb.orGroup().with(cb.term("ID", "WPD_BBB.04463")).with(cb.term("ID", "WPD_III.00758")));
    // kc.filter(bf);
    ks.setCollection(kc);
    kr = ks.apply(ki);
    assertEquals(1094, kr.getMatch(0).getStartPos());
    assertEquals(451, kr.getMatch(1).getEndPos());
}
Also used : Krill(de.ids_mannheim.korap.Krill) SpanDistanceQuery(de.ids_mannheim.korap.query.SpanDistanceQuery) CollectionBuilder(de.ids_mannheim.korap.collection.CollectionBuilder) KrillCollection(de.ids_mannheim.korap.KrillCollection) Test(org.junit.Test)

Aggregations

KrillCollection (de.ids_mannheim.korap.KrillCollection)37 Test (org.junit.Test)35 KrillIndex (de.ids_mannheim.korap.KrillIndex)24 Krill (de.ids_mannheim.korap.Krill)17 Result (de.ids_mannheim.korap.response.Result)15 CollectionBuilder (de.ids_mannheim.korap.collection.CollectionBuilder)11 SearchContext (de.ids_mannheim.korap.response.SearchContext)5 MMapDirectory (org.apache.lucene.store.MMapDirectory)5 TestSimple.getJsonString (de.ids_mannheim.korap.TestSimple.getJsonString)4 FieldDocument (de.ids_mannheim.korap.index.FieldDocument)4 QueryBuilder (de.ids_mannheim.korap.query.QueryBuilder)3 Term (org.apache.lucene.index.Term)2 SpanQuery (org.apache.lucene.search.spans.SpanQuery)2 SpanTermQuery (org.apache.lucene.search.spans.SpanTermQuery)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 SpanClassQuery (de.ids_mannheim.korap.query.SpanClassQuery)1 SpanDistanceQuery (de.ids_mannheim.korap.query.SpanDistanceQuery)1 SpanElementQuery (de.ids_mannheim.korap.query.SpanElementQuery)1 SpanFocusQuery (de.ids_mannheim.korap.query.SpanFocusQuery)1