Search in sources :

Example 16 with SpanQueryWrapper

use of de.ids_mannheim.korap.query.wrap.SpanQueryWrapper in project Krill by KorAP.

the class TestSpanReferenceQueryJSON method testMultipleReferences.

@Test
public void testMultipleReferences() throws QueryException {
    String filepath = getClass().getResource("/queries/reference/multiple-references.jsonld").getFile();
    SpanQueryWrapper sqwi = getJSONQuery(filepath);
    SpanQuery sq = sqwi.toQuery();
    // 'cat="VP" & cat="NP" & cat="PP" & #1 . #2 & #2 . #3 & #1 .
    // #3 & #2 ->dep #1'
    assertEquals("spanReference(focus(#[1,2]spanSegment({1: <tokens:c:VP />}, " + "focus(#2: spanSegment(spanRelation(tokens:>:mate/d:HEAD), " + "focus(2: spanReference(spanNext(focus(1: spanNext(focus(2: spanNext({1: <tokens:c:VP />}, " + "{2: <tokens:c:NP />})), {3: <tokens:c:PP />})), {3: <tokens:c:PP />}), 3)))))), 1)", sq.toString());
}
Also used : SpanQueryWrapper(de.ids_mannheim.korap.query.wrap.SpanQueryWrapper) SpanQuery(org.apache.lucene.search.spans.SpanQuery) Test(org.junit.Test)

Example 17 with SpanQueryWrapper

use of de.ids_mannheim.korap.query.wrap.SpanQueryWrapper in project Krill by KorAP.

the class TestSpanExpansionIndex method indexRegexSequence.

@Test
public void indexRegexSequence() throws Exception {
    KrillIndex ki = new KrillIndex();
    ki.addDoc(createFieldDoc5());
    ki.commit();
    QueryBuilder kq = new QueryBuilder("base");
    SpanQueryWrapper sq = kq.seq(kq.or("s:baumgarten", "s:steingarten")).append(kq.seg().without(kq.or("s:franz", "s:hans")));
    // Expected to find [baumgarten steingarten]
    Krill ks = _newKrill(sq);
    Result kr = ki.search(ks);
    assertEquals((long) 1, kr.getTotalResults());
    assertEquals("... baum [[baumgarten steingarten]] franz ...", kr.getMatch(0).getSnippetBrackets());
    // The same result should be shown for:
    sq = kq.seq(kq.re("s:.*garten")).append(kq.seg().without(kq.re("s:.*an.*")));
    ks = _newKrill(sq);
    kr = ki.search(ks);
    assertEquals((long) 1, kr.getTotalResults());
    assertEquals("... baum [[baumgarten steingarten]] franz ...", kr.getMatch(0).getSnippetBrackets());
}
Also used : Krill(de.ids_mannheim.korap.Krill) QueryBuilder(de.ids_mannheim.korap.query.QueryBuilder) SpanQueryWrapper(de.ids_mannheim.korap.query.wrap.SpanQueryWrapper) KrillIndex(de.ids_mannheim.korap.KrillIndex) Result(de.ids_mannheim.korap.response.Result) Test(org.junit.Test)

Example 18 with SpanQueryWrapper

use of de.ids_mannheim.korap.query.wrap.SpanQueryWrapper in project Krill by KorAP.

the class TestKrillQueryJSON method queryJSONcosmas4.

@Test
public void queryJSONcosmas4() throws QueryException {
    SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/cosmas4.json").getFile());
    // "das /+w1:3,s1:1 Buch"
    assertEquals(sqwi.toQuery().toString(), "spanMultipleDistance(tokens:s:das, tokens:s:Buch, [(w[1:3], ordered, notExcluded), (base/s:s[1:1], ordered, notExcluded)])");
}
Also used : SpanQueryWrapper(de.ids_mannheim.korap.query.wrap.SpanQueryWrapper) Test(org.junit.Test)

Example 19 with SpanQueryWrapper

use of de.ids_mannheim.korap.query.wrap.SpanQueryWrapper in project Krill by KorAP.

the class TestKrillQueryJSON method queryJSONBsp5.

@Test
public void queryJSONBsp5() throws QueryException {
    SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp5.jsonld").getFile());
    // focus(1:[base=Der]{1:[base=Mann]})
    assertEquals(sqwi.toQuery().toString(), "focus(1: spanNext(tokens:mate/l:Der, {1: tokens:mate/l:Mann}))");
}
Also used : SpanQueryWrapper(de.ids_mannheim.korap.query.wrap.SpanQueryWrapper) Test(org.junit.Test)

Example 20 with SpanQueryWrapper

use of de.ids_mannheim.korap.query.wrap.SpanQueryWrapper in project Krill by KorAP.

the class TestKrillQueryJSON method queryJSONoverlapsFrameWorkaround.

@Test
public void queryJSONoverlapsFrameWorkaround() throws QueryException {
    // overlaps(<s>,[tt/p=CARD][tt/p="N.*"])
    SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bugs/overlaps_frame_workaround.jsonld").getFile());
    assertEquals(sqwi.toQuery().toString(), "spanOverlap(<tokens:s />, spanNext(tokens:tt/p:CARD, SpanMultiTermQueryWrapper(tokens:/tt/p:N.*/)))");
}
Also used : SpanQueryWrapper(de.ids_mannheim.korap.query.wrap.SpanQueryWrapper) Test(org.junit.Test)

Aggregations

SpanQueryWrapper (de.ids_mannheim.korap.query.wrap.SpanQueryWrapper)165 Test (org.junit.Test)150 SpanQuery (org.apache.lucene.search.spans.SpanQuery)65 KrillIndex (de.ids_mannheim.korap.KrillIndex)17 QueryException (de.ids_mannheim.korap.util.QueryException)14 KrillQuery (de.ids_mannheim.korap.KrillQuery)13 QueryBuilder (de.ids_mannheim.korap.query.QueryBuilder)11 Result (de.ids_mannheim.korap.response.Result)8 JsonNode (com.fasterxml.jackson.databind.JsonNode)7 Krill (de.ids_mannheim.korap.Krill)5 SpanRepetitionQueryWrapper (de.ids_mannheim.korap.query.wrap.SpanRepetitionQueryWrapper)3 TestSimple.getJsonString (de.ids_mannheim.korap.TestSimple.getJsonString)2 SpanClassQuery (de.ids_mannheim.korap.query.SpanClassQuery)2 SpanDistanceQuery (de.ids_mannheim.korap.query.SpanDistanceQuery)2 SpanWithinQuery (de.ids_mannheim.korap.query.SpanWithinQuery)2 SpanAlterQueryWrapper (de.ids_mannheim.korap.query.wrap.SpanAlterQueryWrapper)2 SpanRegexQueryWrapper (de.ids_mannheim.korap.query.wrap.SpanRegexQueryWrapper)2 SpanSegmentQueryWrapper (de.ids_mannheim.korap.query.wrap.SpanSegmentQueryWrapper)2 Term (org.apache.lucene.index.Term)2 SpanOrQuery (org.apache.lucene.search.spans.SpanOrQuery)2