use of de.ids_mannheim.korap.KrillIndex in project Krill by KorAP.
the class TestUnorderedElementDistanceIndex method testBothCandidateListEmptyBug.
/**
* Both candidate lists may be empty because the spans are not in an element span.
*
* @throws IOException
* @throws QueryException
*/
@Test
public void testBothCandidateListEmptyBug() throws IOException, QueryException {
ki = new KrillIndex();
ki.addDoc(createFieldDoc6());
ki.commit();
SpanQuery sq = createQuery("s", "s:a", "s:c", 1, 2, false);
kr = ki.search(sq, (short) 10);
assertEquals(0, kr.getMatches().size());
}
use of de.ids_mannheim.korap.KrillIndex in project Krill by KorAP.
the class TestUnorderedElementDistanceIndex method testCase4.
/**
* Multiple documents
* Skip to
*/
@Test
public void testCase4() throws IOException {
// System.out.println("testCase4");
ki = new KrillIndex();
ki.addDoc(createFieldDoc1());
ki.addDoc(createFieldDoc0());
ki.addDoc(createFieldDoc3());
ki.addDoc(createFieldDoc4());
ki.commit();
SpanQuery sq, edq;
edq = createQuery("s", "s:b", "s:c", 1, 1, false);
sq = new SpanNextQuery(edq, new SpanTermQuery(new Term("base", "s:e")));
kr = ki.search(sq, (short) 10);
assertEquals((long) 4, kr.getTotalResults());
assertEquals(0, kr.getMatch(0).startPos);
assertEquals(3, kr.getMatch(0).endPos);
assertEquals(1, kr.getMatch(1).startPos);
assertEquals(6, kr.getMatch(1).endPos);
assertEquals(3, kr.getMatch(2).startPos);
assertEquals(6, kr.getMatch(2).endPos);
assertEquals(3, kr.getMatch(3).getLocalDocID());
assertEquals(0, kr.getMatch(3).startPos);
assertEquals(4, kr.getMatch(3).endPos);
}
use of de.ids_mannheim.korap.KrillIndex in project Krill by KorAP.
the class TestWildcardIndex method testWildcardPlusWithCollection.
@Test
public void testWildcardPlusWithCollection() throws IOException {
ki = new KrillIndex();
ki.addDoc(createFieldDoc1());
ki.commit();
// mein+ /+w1:2,s0 &Erfahrung
SpanMultiTermQueryWrapper<WildcardQuery> mtq = new SpanMultiTermQueryWrapper<WildcardQuery>(new WildcardQuery(new Term("tokens", "s:mein+")));
// Just to make sure, Lucene internal queries treat SpanOr([]) correctly
SpanQuery soq = new SpanNearQuery(new SpanQuery[] { mtq, sq }, 1, true);
kr = ki.search(soq, (short) 10);
// As described in http://korap.github.io/Koral/, '+' is not a valid wildcard
assertEquals(0, kr.getMatches().size());
// Check the reported classed query
SpanMultipleDistanceQuery mdsq = new SpanMultipleDistanceQuery(new SpanClassQuery(mtq, (byte) 129), new SpanClassQuery(sq, (byte) 129), constraints, true, true);
kr = ki.search(mdsq, (short) 10);
assertEquals(0, kr.getMatches().size());
// Check multiple distance query
mdsq = new SpanMultipleDistanceQuery(mtq, sq, constraints, true, true);
kr = ki.search(mdsq, (short) 10);
assertEquals(0, kr.getMatches().size());
}
use of de.ids_mannheim.korap.KrillIndex in project Krill by KorAP.
the class TestWildcardIndex method testWildcardQuestionMark1.
@Test
public void testWildcardQuestionMark1() throws IOException {
ki = new KrillIndex();
ki.addDoc(createFieldDoc1());
ki.commit();
// Wildcard ? means regex . (expects exactly one character)
SpanMultiTermQueryWrapper<WildcardQuery> mtq = new SpanMultiTermQueryWrapper<WildcardQuery>(new WildcardQuery(new Term("tokens", "s:meine?")));
SpanMultipleDistanceQuery mdsq = new SpanMultipleDistanceQuery(new SpanClassQuery(mtq, (byte) 129), new SpanClassQuery(sq, (byte) 129), constraints, true, true);
kr = ki.search(mdsq, (short) 10);
assertEquals(3, kr.getMatches().size());
}
use of de.ids_mannheim.korap.KrillIndex in project Krill by KorAP.
the class TestWildcardIndex method testWildcardQuestionMark2.
@Test
public void testWildcardQuestionMark2() throws IOException {
ki = new KrillIndex();
ki.addDoc(createFieldDoc1());
ki.commit();
// Wildcard ? means regex . (expects exactly one character)
SpanMultiTermQueryWrapper<WildcardQuery> mtq = new SpanMultiTermQueryWrapper<WildcardQuery>(new WildcardQuery(new Term("tokens", "s:mein?")));
SpanMultipleDistanceQuery mdsq = new SpanMultipleDistanceQuery(new SpanClassQuery(mtq, (byte) 129), new SpanClassQuery(sq, (byte) 129), constraints, true, true);
kr = ki.search(mdsq, (short) 10);
assertEquals(1, kr.getMatches().size());
}
Aggregations