use of de.ids_mannheim.korap.query.SpanClassQuery 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.query.SpanClassQuery 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.query.SpanClassQuery 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());
}
use of de.ids_mannheim.korap.query.SpanClassQuery in project Krill by KorAP.
the class TestRegexIndex method testWildcardQuestionMarkRewritten.
@Test
public void testWildcardQuestionMarkRewritten() throws IOException {
ki = new KrillIndex();
ki.addDoc(createFieldDoc1());
ki.commit();
// meine? /+w1:2,s0 &Erfahrung
// meine? rewritten into meine.
SpanMultiTermQueryWrapper<RegexpQuery> mtq = new SpanMultiTermQueryWrapper<RegexpQuery>(new RegexpQuery(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.query.SpanClassQuery in project Krill by KorAP.
the class TestRegexIndex method testWildcardPlusRewritten2.
@Test
public void testWildcardPlusRewritten2() throws IOException {
ki = new KrillIndex();
ki.addDoc(createFieldDoc1());
ki.commit();
// C2 mein+ /+w1:2,s0 &Erfahrung
// mein+ rewritten into mein.?
SpanMultiTermQueryWrapper<RegexpQuery> mtq = new SpanMultiTermQueryWrapper<RegexpQuery>(new RegexpQuery(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(2, kr.getMatches().size());
}
Aggregations