Search in sources :

Example 26 with Match

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);
}
Also used : SearchContext(de.ids_mannheim.korap.response.SearchContext) KrillIndex(de.ids_mannheim.korap.KrillIndex) Match(de.ids_mannheim.korap.response.Match) Test(org.junit.Test)

Example 27 with Match

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());
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) KrillIndex(de.ids_mannheim.korap.KrillIndex) Match(de.ids_mannheim.korap.response.Match) Test(org.junit.Test)

Example 28 with Match

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());
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) KrillIndex(de.ids_mannheim.korap.KrillIndex) Match(de.ids_mannheim.korap.response.Match) Test(org.junit.Test)

Example 29 with Match

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");
}
Also used : KrillIndex(de.ids_mannheim.korap.KrillIndex) Match(de.ids_mannheim.korap.response.Match) Test(org.junit.Test)

Example 30 with Match

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());
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) KrillIndex(de.ids_mannheim.korap.KrillIndex) Match(de.ids_mannheim.korap.response.Match) Test(org.junit.Test)

Aggregations

Match (de.ids_mannheim.korap.response.Match)37 Test (org.junit.Test)34 KrillIndex (de.ids_mannheim.korap.KrillIndex)30 Result (de.ids_mannheim.korap.response.Result)9 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 QueryBuilder (de.ids_mannheim.korap.query.QueryBuilder)8 FieldDocument (de.ids_mannheim.korap.index.FieldDocument)7 Krill (de.ids_mannheim.korap.Krill)5 SpanQuery (org.apache.lucene.search.spans.SpanQuery)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 SpanClassQuery (de.ids_mannheim.korap.query.SpanClassQuery)1 SpanFocusQuery (de.ids_mannheim.korap.query.SpanFocusQuery)1 SpanNextQuery (de.ids_mannheim.korap.query.SpanNextQuery)1 SearchContext (de.ids_mannheim.korap.response.SearchContext)1 ArrayList (java.util.ArrayList)1 Term (org.apache.lucene.index.Term)1 SpanTermQuery (org.apache.lucene.search.spans.SpanTermQuery)1 Ignore (org.junit.Ignore)1