Search in sources :

Example 11 with SpanMultipleDistanceQuery

use of de.ids_mannheim.korap.query.SpanMultipleDistanceQuery in project Krill by KorAP.

the class TestRegexIndex method testWildcardPlusRewritten.

@Test
public void testWildcardPlusRewritten() throws IOException {
    ki = new KrillIndex();
    ki.addDoc(createFieldDoc1());
    ki.commit();
    // C2 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(4, kr.getMatches().size());
}
Also used : SpanMultiTermQueryWrapper(org.apache.lucene.search.spans.SpanMultiTermQueryWrapper) SpanClassQuery(de.ids_mannheim.korap.query.SpanClassQuery) Term(org.apache.lucene.index.Term) KrillIndex(de.ids_mannheim.korap.KrillIndex) SpanMultipleDistanceQuery(de.ids_mannheim.korap.query.SpanMultipleDistanceQuery) RegexpQuery(org.apache.lucene.search.RegexpQuery) Test(org.junit.Test)

Example 12 with SpanMultipleDistanceQuery

use of de.ids_mannheim.korap.query.SpanMultipleDistanceQuery in project Krill by KorAP.

the class TestRegexIndex method testWildcardStarRewritten.

@Test
public void testWildcardStarRewritten() throws IOException {
    ki = new KrillIndex();
    ki.addDoc(createFieldDoc1());
    ki.commit();
    // meine* /+w1:2,s0 &Erfahrung
    // rewritten into meine.*
    RegexpQuery wcquery = new RegexpQuery(new Term("tokens", "s:meine.*"));
    SpanMultiTermQueryWrapper<RegexpQuery> mtq = new SpanMultiTermQueryWrapper<RegexpQuery>(wcquery);
    SpanMultipleDistanceQuery mdsq = new SpanMultipleDistanceQuery(new SpanClassQuery(mtq, (byte) 129), new SpanClassQuery(sq, (byte) 129), constraints, true, true);
    kr = ki.search(mdsq, (short) 10);
    assertEquals(4, kr.getMatches().size());
}
Also used : SpanMultiTermQueryWrapper(org.apache.lucene.search.spans.SpanMultiTermQueryWrapper) SpanClassQuery(de.ids_mannheim.korap.query.SpanClassQuery) Term(org.apache.lucene.index.Term) KrillIndex(de.ids_mannheim.korap.KrillIndex) SpanMultipleDistanceQuery(de.ids_mannheim.korap.query.SpanMultipleDistanceQuery) RegexpQuery(org.apache.lucene.search.RegexpQuery) Test(org.junit.Test)

Example 13 with SpanMultipleDistanceQuery

use of de.ids_mannheim.korap.query.SpanMultipleDistanceQuery in project Krill by KorAP.

the class TestSampleIndex method testWildcardStarWithCollection.

@Test
public void testWildcardStarWithCollection() throws IOException {
    // meine*
    WildcardQuery wcquery = new WildcardQuery(new Term("tokens", "s:meine*"));
    SpanMultiTermQueryWrapper<WildcardQuery> mtq = new SpanMultiTermQueryWrapper<WildcardQuery>(wcquery);
    // meine* /+w1:2,s0 &Erfahrung
    SpanQuery mdsq = new SpanMultipleDistanceQuery(new SpanClassQuery(mtq, (byte) 129), new SpanClassQuery(sq, (byte) 129), constraints, true, true);
    krillAvailabilityAll.setSpanQuery(mdsq);
    kr = sample.search(krillAvailabilityAll);
    assertEquals(4, kr.getMatches().size());
    assertEquals("match-GOE/AGI/04846-p107-109", kr.getMatch(0).getID());
    assertEquals("QAO-NC-LOC:ids", kr.getMatch(0).getAvailability());
    assertEquals("... gelesen und erzählt hat, ich in " + "[[meine Erfahrungen]] hätte mit aufnehmen sollen. " + "heute jedoch ...", kr.getMatch(0).getSnippetBrackets());
    assertEquals("match-GOE/AGD/00000-p132566-132569", kr.getMatch(1).getID());
    assertEquals("QAO-NC-LOC:ids-NU:1", kr.getMatch(1).getAvailability());
    assertEquals("... Mannes umständlich beibringen und solches " + "durch [[meine eigne Erfahrung]] bekräftigen: das " + "alles sollte nicht gelten ...", kr.getMatch(1).getSnippetBrackets());
    assertEquals("match-GOE/AGD/00000-p161393-161396", kr.getMatch(2).getID());
    assertEquals("QAO-NC-LOC:ids-NU:1", kr.getMatch(2).getAvailability());
    assertEquals("... lassen, bis er sich zuletzt an " + "[[meine sämtlichen Erfahrungen]] und Überzeugungen " + "anschloß, in welchem Sinne ...", kr.getMatch(2).getSnippetBrackets());
    assertEquals("match-GOE/AGD/06345-p10298-10301", kr.getMatch(3).getID());
    assertEquals("QAO-NC", kr.getMatch(3).getAvailability());
    assertEquals("... bis aufs Äußerste verfolgte, und, über " + "[[meine enge Erfahrung]] hinaus, nach ähnlichen Fällen " + "in der ...", kr.getMatch(3).getSnippetBrackets());
}
Also used : WildcardQuery(org.apache.lucene.search.WildcardQuery) SpanMultiTermQueryWrapper(org.apache.lucene.search.spans.SpanMultiTermQueryWrapper) SpanClassQuery(de.ids_mannheim.korap.query.SpanClassQuery) Term(org.apache.lucene.index.Term) SpanMultipleDistanceQuery(de.ids_mannheim.korap.query.SpanMultipleDistanceQuery) SpanQuery(org.apache.lucene.search.spans.SpanQuery) Test(org.junit.Test)

