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());
}
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());
}
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)])");
}
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}))");
}
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.*/)))");
}
Aggregations