use of de.ids_mannheim.korap.query.wrap.SpanQueryWrapper in project Krill by KorAP.
the class TestSpanRelationQueryJSON method testTypedRelationWithWrapTokenNodes.
@Test
public void testTypedRelationWithWrapTokenNodes() throws QueryException {
// query = "corenlp/c=\"VP\" & corenlp/c=\"NP\" & #1 ->malt/d[func=\"PP\"] #2";
String filepath = getClass().getResource("/queries/relation/typed-relation-with-wrap-token-nodes.json").getFile();
SpanQueryWrapper sqwi = getJSONQuery(filepath);
SpanQuery sq = sqwi.toQuery();
assertEquals("focus(#[1,2]spanSegment(tokens:tt/p:VVINF, " + "focus(#2: spanSegment(" + "spanRelation(tokens:>:malt/d:KONJ), tokens:tt/p:KOUI))))", sq.toString());
}
use of de.ids_mannheim.korap.query.wrap.SpanQueryWrapper in project Krill by KorAP.
the class TestSampleIndex method testMultipleDistanceWithWildcards.
@Test
public void testMultipleDistanceWithWildcards() throws IOException, QueryException {
WildcardQuery wcquery = new WildcardQuery(new Term("tokens", "s:meine*"));
SpanMultiTermQueryWrapper<WildcardQuery> mtq = new SpanMultiTermQueryWrapper<WildcardQuery>(wcquery);
// meine* /+w1:2 &Erfahrung
SpanQuery tdq = new SpanDistanceQuery(mtq, sq, TestMultipleDistanceIndex.createConstraint("w", 1, 2, true, false), true);
kr = sample.search(tdq, (short) 10);
assertEquals(4, kr.getMatches().size());
assertEquals(107, kr.getMatch(0).getStartPos());
assertEquals(109, kr.getMatch(0).getEndPos());
assertEquals(132566, kr.getMatch(1).getStartPos());
assertEquals(132569, kr.getMatch(1).getEndPos());
assertEquals(161393, kr.getMatch(2).getStartPos());
assertEquals(161396, kr.getMatch(2).getEndPos());
assertEquals(10298, kr.getMatch(3).getStartPos());
assertEquals(10301, kr.getMatch(3).getEndPos());
// meine* /+s0 &Erfahrung
SpanQuery edq = new SpanDistanceQuery(mtq, sq, TestMultipleDistanceIndex.createConstraint("tokens", "base/s:s", 0, 0, true, false), true);
kr = sample.search(edq, (short) 20);
assertEquals(18, kr.getMatches().size());
// meine* /+w1:2,s0 &Erfahrung
SpanQuery mdsq = new SpanMultipleDistanceQuery(new SpanClassQuery(mtq, (byte) 129), new SpanClassQuery(sq, (byte) 129), constraints, true, true);
kr = sample.search(mdsq, (short) 10);
assertEquals(4, kr.getMatches().size());
// check SpanQueryWrapper generated query
SpanQueryWrapper sqwi = getJSONQuery(getClass().getResource("/queries/bugs/cosmas_wildcards.jsonld").getFile());
SpanQuery jsq = sqwi.toQuery();
assertEquals(mdsq.toString(), jsq.toString());
}
use of de.ids_mannheim.korap.query.wrap.SpanQueryWrapper in project Krill by KorAP.
the class TestSampleIndex method testWildcardsWithJson.
@Test
public void testWildcardsWithJson() throws IOException, QueryException {
SpanQueryWrapper sqwi = getJSONQuery(getClass().getResource("/queries/bugs/cosmas_wildcards_all.jsonld").getFile());
SpanQuery sq = sqwi.toQuery();
kr = sample.search(sq, (short) 10);
assertEquals(4, kr.getMatches().size());
// test krill apply
Krill krill = new Krill();
krill.setSpanQuery(sq);
krill.setIndex(sample);
kr = krill.apply();
assertEquals(4, kr.getMatches().size());
// test krill deserialization
String jsonString = getJsonString(getClass().getResource("/queries/bugs/cosmas_wildcards_all.jsonld").getFile());
krill = new Krill();
ObjectMapper mapper = new ObjectMapper();
JsonNode jsonNode = mapper.readTree(jsonString);
final KrillQuery kq = new KrillQuery("tokens");
krill.setQuery(kq);
SpanQueryWrapper qw = kq.fromKoral(jsonNode.get("query"));
assertEquals(sqwi.toQuery(), qw.toQuery());
krill.setSpanQuery(qw.toQuery());
kr = krill.apply(sample);
assertEquals(4, kr.getMatches().size());
}
use of de.ids_mannheim.korap.query.wrap.SpanQueryWrapper in project Krill by KorAP.
the class TestSpanSubspanQueryJSON method testNegativeEmbeddedSequenceWithClass.
@Test
public void testNegativeEmbeddedSequenceWithClass() throws QueryException {
// submatch(0,1:{1:[base != Baum] dass})
String filepath = getClass().getResource("/queries/submatch/embedded-negative-class-seq.jsonld").getFile();
SpanQueryWrapper sqwi = getJSONQuery(filepath);
SpanQuery sq = sqwi.toQuery();
assertEquals("subspan({1: spanExpansion(tokens:s:dass, !tokens:l:Baum{1, 1}, left)}, 0, 1)", sq.toString());
}
use of de.ids_mannheim.korap.query.wrap.SpanQueryWrapper in project Krill by KorAP.
the class TestSpanSubspanQueryJSON method testNegativeSequenceWithClass.
@Test
public void testNegativeSequenceWithClass() throws QueryException {
// das {1:submatch(0,1:[base != Baum])}
String filepath = getClass().getResource("/queries/submatch/negative-sequence-class.jsonld").getFile();
SpanQueryWrapper sqwi = getJSONQuery(filepath);
SpanQuery sq = sqwi.toQuery();
assertEquals("focus(254: spanContain(<tokens:base/s:t />, {254: spanExpansion(tokens:s:das, !tokens:l:Baum{1, 1}, right, class:1)}))", sq.toString());
}
Aggregations