use of de.ids_mannheim.korap.query.SpanNextQuery in project Krill by KorAP.
the class TestFocusIndex method testCase12.
/**
* Check Skipto focus spans
*/
@Test
public void testCase12() throws IOException {
ki.addDoc(TestRelationIndex.createFieldDoc0());
ki.addDoc(TestRelationIndex.createFieldDoc1());
ki.commit();
SpanRelationQuery sq = new SpanRelationQuery(new SpanTermQuery(new Term("base", ">:xip/syntax-dep_rel")), true, RelationDirection.RIGHT);
sq.setSourceClass((byte) 1);
SpanFocusQuery sfq = new SpanFocusQuery(sq, (byte) 1);
sfq.setSorted(false);
SpanTermQuery stq = new SpanTermQuery(new Term("base", "s:c"));
SpanNextQuery snq = new SpanNextQuery(stq, sfq);
kr = ki.search(snq, (short) 20);
assertEquals(0, kr.getMatch(0).getStartPos());
assertEquals(2, kr.getMatch(0).getEndPos());
assertEquals(5, kr.getMatch(1).getStartPos());
assertEquals(9, kr.getMatch(1).getEndPos());
// for (Match m : kr.getMatches()) {
// System.out.println(m.getStartPos() + " " + m.getEndPos());
// }
}
use of de.ids_mannheim.korap.query.SpanNextQuery in project Krill by KorAP.
the class TestClass method queryJSONpoly1.
@Test
public void queryJSONpoly1() throws QueryException, IOException {
String jsonPath = URLDecoder.decode(getClass().getResource("/queries/poly1.json").getFile(), "UTF-8");
String jsonQuery = readFile(jsonPath);
SpanQueryWrapper sqwi = new KrillQuery("tokens").fromKoral(jsonQuery);
SpanNextQuery sq = (SpanNextQuery) sqwi.toQuery();
// System.out.println(sq.toString());
ki = new KrillIndex();
ki.addDoc(getClass().getResourceAsStream("/wiki/JJJ-00785.json.gz"), true);
ki.addDoc(getClass().getResourceAsStream("/wiki/DDD-01402.json.gz"), true);
ki.commit();
kr = ki.search(sq, (short) 10);
assertEquals(61, kr.getMatch(0).getStartPos());
assertEquals(64, kr.getMatch(0).getEndPos());
assertEquals("... Bruckner (Wien) und Mathis Lussy (Paris). [[{1:Inspiriert} " + "{2:durch die}]] additiven Modelle arabischer Rhythmik (er half ...", kr.getMatch(0).getSnippetBrackets());
assertEquals(31, kr.getMatch(1).getStartPos());
assertEquals(34, kr.getMatch(1).getEndPos());
assertEquals("... des Sendens wird ein unhörbarer Unterton [[{1:mitgesendet}, " + "{2:auf den}]] das angesprochene Funkgerät reagiert. Die Abkürzung ...", kr.getMatch(1).getSnippetBrackets());
}
use of de.ids_mannheim.korap.query.SpanNextQuery in project Krill by KorAP.
the class TestNextIndex method indexExample3.
@Test
public void indexExample3() throws IOException {
KrillIndex ki = new KrillIndex();
// abcabcabac
FieldDocument fd = new FieldDocument();
fd.addTV("base", "abcabcabac", "[(0-1)s:a|i:a|_0$<i>0<i>1|-:t$<i>10]" + "[(1-2)s:b|i:b|_1$<i>1<i>2]" + "[(2-3)s:c|i:c|_2$<i>2<i>3]" + "[(3-4)s:a|i:a|_3$<i>3<i>4|<>:x$<b>64<i>3<i>7<i>7<b>0]" + "[(4-5)s:b|i:b|_4$<i>4<i>5]" + "[(5-6)s:c|i:c|_5$<i>5<i>6]" + "[(6-7)s:a|i:a|_6$<i>6<i>7]" + "[(7-8)s:b|i:b|_7$<i>7<i>8]" + "[(8-9)s:a|i:a|_8$<i>8<i>9]" + "[(9-10)s:c|i:c|_9$<i>9<i>10]");
ki.addDoc(fd);
ki.commit();
SpanQuery sq;
Result kr;
sq = new SpanNextQuery(new SpanElementQuery("base", "x"), new SpanTermQuery(new Term("base", "s:b")));
kr = ki.search(sq, (short) 10);
assertEquals("abc[[abcab]]ac", kr.getMatch(0).getSnippetBrackets());
}
use of de.ids_mannheim.korap.query.SpanNextQuery in project Krill by KorAP.
the class TestNextIndex method indexExample1.
// Todo: primary data as a non-indexed field separated.
@Test
public void indexExample1() throws IOException {
KrillIndex ki = new KrillIndex();
// abcabcabac
FieldDocument fd = new FieldDocument();
fd.addTV("base", "abcabcabac", "[(0-1)s:a|i:a|_0$<i>0<i>1|-:t$<i>10]" + "[(1-2)s:b|i:b|_1$<i>1<i>2]" + "[(2-3)s:c|i:c|_2$<i>2<i>3]" + "[(3-4)s:a|i:a|_3$<i>3<i>4]" + "[(4-5)s:b|i:b|_4$<i>4<i>5]" + "[(5-6)s:c|i:c|_5$<i>5<i>6]" + "[(6-7)s:a|i:a|_6$<i>6<i>7]" + "[(7-8)s:b|i:b|_7$<i>7<i>8]" + "[(8-9)s:a|i:a|_8$<i>8<i>9]" + "[(9-10)s:c|i:c|_9$<i>9<i>10]");
ki.addDoc(fd);
ki.commit();
SpanQuery sq;
Result kr;
sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:a")), new SpanTermQuery(new Term("base", "s:b")));
kr = ki.search(sq, (short) 10);
assertEquals("totalResults", kr.getTotalResults(), 3);
assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);
assertEquals("StartPos (1)", 3, kr.getMatch(1).startPos);
assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
assertEquals("StartPos (2)", 6, kr.getMatch(2).startPos);
assertEquals("EndPos (2)", 8, kr.getMatch(2).endPos);
sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:b")), new SpanTermQuery(new Term("base", "s:c")));
kr = ki.search(sq, (short) 10);
assertEquals("totalResults", kr.getTotalResults(), 2);
assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
assertEquals(1, ki.numberOf("base", "documents"));
assertEquals(10, ki.numberOf("base", "t"));
sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:a")), new SpanNextQuery(new SpanTermQuery(new Term("base", "s:b")), new SpanTermQuery(new Term("base", "s:c"))));
kr = ki.search(sq, (short) 2);
assertEquals("totalResults", kr.getTotalResults(), 2);
assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
assertEquals("StartPos (1)", 3, kr.getMatch(1).startPos);
assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
assertEquals(1, ki.numberOf("base", "documents"));
assertEquals(10, ki.numberOf("base", "t"));
}
use of de.ids_mannheim.korap.query.SpanNextQuery in project Krill by KorAP.
the class TestNextIndex method indexExample2.
@Test
public void indexExample2() throws IOException {
KrillIndex ki = new KrillIndex();
// abcabcabac
FieldDocument fd = new FieldDocument();
fd.addTV("base", "abcabcabac", "[(0-1)s:a|i:a|_0$<i>0<i>1|-:t$<i>10]" + "[(1-2)s:b|i:b|_1$<i>1<i>2]" + "[(2-3)s:c|i:c|_2$<i>2<i>3]" + "[(3-4)s:a|i:a|_3$<i>3<i>4|<>:x$<b>64<i>3<i>4<i>4<b>0|<>:x$<b>64<i>3<i>7<i>7<b>0]" + "[(4-5)s:b|i:b|_4$<i>4<i>5]" + "[(5-6)s:c|i:c|_5$<i>5<i>6]" + "[(6-7)s:a|i:a|_6$<i>6<i>7]" + "[(7-8)s:b|i:b|_7$<i>7<i>8]" + "[(8-9)s:a|i:a|_8$<i>8<i>9]" + "[(9-10)s:c|i:c|_9$<i>9<i>10]");
ki.addDoc(fd);
ki.commit();
SpanQuery sq;
Result kr;
sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:c")), new SpanElementQuery("base", "x"));
kr = ki.search(sq, (short) 10);
assertEquals("ab[[cabca]]bac", kr.getMatch(1).getSnippetBrackets());
}
Aggregations