Example 14 with SpanMultipleDistanceQuery

use of de.ids_mannheim.korap.query.SpanMultipleDistanceQuery in project Krill by KorAP.

the class TestWildcardIndex method testWildcardStarWithCollection.

@Test
public void testWildcardStarWithCollection() throws IOException {
    ki = new KrillIndex();
    ki.addDoc(createFieldDoc1());
    ki.commit();
    // meine*
    WildcardQuery wcquery = new WildcardQuery(new Term("tokens", "s:meine*"));
    SpanMultiTermQueryWrapper<WildcardQuery> mtq = new SpanMultiTermQueryWrapper<WildcardQuery>(wcquery);
    // meine* /+w1:2,s0 &Erfahrung
    SpanQuery mdsq = new SpanMultipleDistanceQuery(new SpanClassQuery(mtq, (byte) 129), new SpanClassQuery(sq, (byte) 129), constraints, true, true);
    kr = ki.search(mdsq, (short) 10);
    assertEquals(4, kr.getMatches().size());
}
Also used : WildcardQuery(org.apache.lucene.search.WildcardQuery) SpanMultiTermQueryWrapper(org.apache.lucene.search.spans.SpanMultiTermQueryWrapper) SpanClassQuery(de.ids_mannheim.korap.query.SpanClassQuery) Term(org.apache.lucene.index.Term) KrillIndex(de.ids_mannheim.korap.KrillIndex) SpanMultipleDistanceQuery(de.ids_mannheim.korap.query.SpanMultipleDistanceQuery) SpanQuery(org.apache.lucene.search.spans.SpanQuery) Test(org.junit.Test)

Aggregations

SpanMultipleDistanceQuery (de.ids_mannheim.korap.query.SpanMultipleDistanceQuery)14 Term (org.apache.lucene.index.Term)12 Test (org.junit.Test)12 SpanMultiTermQueryWrapper (org.apache.lucene.search.spans.SpanMultiTermQueryWrapper)11 KrillIndex (de.ids_mannheim.korap.KrillIndex)10 SpanClassQuery (de.ids_mannheim.korap.query.SpanClassQuery)10 SpanQuery (org.apache.lucene.search.spans.SpanQuery)8 WildcardQuery (org.apache.lucene.search.WildcardQuery)7 RegexpQuery (org.apache.lucene.search.RegexpQuery)4 DistanceConstraint (de.ids_mannheim.korap.query.DistanceConstraint)3 SpanDistanceQuery (de.ids_mannheim.korap.query.SpanDistanceQuery)2 ArrayList (java.util.ArrayList)2 SpanTermQuery (org.apache.lucene.search.spans.SpanTermQuery)2 Krill (de.ids_mannheim.korap.Krill)1 QueryBuilder (de.ids_mannheim.korap.query.QueryBuilder)1 SpanNextQuery (de.ids_mannheim.korap.query.SpanNextQuery)1 SpanQueryWrapper (de.ids_mannheim.korap.query.wrap.SpanQueryWrapper)1 Result (de.ids_mannheim.korap.response.Result)1 QueryException (de.ids_mannheim.korap.util.QueryException)1 SpanNearQuery (org.apache.lucene.search.spans.SpanNearQuery)1