use of de.ids_mannheim.korap.query.SpanNextQuery in project Krill by KorAP.
the class TestUnorderedDistanceIndex method testCase4.
/**
* Skip to
*/
@Test
public void testCase4() throws IOException {
// System.out.println("testcase 4");
ki = new KrillIndex();
ki.addDoc(createFieldDoc0());
ki.addDoc(createFieldDoc1());
ki.addDoc(createFieldDoc2());
ki.commit();
SpanQuery sq = new SpanNextQuery(createQuery("s:d", "s:e", 1, 2, false), new SpanTermQuery(new Term("base", "s:f")));
kr = ki.search(sq, (short) 10);
assertEquals(kr.getTotalResults(), 2);
assertEquals(2, kr.getMatch(0).getLocalDocID());
assertEquals(2, kr.getMatch(0).getStartPos());
assertEquals(6, kr.getMatch(0).getEndPos());
assertEquals(3, kr.getMatch(1).getStartPos());
assertEquals(6, kr.getMatch(1).getEndPos());
}
use of de.ids_mannheim.korap.query.SpanNextQuery in project Krill by KorAP.
the class TestWPDIndex method testCase6.
/**
* Next and repetition
*/
@Test
public void testCase6() throws IOException {
SpanQuery sq = new SpanNextQuery(new SpanTermQuery(new Term("tokens", "tt/p:NN")), new SpanRepetitionQuery(new SpanTermQuery(new Term("tokens", "mate/p:ADJA")), 2, 2, true));
ks = new Krill(sq);
kr = ks.apply(ki);
assertEquals(kr.getTotalResults(), 30223);
// 1.1s
SpanQuery sq2 = new SpanNextQuery(sq, new SpanTermQuery(new Term("tokens", "tt/p:NN")));
ks = new Krill(sq2);
kr = ks.apply(ki);
assertEquals(kr.getTotalResults(), 26607);
// 1.1s
}
use of de.ids_mannheim.korap.query.SpanNextQuery in project Krill by KorAP.
the class TestWithinIndex method indexExample6.
@Test
public void indexExample6() throws IOException {
KrillIndex ki = new KrillIndex();
// 2,5,8,12,13
// h<a><a>i</a>j</a><a>h</a>i j<a>h i</a>j
FieldDocument fd = new FieldDocument();
fd.addTV("base", "hijhi jh ij", "[(0-1)s:h|i:h|_0$<i>0<i>1|-:a$<i>4|-:t$<i>9]" + "[(1-2)s:i|i:i|_1$<i>1<i>2|<>:a$<b>64<i>1<i>2<i>2<b>0|" + "<>:a$<b>64<i>1<i>3<i>3<b>0]" + "[(2-3)s:j|i:j|_2$<i>2<i>3]" + "[(3-4)s:h|i:h|_3$<i>3<i>4|<>:a$<b>64<i>3<i>4<i>4<b>0]" + "[(4-5)s:i|i:i|_4$<i>4<i>5]" + "[(6-7)s:j|i:j|_5$<i>6<i>7]" + "[(7-8)s:h|i:h|_6$<i>7<i>8|<>:a$<b>64<i>7<i>10<i>8<b>0]" + "[(9-10)s:i|i:i|_7$<i>9<i>10]" + "[(10-11)s:j|i:j|_8$<i>10<i>11]");
ki.addDoc(fd);
// Save documents
ki.commit();
assertEquals(1, ki.numberOf("documents"));
SpanQuery sq = new SpanWithinQuery(new SpanElementQuery("base", "a"), new SpanNextQuery(new SpanTermQuery(new Term("base", "s:h")), new SpanNextQuery(new SpanTermQuery(new Term("base", "s:i")), new SpanTermQuery(new Term("base", "s:j")))));
Result kr = ki.search(sq, (short) 10);
assertEquals("totalResults", kr.getTotalResults(), 0);
}
use of de.ids_mannheim.korap.query.SpanNextQuery in project Krill by KorAP.
the class TestWithinIndex method indexExample7.
@Test
public void indexExample7() throws IOException {
KrillIndex ki = new KrillIndex();
// 4,5,11,13
// x<a>x h</a>i j h<a>i j</a>
FieldDocument fd = new FieldDocument();
fd.addTV("base", "xx hi j hi j", "[(0-1)s:x|i:x|_0$<i>0<i>1|-:a$<i>2|-:t$<i>8]" + "[(1-2)s:x|i:x|_1$<i>1<i>2|<>:a$<b>64<i>1<i>4<i>3<b>0]" + "[(3-4)s:h|i:h|_2$<i>3<i>4]" + "[(4-5)s:i|i:i|_3$<i>4<i>5]" + "[(6-7)s:j|i:j|_4$<i>6<i>7]" + "[(8-9)s:h|i:h|_5$<i>8<i>9]" + "[(9-10)s:i|i:i|_6$<i>9<i>10|<>:a$<b>64<i>9<i>12<i>8<b>0]" + "[(11-12)s:j|i:j|_7$<i>11<i>12]");
ki.addDoc(fd);
// Save documents
ki.commit();
assertEquals(1, ki.numberOf("documents"));
SpanQuery sq = new SpanWithinQuery(new SpanElementQuery("base", "a"), new SpanNextQuery(new SpanTermQuery(new Term("base", "s:h")), new SpanNextQuery(new SpanTermQuery(new Term("base", "s:i")), new SpanTermQuery(new Term("base", "s:j")))));
Result kr = ki.search(sq, (short) 10);
assertEquals("totalResults", kr.getTotalResults(), 0);
}
use of de.ids_mannheim.korap.query.SpanNextQuery in project Krill by KorAP.
the class TestRepetitionIndex method testCase3.
/**
* OR
*/
@Test
public void testCase3() throws IOException {
ki = new KrillIndex();
ki.addDoc(createFieldDoc0());
ki.commit();
SpanQuery sq, sq2;
// ec{1,2}
sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:e")), new SpanOrQuery(new SpanRepetitionQuery(new SpanTermQuery(new Term("base", "s:c")), 1, 1, true), new SpanRepetitionQuery(new SpanTermQuery(new Term("base", "s:b")), 1, 1, true)));
kr = ki.search(sq, (short) 10);
assertEquals((long) 3, kr.getTotalResults());
assertEquals(1, kr.getMatch(0).startPos);
assertEquals(3, kr.getMatch(0).endPos);
assertEquals(4, kr.getMatch(1).startPos);
assertEquals(6, kr.getMatch(1).endPos);
assertEquals(7, kr.getMatch(2).startPos);
assertEquals(9, kr.getMatch(2).endPos);
}
Aggregations