use of de.ids_mannheim.korap.query.SpanSegmentQuery in project Krill by KorAP.
the class TestDistanceIndex method testCase6.
/**
* Skip to
*/
@Test
public void testCase6() throws IOException {
ki = new KrillIndex();
ki.addDoc(createFieldDoc2());
ki.addDoc(createFieldDoc1());
ki.commit();
SpanQuery firstClause = createQuery("s:d", "s:e", 3, 4, true);
kr = ki.search(firstClause, (short) 10);
assertEquals(kr.getTotalResults(), 3);
assertEquals(0, kr.getMatch(0).getLocalDocID());
assertEquals(2, kr.getMatch(0).startPos);
assertEquals(6, kr.getMatch(0).endPos);
assertEquals(1, kr.getMatch(1).getLocalDocID());
assertEquals(4, kr.getMatch(1).startPos);
assertEquals(8, kr.getMatch(1).endPos);
assertEquals(4, kr.getMatch(2).startPos);
assertEquals(9, kr.getMatch(2).endPos);
// The secondspans is skipped to doc# of the current firstspans
SpanQuery sq = new SpanSegmentQuery(createQuery("s:d", "s:e", 3, 4, true), createElementQuery("y", "x", 1, 2, true));
kr = ki.search(sq, (short) 10);
assertEquals(kr.getTotalResults(), 1);
assertEquals(4, kr.getMatch(0).startPos);
assertEquals(9, kr.getMatch(0).endPos);
}
use of de.ids_mannheim.korap.query.SpanSegmentQuery in project Krill by KorAP.
the class TestSegmentIndex method testCase2.
/**
* Matches in multiple documents.
* Ensure the same document. The current secondspan is skipped to
* the doc number of the firstspan.
*/
@Test
public void testCase2() throws IOException {
// log.trace("Testcase2");
sq = new SpanSegmentQuery(new SpanTermQuery(new Term("base", "s:a")), new SpanTermQuery(new Term("base", "s:b")));
kr = ki.search(sq, (short) 10);
ki.close();
assertEquals("totalResults", kr.getTotalResults(), 3);
// Match #0
assertEquals("doc-number", 1, kr.getMatch(0).getLocalDocID());
assertEquals("StartPos", 1, kr.getMatch(0).startPos);
assertEquals("EndPos", 2, kr.getMatch(0).endPos);
// Match #2
assertEquals("doc-number", 2, kr.getMatch(2).getLocalDocID());
assertEquals("StartPos", 2, kr.getMatch(2).startPos);
assertEquals("EndPos", 3, kr.getMatch(2).endPos);
}
use of de.ids_mannheim.korap.query.SpanSegmentQuery in project Krill by KorAP.
the class TestSegmentIndex method testCase4.
/**
* Matching a SpanElementQuery and a SpanNextQuery
* Multiple atomic indices
*/
@Test
public void testCase4() throws IOException {
// log.trace("Testcase4");
ki = new KrillIndex();
ki.addDoc(createFieldDoc0());
ki.commit();
ki.addDoc(createFieldDoc1());
ki.addDoc(createFieldDoc2());
ki.commit();
sq = new SpanSegmentQuery(new SpanElementQuery("base", "e"), new SpanNextQuery(new SpanTermQuery(new Term("base", "s:a")), new SpanTermQuery(new Term("base", "s:b"))));
kr = ki.search(sq, (short) 10);
ki.close();
assertEquals("totalResults", kr.getTotalResults(), 2);
// Match #0
assertEquals("doc-number", 0, kr.getMatch(0).getLocalDocID());
assertEquals("StartPos", 3, kr.getMatch(0).startPos);
assertEquals("EndPos", 5, kr.getMatch(0).endPos);
// Match #1
assertEquals("doc-number", 0, kr.getMatch(1).getLocalDocID());
assertEquals("StartPos", 1, kr.getMatch(1).startPos);
assertEquals("EndPos", 3, kr.getMatch(1).endPos);
}
use of de.ids_mannheim.korap.query.SpanSegmentQuery in project Krill by KorAP.
the class TestSegmentIndex method testCase5.
/**
* Matching SpanElementQueries
*/
@Test
public void testCase5() throws IOException {
// log.trace("Testcase5");
sq = new SpanSegmentQuery(new SpanElementQuery("base", "e"), new SpanElementQuery("base", "e2"));
kr = ki.search(sq, (short) 10);
ki.close();
assertEquals("totalResults", kr.getTotalResults(), 1);
// Match #0
assertEquals("doc-number", 0, kr.getMatch(0).getLocalDocID());
assertEquals("StartPos", 3, kr.getMatch(0).startPos);
assertEquals("EndPos", 5, kr.getMatch(0).endPos);
}
use of de.ids_mannheim.korap.query.SpanSegmentQuery in project Krill by KorAP.
the class TestSegmentIndex method testCase1.
/**
* Multiple matches in one document.
*/
@Test
public void testCase1() throws IOException {
sq = new SpanSegmentQuery(new SpanTermQuery(new Term("base", "s:b")), new SpanTermQuery(new Term("base", "s:c")));
kr = ki.search(sq, (short) 10);
ki.close();
assertEquals("totalResults", kr.getTotalResults(), 3);
assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);
assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
}
Aggregations