use of de.ids_mannheim.korap.query.SpanElementQuery in project Krill by KorAP.
the class TestWithinIndex method indexExample4.
@Test
public void indexExample4() throws IOException {
KrillIndex ki = new KrillIndex();
// Case 1, 6, 7, 13
// xy<a><a>x</a>b<a>c</a></a>x
FieldDocument fd = new FieldDocument();
fd.addTV("base", "x y x b c x ", "[(0-3)s:x|_0$<i>0<i>3]" + "[(3-6)s:y|_1$<i>3<i>6]" + "[(6-9)s:x|_2$<i>6<i>9|<>:a$<b>64<i>6<i>9<i>3<b>0|" + "<>:a$<b>64<i>6<i>15<i>5<b>0]" + "[(9-12)s:b|_3$<i>9<i>12]" + "[(12-15)s:c|_4$<i>12<i>15|<>:a$<b>64<i>12<i>15<i>5<b>0]" + "[(15-18)s:x|_5$<i>15<i>18]");
ki.addDoc(fd);
// Save documents
ki.commit();
assertEquals(1, ki.numberOf("documents"));
SpanQuery sq = new SpanWithinQuery(new SpanElementQuery("base", "a"), new SpanTermQuery(new Term("base", "s:x")));
assertEquals("spanContain(<base:a />, base:s:x)", sq.toString());
Result kr = ki.search(sq, (short) 10);
assertEquals("totalResults", kr.getTotalResults(), 2);
assertEquals("x y [[x ]]b c x ", kr.getMatch(0).getSnippetBrackets());
assertEquals("x y [[x b c ]]x ", kr.getMatch(1).getSnippetBrackets());
assertEquals("StartPos (0)", 2, kr.getMatch(0).startPos);
assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
assertEquals("StartPos (1)", 2, kr.getMatch(1).startPos);
assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
}
use of de.ids_mannheim.korap.query.SpanElementQuery in project Krill by KorAP.
the class TestWithinIndex method indexExample1c.
@Test
public void indexExample1c() throws IOException {
// Cases 9, 12, 13
KrillIndex ki = new KrillIndex();
// <a>x<a>y<a>zhij</a>hij</a>hij</a>
FieldDocument fd = new FieldDocument();
fd.addTV("base", "x y z h i j h i j h i j ", // 1
"[(0-3)s:x|<>:a$<b>64<i>0<i>36<i>12<b>0]" + // 2
"[(3-6)s:y|<>:a$<b>64<i>3<i>27<i>9<b>0]" + // 3
"[(6-9)s:z|<>:a$<b>64<i>6<i>18<i>6<b>0]" + // 4
"[(9-12)s:h]" + // 5
"[(12-15)s:i]" + // 6
"[(15-18)s:j]" + // 7
"[(18-21)s:h]" + // 8
"[(21-24)s:i]" + // 9
"[(24-27)s:j]" + // 10
"[(27-30)s:h]" + // 11
"[(30-33)s:i]" + // 12
"[(33-36)s:j]");
ki.addDoc(fd);
// <a>x<a>y<a>zabc</a>abc</a>abc</a>
fd = new FieldDocument();
fd.addTV("base", "x y z a b c a b c a b c ", // 1
"[(0-3)s:x|<>:a$<b>64<i>0<i>36<i>12<b>0]" + // 2
"[(3-6)s:y|<>:a$<b>64<i>3<i>27<i>9<b>0]" + // 3
"[(6-9)s:z|<>:a$<b>64<i>6<i>18<i>6<b>0]" + // 4
"[(9-12)s:a]" + // 5
"[(12-15)s:b]" + // 6
"[(15-18)s:c]" + // 7
"[(18-21)s:a]" + // 8
"[(21-24)s:b]" + // 9
"[(24-27)s:c]" + // 10
"[(27-30)s:a]" + // 11
"[(30-33)s:b]" + // 12
"[(33-36)s:c]");
ki.addDoc(fd);
// Save documents
ki.commit();
SpanQuery sq;
Result kr;
sq = new SpanWithinQuery(new SpanElementQuery("base", "a"), new SpanTermQuery(new Term("base", "s:h")));
kr = ki.search(sq, (short) 15);
assertEquals("totalResults", kr.getTotalResults(), 6);
assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
assertEquals("EndPos (0)", 12, kr.getMatch(0).endPos);
assertEquals("Doc (0)", 0, kr.getMatch(0).internalDocID);
assertEquals("StartPos (1)", 0, kr.getMatch(1).startPos);
assertEquals("EndPos (1)", 12, kr.getMatch(1).endPos);
assertEquals("Doc (1)", 0, kr.getMatch(1).internalDocID);
assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
assertEquals("EndPos (2)", 12, kr.getMatch(2).endPos);
assertEquals("Doc (2)", 0, kr.getMatch(2).internalDocID);
assertEquals("StartPos (3)", 1, kr.getMatch(3).startPos);
assertEquals("EndPos (3)", 9, kr.getMatch(3).endPos);
assertEquals("Doc (3)", 0, kr.getMatch(3).internalDocID);
assertEquals("StartPos (4)", 1, kr.getMatch(4).startPos);
assertEquals("EndPos (4)", 9, kr.getMatch(4).endPos);
assertEquals("Doc (4)", 0, kr.getMatch(4).internalDocID);
assertEquals("StartPos (5)", 2, kr.getMatch(5).startPos);
assertEquals("EndPos (5)", 6, kr.getMatch(5).endPos);
assertEquals("Doc (5)", 0, kr.getMatch(5).internalDocID);
assertEquals(2, ki.numberOf("documents"));
}
use of de.ids_mannheim.korap.query.SpanElementQuery 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.SpanElementQuery in project Krill by KorAP.
the class TestWithinIndex method indexExample1d.
@Test
public void indexExample1d() throws IOException {
// Cases 9, 12, 13
KrillIndex ki = new KrillIndex();
// <a>x<a>y<a>zhij</a>hij</a>hij</a>
FieldDocument fd = new FieldDocument();
fd.addTV("base", "x y z h i j h i j h i j ", // 1
"[(0-3)s:x|<>:a$<b>64<i>0<i>36<i>12<b>0]" + // 2
"[(3-6)s:y|<>:a$<b>64<i>3<i>27<i>9<b>0]" + // 3
"[(6-9)s:z|<>:a$<b>64<i>6<i>18<i>6<b>0]" + // 4
"[(9-12)s:h]" + // 5
"[(12-15)s:i]" + // 6
"[(15-18)s:j]" + // 7
"[(18-21)s:h]" + // 8
"[(21-24)s:i]" + // 9
"[(24-27)s:j]" + // 10
"[(27-30)s:h]" + // 11
"[(30-33)s:i]" + // 12
"[(33-36)s:j]");
ki.addDoc(fd);
fd = new FieldDocument();
fd.addTV("base", "x y z h ", // 1
"[(0-3)s:x]" + // 2
"[(3-6)s:y]" + // 3
"[(6-9)s:z]" + // 4
"[(9-12)s:h]");
ki.addDoc(fd);
// <a>x<a>y<a>zabc</a>abc</a>abc</a>
fd = new FieldDocument();
fd.addTV("base", "x y z a b c a b c a b c ", // 1
"[(0-3)s:x|<>:a$<b>64<i>0<i>36<i>12<b>0]" + // 2
"[(3-6)s:y|<>:a$<b>64<i>3<i>27<i>9<b>0]" + // 3
"[(6-9)s:z|<>:a$<b>64<i>6<i>18<i>6<b>0]" + // 4
"[(9-12)s:a]" + // 5
"[(12-15)s:b]" + // 6
"[(15-18)s:c]" + // 7
"[(18-21)s:a]" + // 8
"[(21-24)s:b]" + // 9
"[(24-27)s:c]" + // 10
"[(27-30)s:a]" + // 11
"[(30-33)s:b]" + // 12
"[(33-36)s:c]");
ki.addDoc(fd);
// Save documents
ki.commit();
SpanQuery sq;
Result kr;
sq = new SpanElementQuery("base", "a");
kr = ki.search(sq, (short) 15);
sq = new SpanWithinQuery(new SpanElementQuery("base", "a"), new SpanTermQuery(new Term("base", "s:h")));
kr = ki.search(sq, (short) 15);
assertEquals("totalResults", kr.getTotalResults(), 6);
assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
assertEquals("EndPos (0)", 12, kr.getMatch(0).endPos);
assertEquals("Doc (0)", 0, kr.getMatch(0).internalDocID);
assertEquals("StartPos (1)", 0, kr.getMatch(1).startPos);
assertEquals("EndPos (1)", 12, kr.getMatch(1).endPos);
assertEquals("Doc (1)", 0, kr.getMatch(1).internalDocID);
assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
assertEquals("EndPos (2)", 12, kr.getMatch(2).endPos);
assertEquals("Doc (2)", 0, kr.getMatch(2).internalDocID);
assertEquals("StartPos (3)", 1, kr.getMatch(3).startPos);
assertEquals("EndPos (3)", 9, kr.getMatch(3).endPos);
assertEquals("Doc (3)", 0, kr.getMatch(3).internalDocID);
assertEquals("StartPos (4)", 1, kr.getMatch(4).startPos);
assertEquals("EndPos (4)", 9, kr.getMatch(4).endPos);
assertEquals("Doc (4)", 0, kr.getMatch(4).internalDocID);
assertEquals("StartPos (5)", 2, kr.getMatch(5).startPos);
assertEquals("EndPos (5)", 6, kr.getMatch(5).endPos);
assertEquals("Doc (5)", 0, kr.getMatch(5).internalDocID);
assertEquals(3, ki.numberOf("documents"));
}
use of de.ids_mannheim.korap.query.SpanElementQuery 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);
}
Aggregations