Search in sources :

Example 16 with Match

use of de.ids_mannheim.korap.response.Match in project Krill by KorAP.

the class TestMatchIdentifier method indexSigleDuplicate.

@Test
public void indexSigleDuplicate() throws IOException, QueryException {
    KrillIndex ki = new KrillIndex();
    ki.addDoc(createSigleDoc2());
    ki.addDoc(createSigleDoc1());
    ki.commit();
    Match km = ki.getMatchInfo("match-c1/d1/t1-p3-9", "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("c1", res.at("/corpusSigle").asText());
    assertEquals("c1/d1", res.at("/docSigle").asText());
    assertEquals("c1/d1/t1", res.at("/textSigle").asText());
    assertEquals("match-c1/d1/t1-p3-9", res.at("/matchID").asText());
    assertEquals(2, res.at("/UID").asInt());
}
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 17 with Match

use of de.ids_mannheim.korap.response.Match in project Krill by KorAP.

the class TestKrill method searchJSONwithPagebreaks.

@Test
public void searchJSONwithPagebreaks() throws IOException {
    // Construct index
    KrillIndex ki = new KrillIndex();
    // Indexing test files
    FieldDocument fd = ki.addDoc(1, getClass().getResourceAsStream("/goe/AGA-03828-pb.json.gz"), true);
    ki.commit();
    assertEquals(fd.getUID(), 1);
    assertEquals(fd.getTextSigle(), "GOE/AGA/03828");
    assertEquals(fd.getDocSigle(), "GOE/AGA");
    assertEquals(fd.getCorpusSigle(), "GOE");
    assertEquals(fd.getTitle(), "Autobiographische Einzelheiten");
    assertNull(fd.getSubTitle());
    assertEquals(fd.getTextType(), "Autobiographie");
    assertNull(fd.getTextTypeArt());
    assertNull(fd.getTextTypeRef());
    assertNull(fd.getTextColumn());
    assertNull(fd.getTextDomain());
    // assertEquals(fd.getPages(), "529-547");
    // assertEquals(fd.getAvailability(), "QAO-NC");
    assertEquals(fd.getCreationDate().toString(), "18200000");
    assertEquals(fd.getPubDate().toString(), "19820000");
    assertEquals(fd.getAuthor(), "Goethe, Johann Wolfgang von");
    assertNull(fd.getTextClass());
    assertEquals(fd.getLanguage(), "de");
    assertEquals(fd.getPubPlace(), "München");
    assertEquals(fd.getReference(), "Goethe, Johann Wolfgang von:" + " Autobiographische Einzelheiten," + " (Geschrieben bis 1832), In: Goethe," + " Johann Wolfgang von: Goethes Werke," + " Bd. 10, Autobiographische Schriften" + " II, Hrsg.: Trunz, Erich. München: " + "Verlag C. H. Beck, 1982, S. 529-547");
    assertEquals(fd.getPublisher(), "Verlag C. H. Beck");
    assertNull(fd.getEditor());
    assertNull(fd.getFileEditionStatement());
    assertNull(fd.getBiblEditionStatement());
    assertNull(fd.getKeywords());
    assertEquals(fd.getTokenSource(), "base#tokens_aggr");
    assertEquals(fd.getFoundries(), "dereko dereko/structure " + "dereko/structure/base-sentences-paragraphs-pagebreaks");
    assertEquals(fd.getLayerInfos(), "dereko/s=spans");
    assertEquals(fd.getCorpusTitle(), "Goethes Werke");
    assertNull(fd.getCorpusSubTitle());
    assertEquals(fd.getCorpusAuthor(), "Goethe, Johann Wolfgang von");
    assertEquals(fd.getCorpusEditor(), "Trunz, Erich");
    assertEquals(fd.getDocTitle(), "Goethe: Autobiographische Schriften II, (1817-1825, 1832)");
    assertNull(fd.getDocSubTitle());
    assertNull(fd.getDocEditor());
    assertNull(fd.getDocAuthor());
    Krill ks = new Krill(new QueryBuilder("tokens").seg("s:der"));
    Result kr = ks.apply(ki);
    assertEquals(kr.getTotalResults(), 97);
    assertEquals(0, kr.getStartIndex());
    assertEquals(25, kr.getItemsPerPage());
    Match m = kr.getMatch(5);
    assertEquals("Start page", m.getStartPage(), 529);
    ObjectMapper mapper = new ObjectMapper();
    JsonNode res = mapper.readTree(m.toJsonString());
    assertEquals(529, res.at("/pages/0").asInt());
}
Also used : Krill(de.ids_mannheim.korap.Krill) JsonNode(com.fasterxml.jackson.databind.JsonNode) QueryBuilder(de.ids_mannheim.korap.query.QueryBuilder) FieldDocument(de.ids_mannheim.korap.index.FieldDocument) KrillIndex(de.ids_mannheim.korap.KrillIndex) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Result(de.ids_mannheim.korap.response.Result) Match(de.ids_mannheim.korap.response.Match) Test(org.junit.Test)

Example 18 with Match

use of de.ids_mannheim.korap.response.Match in project Krill by KorAP.

the class TestSampleIndex method testMatchWithDependency.

@Test
public void testMatchWithDependency() throws IOException, QueryException {
    // /GOE/AGA/01784/p104-105/matchInfo?layer=c&foundry=corenlp&spans=true
    Match km = sample.getMatchInfo("match-GOE/AGD/00000-p132566-132569", "tokens", "corenlp", "c", true, true);
    assertEquals(km.getSnippetBrackets(), "... [[meine eigne Erfahrung]] ...");
    assertEquals(km.getSnippetHTML(), "<span class=\"context-left\"><span class=\"more\"></span></span><span class=\"match\"><mark>meine eigne Erfahrung</mark></span><span class=\"context-right\"><span class=\"more\"></span></span>");
    km = sample.getMatchInfo("match-GOE/AGD/00000-p132566-132569", "tokens", "malt", "d", true, true);
    // assertEquals(km.getSnippetBrackets(), "... [[{malt/d:DET>132567:meine} {#132567:{malt/d:ATTR>132567:eigne}} {malt/d:PN>132564:Erfahrung}]] ...");
    assertEquals(km.getSnippetHTML(), "<span class=\"context-left\"><span class=\"more\"></span></span><span class=\"match\"><mark><span xlink:title=\"malt/d:DET\" xlink:type=\"simple\" xlink:href=\"#token-GOE/AGD/00000-p132567\">meine</span> <span xml:id=\"token-GOE/AGD/00000-p132567\"><span xlink:title=\"malt/d:ATTR\" xlink:type=\"simple\" xlink:href=\"#token-GOE/AGD/00000-p132567\">eigne</span></span> <span xlink:title=\"malt/d:PN\" xlink:type=\"simple\" xlink:href=\"#token-GOE/AGD/00000-p132564\">Erfahrung</span></mark></span><span class=\"context-right\"><span class=\"more\"></span></span>");
    km = sample.getMatchInfo("match-GOE/AGD/00000-p132566-132569", "tokens", "malt", "d", true, true, true);
    assertEquals(km.getSnippetBrackets().substring(0, 20), "[{#132507:{malt/d:SU");
    assertEquals(km.getSnippetHTML().substring(0, 20), "<span class=\"context");
}
Also used : Match(de.ids_mannheim.korap.response.Match) Test(org.junit.Test)

Example 19 with Match

use of de.ids_mannheim.korap.response.Match in project Krill by KorAP.

the class TestMatch method testMatchBug.

@Test
public void testMatchBug() {
    Match m = new Match("match-PRO-DUD!PRO-DUD_KSTA-2013-01.7483-2013-01", false);
    assertEquals(null, m.getID());
}
Also used : Match(de.ids_mannheim.korap.response.Match) Test(org.junit.Test)

Example 20 with Match

use of de.ids_mannheim.korap.response.Match in project Krill by KorAP.

the class TestMatch method testMatchTextSigle1.

@Test
public void testMatchTextSigle1() {
    Match m = new Match("match-GOE!GOE_AGK.00000-p60348-60349", false);
    assertEquals("GOE_AGK.00000", m.getTextSigle());
}
Also used : 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