Search in sources :

Example 1 with MatchIdentifier

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

the class TestMatchIdentifier method identifierExample1.

@Test
public void identifierExample1() throws IOException, QueryException {
    MatchIdentifier id = new MatchIdentifier("match-c1!d1-p4-20");
    assertEquals(id.getCorpusID(), "c1");
    assertEquals(id.getDocID(), "d1");
    assertEquals(id.getStartPos(), 4);
    assertEquals(id.getEndPos(), 20);
    assertEquals(id.toString(), "match-c1!d1-p4-20");
    id.addPos(10, 14, 2);
    assertEquals(id.toString(), "match-c1!d1-p4-20(2)10-14");
    id.addPos(11, 12, 5);
    assertEquals(id.toString(), "match-c1!d1-p4-20(2)10-14(5)11-12");
    // Ignore
    id.addPos(11, 12, -8);
    assertEquals(id.toString(), "match-c1!d1-p4-20(2)10-14(5)11-12");
    id.addPos(11, -12, 8);
    assertEquals(id.toString(), "match-c1!d1-p4-20(2)10-14(5)11-12");
    id.addPos(-11, 12, 8);
    assertEquals(id.toString(), "match-c1!d1-p4-20(2)10-14(5)11-12");
    id = new MatchIdentifier("matc-c1!d1-p4-20");
    assertNull(id.toString());
    id = new MatchIdentifier("match-d1-p4-20");
    assertNull(id.getCorpusID());
    assertEquals(id.getDocID(), "d1");
    id = new MatchIdentifier("match-p4-20");
    assertNull(id.toString());
    id = new MatchIdentifier("match-c1!d1-p4-20");
    assertEquals(id.toString(), "match-c1!d1-p4-20");
    id = new MatchIdentifier("match-c1!d1-p4-20(5)7-8");
    assertEquals(id.toString(), "match-c1!d1-p4-20(5)7-8");
    id = new MatchIdentifier("match-c1!d1-p4-20(5)7-8(-2)9-10");
    assertEquals(id.toString(), "match-c1!d1-p4-20(5)7-8");
    id = new MatchIdentifier("match-c1!d1-p4-20(5)7-8(-2)9-10(2)3-4(3)-5-6");
    assertEquals(id.toString(), "match-c1!d1-p4-20(5)7-8(2)3-4");
    id = new MatchIdentifier("match-c1!d1-p4-20(5)7-8(-2)9-10(2)3-4(3)-5-6(4)7-8");
    assertEquals(id.toString(), "match-c1!d1-p4-20(5)7-8(2)3-4(4)7-8");
    id = new MatchIdentifier("match-c1!d1-p4-20(5)7-8(-2)9-10(2)3-4(3)-5-6(4)7-8(5)9--10");
    assertEquals(4, id.getStartPos());
    assertEquals(20, id.getEndPos());
    assertEquals("c1", id.getCorpusID());
    assertEquals("d1", id.getDocID());
    assertEquals(null, id.getTextSigle());
    assertEquals(id.toString(), "match-c1!d1-p4-20(5)7-8(2)3-4(4)7-8");
    id = new MatchIdentifier("match-GOE!GOE_AGF.02286-p2105-2106");
    assertEquals(2105, id.getStartPos());
    assertEquals(2106, id.getEndPos());
    assertEquals(null, id.getCorpusID());
    assertEquals(null, id.getDocID());
    assertEquals("GOE_AGF.02286", id.getTextSigle());
    assertEquals("match-GOE_AGF.02286-p2105-2106", id.toString());
    id = new MatchIdentifier("match-corpus-1/doc-1/text-1/p2105-2106");
    assertEquals("match-corpus-1/doc-1/text-1-p2105-2106", id.toString());
    assertEquals("corpus-1/doc-1/text-1", id.getTextSigle());
}
Also used : MatchIdentifier(de.ids_mannheim.korap.response.match.MatchIdentifier) Test(org.junit.Test)

Example 2 with MatchIdentifier

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

the class Match method getMatchIdentifier.

@JsonIgnore
public MatchIdentifier getMatchIdentifier() {
    MatchIdentifier id = new MatchIdentifier();
    id.setStartPos(startPos);
    id.setEndPos(endPos);
    // There are highlights to integrate
    if (this.highlight != null) {
        for (Highlight h : this.highlight) {
            if (h.number >= 256 || h.end == PB_MARKER)
                continue;
            // Add highlight to the snippet
            id.addPos(h.start, h.end, h.number);
        }
        ;
    }
    ;
    return id;
}
Also used : MatchIdentifier(de.ids_mannheim.korap.response.match.MatchIdentifier) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore)

Example 3 with MatchIdentifier

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

the class Match method getID.

/**
 * Get match ID (for later retrieval).
 *
 * @see MatchIdentifier
 */
@Override
@JsonProperty("matchID")
public String getID() {
    // Return identifier as given
    if (this.mirrorIdentifier != null) {
        return this.mirrorIdentifier;
    }
    ;
    // Identifier already created
    if (this.identifier != null) {
        return this.identifier;
    }
    ;
    // No, nada, nix
    if (this.localDocID == -1)
        return null;
    MatchIdentifier id = this.getMatchIdentifier();
    // Get prefix string corpus/doc
    if (this.getTextSigle() != null) {
        id.setTextSigle(this.getTextSigle());
    } else // LEGACY
    {
        id.setCorpusID(this.getCorpusID());
        id.setDocID(this.getDocID());
    }
    ;
    return (this.identifier = id.toString());
}
Also used : MatchIdentifier(de.ids_mannheim.korap.response.match.MatchIdentifier) JsonProperty(com.fasterxml.jackson.annotation.JsonProperty)

Aggregations

MatchIdentifier (de.ids_mannheim.korap.response.match.MatchIdentifier)3 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)1 Test (org.junit.Test)1