Search in sources :

Example 16 with SpanAttributeQuery

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

the class TestRelationIndex method testCase4.

/**
 * Relations only with/out attribute
 */
@Test
public void testCase4() throws IOException {
    ki.addDoc(createFieldDoc2());
    ki.commit();
    SpanRelationQuery srq = new SpanRelationQuery(new SpanTermQuery(new Term("base", ">:child-of")), true, RelationDirection.RIGHT);
    SpanFocusQuery fq = new SpanFocusQuery(srq, srq.getTempClassNumbers());
    fq.setMatchTemporaryClass(true);
    fq.setRemoveTemporaryClasses(true);
    fq.setSorted(false);
    // kr = ki.search(fq, (short) 20);
    // for (Match m : kr.getMatches()) {
    // System.out.println(m.getStartPos() + " " + m.getEndPos());
    // }
    SpanAttributeQuery saq = new SpanAttributeQuery(new SpanTermQuery(new Term("base", "@:func=sbj")), true);
    // kr = ki.search(saq, (short) 20);
    // child-of with attr func=sbj
    SpanWithAttributeQuery wq;
    wq = new SpanWithAttributeQuery(fq, saq, true);
    // kr = ki.search(wq, (short) 20);
    // assertEquals((long) 1, kr.getTotalResults());
    // assertEquals(0, kr.getMatch(0).getStartPos()); // token
    // assertEquals(7, kr.getMatch(0).getEndPos());
    // child-of without attr func=sbj
    wq = new SpanWithAttributeQuery(fq, new SpanAttributeQuery(new SpanTermQuery(new Term("base", "@:func=sbj")), true, true), true);
    kr = ki.search(wq, (short) 20);
    assertEquals((long) 12, kr.getTotalResults());
}
Also used : SpanTermQuery(org.apache.lucene.search.spans.SpanTermQuery) SpanAttributeQuery(de.ids_mannheim.korap.query.SpanAttributeQuery) SpanRelationQuery(de.ids_mannheim.korap.query.SpanRelationQuery) SpanWithAttributeQuery(de.ids_mannheim.korap.query.SpanWithAttributeQuery) Term(org.apache.lucene.index.Term) SpanFocusQuery(de.ids_mannheim.korap.query.SpanFocusQuery) Test(org.junit.Test)

Aggregations

SpanAttributeQuery (de.ids_mannheim.korap.query.SpanAttributeQuery)16 SpanWithAttributeQuery (de.ids_mannheim.korap.query.SpanWithAttributeQuery)15 Term (org.apache.lucene.index.Term)14 SpanTermQuery (org.apache.lucene.search.spans.SpanTermQuery)14 Test (org.junit.Test)14 SpanQuery (org.apache.lucene.search.spans.SpanQuery)9 ArrayList (java.util.ArrayList)7 SpanElementQuery (de.ids_mannheim.korap.query.SpanElementQuery)6 SpanRelationQuery (de.ids_mannheim.korap.query.SpanRelationQuery)5 SpanFocusQuery (de.ids_mannheim.korap.query.SpanFocusQuery)4 SpanNextQuery (de.ids_mannheim.korap.query.SpanNextQuery)1 SpanRelationMatchQuery (de.ids_mannheim.korap.query.SpanRelationMatchQuery)1 SpanSegmentQuery (de.ids_mannheim.korap.query.SpanSegmentQuery)1