Search in sources :

Example 1 with TsvUnit

use of de.tudarmstadt.ukp.clarin.webanno.tsv.internal.tsv3x.model.TsvUnit in project webanno by webanno.

the class Tsv3XSerializer method writeRelationReference.

private static void writeRelationReference(PrintWriter aOut, TsvDocument aDoc, TsvColumn aCol, AnnotationFS aFS) {
    AnnotationFS targetFS = getFeature(aFS, FEAT_REL_TARGET, AnnotationFS.class);
    AnnotationFS sourceFS = getFeature(aFS, FEAT_REL_SOURCE, AnnotationFS.class);
    // The column contains the ID of the unit from which the relation is pointing to the
    // current unit, i.e. the sourceUnit of the relation.
    TsvUnit sourceUnit = aDoc.findIdDefiningUnit(sourceFS);
    aOut.print(sourceUnit.getId());
    // If the source/target is ambiguous, add the disambiguation IDs
    Integer sourceId = aDoc.getDisambiguationId(sourceFS);
    Integer targetId = aDoc.getDisambiguationId(targetFS);
    if (sourceId != null || targetId != null) {
        sourceId = sourceId != null ? sourceId : 0;
        targetId = targetId != null ? targetId : 0;
        aOut.printf("[%d_%d]", sourceId, targetId);
    }
}
Also used : AnnotationFS(org.apache.uima.cas.text.AnnotationFS) TsvUnit(de.tudarmstadt.ukp.clarin.webanno.tsv.internal.tsv3x.model.TsvUnit)

Example 2 with TsvUnit

use of de.tudarmstadt.ukp.clarin.webanno.tsv.internal.tsv3x.model.TsvUnit in project webanno by webanno.

the class Tsv3XSerializer method writeSlotTarget.

private static void writeSlotTarget(PrintWriter aOut, TsvDocument aDoc, TsvColumn aCol, AnnotationFS aFS) {
    FeatureStructure[] links = getFeature(aFS, aCol.uimaFeature, FeatureStructure[].class);
    if (links != null && links.length > 0) {
        for (int i = 0; i < links.length; i++) {
            if (i > 0) {
                aOut.print(SLOT_SEP);
            }
            AnnotationFS targetFS = getFeature(links[i], TsvSchema.FEAT_SLOT_TARGET, AnnotationFS.class);
            if (targetFS == null) {
                throw new IllegalStateException("Slot link has no target: " + links[i]);
            }
            TsvUnit target = aDoc.findIdDefiningUnit(targetFS);
            if (target == null) {
                throw new IllegalStateException("Unable to find ID-defining unit for annotation: " + targetFS);
            }
            aOut.print(target.getId());
            writeDisambiguationId(aOut, aDoc, targetFS);
        }
    } else {
        aOut.print(NULL_COLUMN);
    }
}
Also used : FeatureStructure(org.apache.uima.cas.FeatureStructure) AnnotationFS(org.apache.uima.cas.text.AnnotationFS) TsvUnit(de.tudarmstadt.ukp.clarin.webanno.tsv.internal.tsv3x.model.TsvUnit)

Aggregations

TsvUnit (de.tudarmstadt.ukp.clarin.webanno.tsv.internal.tsv3x.model.TsvUnit)2 AnnotationFS (org.apache.uima.cas.text.AnnotationFS)2 FeatureStructure (org.apache.uima.cas.FeatureStructure)1