use of de.ids_mannheim.korap.response.Match in project Krill by KorAP.
the class TestMatchIdentifier method indexExample7SentenceExpansion.
@Test
public void indexExample7SentenceExpansion() throws IOException, QueryException {
KrillIndex ki = new KrillIndex();
ki.addDoc(createSimpleFieldDoc());
ki.addDoc(createSimpleFieldDoc2());
ki.addDoc(createSimpleFieldDoc3());
ki.addDoc(createSimpleFieldDoc4());
ki.commit();
Match km;
km = ki.getMatchInfo("match-c1!d1-p3-4", "tokens", null, null, false, false);
assertEquals("... [[{f/m:vier:{f/y:four:{it/is:4:{x/o:viertens:a}}}}]] ...", km.getSnippetBrackets());
km = ki.getMatchInfo("match-c1!d1-p3-4", "tokens", null, null, false, false, // extendToSentence
true);
// This will
// [{f/m:drei:{f/y:three:{it/is:3:{x/o:drittens:c}}}}{f/m:vier:{f/y:four:{it/is:4:{x/o:viertens:a}}}}{f/m:fuenf:{f/y:five:{it/is:5:{x/o:fünftens:b}}}}]
assertEquals("[{f/m:drei:{f/y:three:{it/is:3:{x/o:drittens:c}}}}[{f/m:vier:{f/y:four:{it/is:4:{x/o:viertens:a}}}}]{f/m:fuenf:{f/y:five:{it/is:5:{x/o:fünftens:b}}}}]", km.getSnippetBrackets());
assertEquals("<span class=\"context-left\"></span>" + "<span class=\"match\">" + "<span title=\"f/m:drei\">" + "<span title=\"f/y:three\">" + "<span title=\"it/is:3\">" + "<span title=\"x/o:drittens\">c</span>" + "</span>" + "</span>" + "</span>" + "<mark>" + "<span title=\"f/m:vier\">" + "<span title=\"f/y:four\">" + "<span title=\"it/is:4\">" + "<span title=\"x/o:viertens\">a</span>" + "</span>" + "</span>" + "</span>" + "</mark>" + "<span title=\"f/m:fuenf\">" + "<span title=\"f/y:five\">" + "<span title=\"it/is:5\">" + "<span title=\"x/o:fünftens\">b</span>" + "</span>" + "</span>" + "</span>" + "</span>" + "<span class=\"context-right\"></span>", km.getSnippetHTML());
/*
km = ki.getMatchInfo("match-c1!d3-p3-4", "tokens", null, null, false,
false, true); // extendToSentence
assertEquals(
"[{f/m:drei:{f/y:three:{it/is:3:{x/o:drittens:cc}}}} {f/m:vier:{f/y:four:{it/is:4:{x/o:viertens:aa}}}} {f/m:fuenf:{f/y:five:{it/is:5:{x/o:fünftens:bb}}}}]",
km.getSnippetBrackets());
km = ki.getMatchInfo("match-c1!d4-p4-6", "tokens", null, null, false,
false, true); // extendToSentence
assertEquals(
"[{f/m:drei:{f/y:three:{it/is:3:{x/o:drittens:c}}}}{f/m:vier:{f/y:four:{it/is:4:{x/o:viertens:a}}}}{f/m:fuenf:{f/y:five:{it/is:5:{x/o:fünftens:b}}}}{f/m:sechs:{f/y:six:{it/is:6:{x/o:sechstens:c}}}}{f/m:sieben:{f/y:seven:{it/is:7:{x/o:siebtens:a}}}}]",
km.getSnippetBrackets());
*/
}
use of de.ids_mannheim.korap.response.Match in project Krill by KorAP.
the class TestMatchIdentifier method snippetBugTest.
// ND: Although this test is failing, I assume it is probably
// due to a data bug.
@Ignore
public void snippetBugTest() throws IOException, QueryException {
KrillIndex ki = new KrillIndex();
ki.addDoc(getClass().getResourceAsStream("/wiki/wpd15-u43-34816.json.gz"), true);
ki.commit();
Match km = ki.getMatchInfo("match-WPD15/U43/34816-p420-422", "tokens", "tt", "l", false, false);
assertEquals("SnippetBrackets (with Spans)", "<span class=\"context-left\">" + "<span class=\"more\"></span></span>" + "<span class=\"match\">" + "<mark>" + "<span title=\"tt/l:online\">online</span> " + "<span title=\"tt/l:verfügbar\">verfügbar</span>" + "</mark>" + "</span>" + "<span class=\"context-right\">" + "<span class=\"more\"></span>" + "</span>", km.getSnippetHTML());
km = ki.getMatchInfo("match-WPD15/U43/34816-p420-422", "tokens", "dereko", null, true, false);
assertEquals("SnippetBrackets (with Spans)", "<span class=\"context-left\">" + "<span class=\"more\"></span>" + "</span>" + "<span class=\"match\">" + "<mark>" + "<span title=\"dereko/s:ref\">online</span> verfügbar" + "</mark>" + "</span>" + "<span class=\"context-right\">" + "<span class=\"more\"></span>" + "</span>", km.getSnippetHTML());
}
use of de.ids_mannheim.korap.response.Match in project Krill by KorAP.
the class TestMatchIdentifier method indexExample1.
@Test
public void indexExample1() throws IOException {
KrillIndex ki = new KrillIndex();
ki.addDoc(createSimpleFieldDoc());
ki.commit();
QueryBuilder kq = new QueryBuilder("tokens");
Krill ks = new Krill(kq.nr(2, kq.seq(kq.seg("s:b")).append(kq.nr(kq.seg("s:a")))));
Result kr = ki.search(ks);
assertEquals("totalResults", kr.getTotalResults(), 1);
assertEquals("StartPos (0)", kr.getMatch(0).startPos, 7);
assertEquals("EndPos (0)", kr.getMatch(0).endPos, 9);
Match km = kr.getMatch(0);
assertEquals("SnippetBrackets (0)", "... bcabca[[{2:b{1:a}}]]c", km.getSnippetBrackets());
assertEquals("ID (0)", "match-c1!d1-p7-9(2)7-8(1)8-8", km.getID());
}
use of de.ids_mannheim.korap.response.Match in project Krill by KorAP.
the class TestMatchIdentifier method indexExample3.
@Test
public void indexExample3() throws IOException, QueryException {
KrillIndex ki = new KrillIndex();
ki.addDoc(createSimpleFieldDoc());
ki.commit();
Match km = ki.getMatchInfo("match-c1!d1-p7-9(4)8-8(2)7-8", "tokens", null, null, false, true);
assertEquals("SnippetHTML (1)", "<span class=\"context-left\">" + "<span class=\"more\">" + "</span>" + "</span>" + "<span class=\"match\">" + "<mark>" + "<mark class=\"class-2 level-0\">" + "<span title=\"f/m:acht\">" + "<span title=\"f/y:eight\">" + "<span title=\"it/is:8\">" + "<span title=\"x/o:achtens\">" + "b" + "</span>" + "</span>" + "</span>" + "</span>" + "<mark class=\"class-4 level-1\">" + "<span title=\"f/m:neun\">" + "<span title=\"f/y:nine\">" + "<span title=\"it/is:9\">" + "<span title=\"x/o:neuntens\">" + "a" + "</span>" + "</span>" + "</span>" + "</span>" + "</mark>" + "</mark>" + "</mark>" + "</span>" + "<span class=\"context-right\">" + "<span class=\"more\">" + "</span>" + "</span>", km.getSnippetHTML());
}
use of de.ids_mannheim.korap.response.Match in project Krill by KorAP.
the class TestMatchIdentifier method indexExample2.
@Test
public void indexExample2() throws IOException, QueryException {
KrillIndex ki = new KrillIndex();
ki.addDoc(createSimpleFieldDoc());
ki.commit();
Match km = ki.getMatch("match-c1!d1-p7-9(0)8-8(2)7-8");
assertEquals("StartPos (0)", 7, km.getStartPos());
assertEquals("EndPos (0)", 9, km.getEndPos());
assertEquals("SnippetBrackets (0)", "... [[{2:b{a}}]] ...", km.getSnippetBrackets());
assertEquals("ID (0)", "match-c1!d1-p7-9(0)8-8(2)7-8", km.getID());
km = ki.getMatchInfo("match-c1!d1-p7-9(0)8-8(2)7-8", "tokens", "f", "m", false, false);
assertEquals("SnippetBrackets (1)", "... [[{f/m:acht:b}{f/m:neun:a}]] ...", km.getSnippetBrackets());
// Mirror identifier when passed
km = ki.getMatchInfo("match-c1!d1-p7-9(0)8-8(2)7-8", "tokens", "f", null, false, false);
assertEquals("SnippetBrackets (1b)", "... [[{f/m:acht:{f/y:eight:b}}{f/m:neun:{f/y:nine:a}}]] ...", km.getSnippetBrackets());
JsonNode res = mapper.readTree(km.toJsonString());
assertEquals("match-c1!d1-p7-9(0)8-8(2)7-8", res.at("/matchID").asText());
km = ki.getMatchInfo("match-c1!d1-p7-9(0)8-8(2)7-8", "tokens", "f", "m", false, true);
assertEquals("SnippetBrackets (2)", "... [[{2:{f/m:acht:b}{{f/m:neun:a}}}]] ...", km.getSnippetBrackets());
km = ki.getMatchInfo("match-c1!d1-p7-9(4)8-8(2)7-8", "tokens", "f", "m", false, true);
assertEquals("SnippetBrackets (3)", "... [[{2:{f/m:acht:b}{4:{f/m:neun:a}}}]] ...", km.getSnippetBrackets());
km = ki.getMatchInfo("match-c1!d1-p7-9(4)8-8(2)7-8", "tokens", "f", null, false, true);
assertEquals("SnippetBrackets (4)", "... [[{2:{f/m:acht:{f/y:eight:b}}{4:{f/m:neun:{f/y:nine:a}}}}]] ...", km.getSnippetBrackets());
assertEquals("SnippetHTML (4)", "<span class=\"context-left\">" + "<span class=\"more\">" + "</span>" + "</span>" + "<span class=\"match\">" + "<mark>" + "<mark class=\"class-2 level-0\">" + "<span title=\"f/m:acht\">" + "<span title=\"f/y:eight\">" + "b" + "</span>" + "</span>" + "<mark class=\"class-4 level-1\">" + "<span title=\"f/m:neun\">" + "<span title=\"f/y:nine\">" + "a" + "</span>" + "</span>" + "</mark>" + "</mark>" + "</mark>" + "</span>" + "<span class=\"context-right\">" + "<span class=\"more\">" + "</span>" + "</span>", km.getSnippetHTML());
res = mapper.readTree(km.toJsonString());
assertEquals("tokens", res.at("/field").asText());
assertTrue(res.at("/startMore").asBoolean());
assertTrue(res.at("/endMore").asBoolean());
assertEquals("c1", res.at("/corpusID").asText());
assertEquals("d1", res.at("/docID").asText());
assertEquals("match-c1!d1-p7-9(4)8-8(2)7-8", res.at("/matchID").asText());
assertTrue(res.at("/pubDate").isMissingNode());
}
Aggregations