use of de.ids_mannheim.korap.response.Match in project Krill by KorAP.
the class TestMatchIdentifier method snippetBugTest3.
@Test
public void snippetBugTest3() throws IOException, QueryException {
KrillIndex ki = new KrillIndex();
ki.addDoc(getClass().getResourceAsStream("/wiki/WPD17-H81-63495.json.gz"), true);
ki.commit();
Match km;
String snippet;
km = ki.getMatchInfo("match-WPD17/H81/63495-p88-91", "tokens", "xyz", "s", false, false, false);
km.setContext(new SearchContext(true, (short) 2, true, (short) 2));
snippet = km.getSnippetHTML();
assertEquals("<span class=\"context-left\">" + "<span class=\"more\"></span>" + "angesehen wurde. " + "</span>" + "<span class=\"match\">" + "<mark>Der alte Baum</mark>" + "</span>" + "<span class=\"context-right\">" + " war eine" + "<span class=\"more\"></span>" + "</span>", snippet);
// Expansion - no context
km = ki.getMatchInfo("match-WPD17/H81/63495-p88-91", "tokens", "xyz", "s", true, true, true);
snippet = km.getSnippetHTML();
assertEquals("<span class=\"context-left\">" + "</span>" + "<span class=\"match\">" + "<mark>Der alte Baum</mark>" + " war eine Sommerlinde (Tilia platyphyllos) , " + "der neue ist eine Winterlinde (Tilia cordata)." + "</span>" + "<span class=\"context-right\">" + "</span>", snippet);
// Addition context
/*
TODO: Support context nonetheless
km = ki.getMatchInfo("match-WPD17/H81/63495-p88-91", "tokens",
"xyz", "s", true, true, true);
km.setContext(new SearchContext(true, (short) 2, true, (short) 2));
snippet = km.getSnippetHTML();
assertEquals(
"<span class=\"context-left\">"+
"xyz"+
"</span>"+
"<span class=\"match\">"+
"<mark>Der alte Baum</mark>"+
" war eine Sommerlinde (Tilia platyphyllos) , "+
"der neue ist eine Winterlinde (Tilia cordata)."+
"</span>"+
"<span class=\"context-right\">"+
"xyz"+
"</span>",
snippet
);
*/
km = ki.getMatchInfo("match-WPD17/H81/63495-p88-91", "tokens", null, null, false, true, true);
snippet = km.getSnippetHTML();
assertEquals("<span class=\"context-left\"></span>" + "<span class=\"match\">" + "<mark>" + "<span title=\"tt/l:die\">" + "<span title=\"tt/p:ART\">Der</span>" + "</span>" + " " + "<span title=\"tt/l:alt\">" + "<span title=\"tt/p:ADJA\">alte</span>" + "</span>" + " " + "<span title=\"tt/l:Baum\">" + "<span title=\"tt/p:NN\">Baum</span>" + "</span>" + "</mark>" + " " + "<span title=\"tt/l:sein\">" + "<span title=\"tt/p:VAFIN\">war</span>" + "</span>" + " " + "<span title=\"tt/l:eine\">" + "<span title=\"tt/p:ART\">eine</span>" + "</span>" + " " + "<span title=\"tt/l:Sommerlinde\">" + "<span title=\"tt/l:Sommerlinde\">" + "<span title=\"tt/p:NE\">" + "<span title=\"tt/p:NN\">Sommerlinde</span>" + "</span>" + "</span>" + "</span>" + " (" + "<span title=\"tt/p:NE\">Tilia</span>" + " " + "<span title=\"tt/p:ADJA\">" + "<span title=\"tt/p:ADJD\">" + "<span title=\"tt/p:NE\">" + "<span title=\"tt/p:NN\">" + "<span title=\"tt/p:VVFIN\">platyphyllos</span>" + "</span>" + "</span>" + "</span>" + "</span>" + ") , " + "<span title=\"tt/l:die\">" + "<span title=\"tt/p:ART\">der</span>" + "</span>" + " " + "<span title=\"tt/l:neu\">" + "<span title=\"tt/p:ADJA\">neue</span>" + "</span>" + " " + "<span title=\"tt/l:sein\">" + "<span title=\"tt/p:VAFIN\">ist</span>" + "</span>" + " " + "<span title=\"tt/l:eine\">" + "<span title=\"tt/p:ART\">eine</span>" + "</span>" + " " + "<span title=\"tt/l:Winterlinde\">" + "<span title=\"tt/l:Winterlinde\">" + "<span title=\"tt/p:NE\">" + "<span title=\"tt/p:NN\">Winterlinde</span>" + "</span>" + "</span>" + "</span>" + " (" + "<span title=\"tt/p:NE\">Tilia</span>" + " " + "<span title=\"tt/p:NE\">cordata</span>" + ")." + "</span>" + "<span class=\"context-right\">" + "</span>", snippet);
km = ki.getMatchInfo("match-WPD17/H81/63495-p88-91", "tokens", "dereko", "s", true, true, true);
snippet = km.getSnippetHTML();
assertEquals("<span class=\"context-left\"></span>" + "<span class=\"match\">" + "<span title=\"dereko/s:s\">" + "<mark>Der alte Baum</mark>" + " war eine " + "<span title=\"dereko/s:ref\">Sommerlinde</span>" + " (" + "<span title=\"dereko/s:hi\">Tilia platyphyllos</span>" + ") , der neue ist eine " + "<span title=\"dereko/s:ref\">Winterlinde</span> (" + "<span title=\"dereko/s:hi\">Tilia cordata</span>" + "</span>" + ")." + "</span>" + "<span class=\"context-right\"></span>", snippet);
}
use of de.ids_mannheim.korap.response.Match in project Krill by KorAP.
the class TestMatchIdentifier method indexExampleFailingFoundry.
@Test
public void indexExampleFailingFoundry() throws IOException, QueryException {
KrillIndex ki = new KrillIndex();
ki.addDoc(createSimpleFieldDoc4());
ki.commit();
Match km = ki.getMatchInfo("match-c1!d4-p3-9", "tokens", "*", "m", false, false);
JsonNode res = mapper.readTree(km.toJsonString());
assertEquals("c1", res.at("/corpusID").asText());
assertEquals("d4", res.at("/docID").asText());
assertEquals("Invalid foundry requested", res.at("/errors/0/1").asText());
}
use of de.ids_mannheim.korap.response.Match in project Krill by KorAP.
the class TestMatchIdentifier method indexAttributeInfo.
@Test
public void indexAttributeInfo() throws IOException, QueryException {
KrillIndex ki = new KrillIndex();
ki.addDoc(createAttributeFieldDoc());
ki.commit();
Match km = ki.getMatchInfo("match-ca1!da1-p7-10", "tokens", null, null, false, false);
JsonNode res = mapper.readTree(km.toJsonString());
assertEquals("tokens", res.at("/field").asText());
assertTrue(res.at("/startMore").asBoolean());
assertTrue(res.at("/endMore").asBoolean());
assertEquals("ca1", res.at("/corpusID").asText());
assertEquals("da1", res.at("/docID").asText());
assertEquals("<span class=\"context-left\">" + "<span class=\"more\">" + "</span>" + "</span>" + "<span class=\"match\"><mark>" + // "<span title=\"@:x/s:key:value\">"+
"<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>" + "</span>" + "<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>" + "<span title=\"f/m:zehn\">" + "<span title=\"f/y:ten\">" + "<span title=\"it/is:10\">" + "<span title=\"x/o:zehntens\">c</span>" + "</span>" + "</span>" + "</span>" + "</mark>" + "</span>" + "<span class=\"context-right\">" + "</span>", res.at("/snippet").asText());
}
use of de.ids_mannheim.korap.response.Match in project Krill by KorAP.
the class TestMatchIdentifier method indexWithFieldInfo.
@Test
public void indexWithFieldInfo() 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, false);
assertEquals(km.getAvailability(), "CC-BY-SA");
}
use of de.ids_mannheim.korap.response.Match in project Krill by KorAP.
the class TestMatchIdentifier method indexFailingMatchID.
@Test
public void indexFailingMatchID() throws IOException, QueryException {
KrillIndex ki = new KrillIndex();
Match km = ki.getMatchInfo("match-PRO-DUD!PRO-DUD_KSTA-2013-01.7483-2013-01", "tokens", "*", "m", false, false);
JsonNode res = mapper.readTree(km.toJsonString());
assertEquals("730", res.at("/errors/0/0").asText());
}
Aggregations