@Override public List<Pair<LogMessage, AnnotationFS>> validate(JCas aJCas) { List<Pair<LogMessage, AnnotationFS>> messages = new ArrayList<>(); for (RelationLayerBehavior behavior : behaviors) { long startTime = currentTimeMillis(); messages.addAll(behavior.onValidate(this, aJCas)); log.trace("Validation for [{}] on [{}] took {}ms", behavior.getClass().getSimpleName(), getLayer().getUiName(), currentTimeMillis() - startTime); } return messages; } }
log.warn("Relation [" + typeAdapter.getLayer().getName() + "] with id [" + getAddr(fs) + "] has loose ends - cannot render."); continue;
log.warn("Relation [" + typeAdapter.getLayer().getName() + "] with id [" + getAddr(fs) + "] has loose ends - cannot render."); continue;
@Override public CreateRelationAnnotationRequest onCreate(RelationAdapter aAdapter, CreateRelationAnnotationRequest aRequest) { if (aAdapter.getLayer().getAttachFeature() == null) { return aRequest; } // FIXME The code below appears to be broken - it basically only works because the only // case were we use the attach-feature is with the Dependency/Token layers and it works // because tokens cannot stack. "selectCovered" below would need to be replaced with // an actual lookup of the annotation pointed to by the attach-feature. final CAS cas = aRequest.getJcas().getCas(); final Type attachType = getType(cas, aAdapter.getLayer().getAttachType().getName()); AnnotationFS originFS = aRequest.getOriginFs(); AnnotationFS targetFS = aRequest.getTargetFs(); targetFS = selectCovered(cas, attachType, targetFS.getBegin(), targetFS.getEnd()).get(0); originFS = selectCovered(cas, attachType, originFS.getBegin(), originFS.getEnd()).get(0); return aRequest.changeRelation(originFS, targetFS); }
@Override public CreateRelationAnnotationRequest onCreate(RelationAdapter aAdapter, CreateRelationAnnotationRequest aRequest) { if (aAdapter.getLayer().getAttachFeature() == null) { return aRequest; } // FIXME The code below appears to be broken - it basically only works because the only // case were we use the attach-feature is with the Dependency/Token layers and it works // because tokens cannot stack. "selectCovered" below would need to be replaced with // an actual lookup of the annotation pointed to by the attach-feature. final CAS cas = aRequest.getJcas().getCas(); final Type attachType = getType(cas, aAdapter.getLayer().getAttachType().getName()); AnnotationFS originFS = aRequest.getOriginFs(); AnnotationFS targetFS = aRequest.getTargetFs(); targetFS = selectCovered(cas, attachType, targetFS.getBegin(), targetFS.getEnd()).get(0); originFS = selectCovered(cas, attachType, originFS.getBegin(), originFS.getEnd()).get(0); return aRequest.changeRelation(originFS, targetFS); }
StringBuilder message = new StringBuilder(); message.append("Relation [" + typeAdapter.getLayer().getName() + "] with id [" + getAddr(fs) + "] has loose ends - cannot render."); if (typeAdapter.getAttachFeatureName() != null) { message.append("\nRelation [" + typeAdapter.getLayer().getName() + "] attached to feature [" + typeAdapter.getAttachFeatureName() + "]."); VArc arc = new VArc(typeAdapter.getLayer(), fs, bratTypeName, governorFs, dependentFs, features);
@Override public CreateRelationAnnotationRequest onCreate(RelationAdapter aAdapter, CreateRelationAnnotationRequest aRequest) throws AnnotationException { if (aAdapter.getLayer().isCrossSentence()) { return aRequest; } if (!isBeginEndInSameSentence(aRequest.getJcas(), aRequest.getOriginFs().getBegin(), aRequest.getTargetFs().getEnd())) { throw new MultipleSentenceCoveredException("Annotation coveres multiple sentences, " + "limit your annotation to single sentence!"); } return aRequest; }
@Override public CreateRelationAnnotationRequest onCreate(RelationAdapter aAdapter, CreateRelationAnnotationRequest aRequest) throws AnnotationException { if (aAdapter.getLayer().isCrossSentence()) { return aRequest; } if (!isBeginEndInSameSentence(aRequest.getJcas(), aRequest.getOriginFs().getBegin(), aRequest.getTargetFs().getEnd())) { throw new MultipleSentenceCoveredException("Annotation coveres multiple sentences, " + "limit your annotation to single sentence!"); } return aRequest; }
StringBuilder message = new StringBuilder(); message.append("Relation [" + typeAdapter.getLayer().getName() + "] with id [" + getAddr(fs) + "] has loose ends - cannot render."); if (typeAdapter.getAttachFeatureName() != null) { message.append("\nRelation [" + typeAdapter.getLayer().getName() + "] attached to feature [" + typeAdapter.getAttachFeatureName() + "]."); VArc arc = new VArc(typeAdapter.getLayer(), fs, bratTypeName, governorFs, dependentFs, features);
throws AnnotationException if (aAdapter.getLayer().isAllowStacking()) { return aRequest; final AnnotationLayer layer = aAdapter.getLayer(); final JCas jcas = aRequest.getJcas(); final Type type = getType(jcas.getCas(), aAdapter.getLayer().getName()); final Feature dependentFeature = type.getFeatureByBaseName(aAdapter.getTargetFeatureName()); final Feature governorFeature = type.getFeatureByBaseName(aAdapter.getSourceFeatureName());
throws AnnotationException if (aAdapter.getLayer().isAllowStacking()) { return aRequest; final AnnotationLayer layer = aAdapter.getLayer(); final JCas jcas = aRequest.getJcas(); final Type type = getType(jcas.getCas(), aAdapter.getLayer().getName()); final Feature dependentFeature = type.getFeatureByBaseName(aAdapter.getTargetFeatureName()); final Feature governorFeature = type.getFeatureByBaseName(aAdapter.getSourceFeatureName());
private AnnotationFS createRelationAnnotation(CAS cas, AnnotationFS originFS, AnnotationFS targetFS) throws AnnotationException { if (targetFS == null || originFS == null) { throw new AnnotationException("Relation must have a source and a target!"); } // Set the relation offsets in DKPro Core style - the relation recieves the offsets from // the dependent // If origin and target spans are multiple tokens, dependentFS.getBegin will be the // the begin position of the first token and dependentFS.getEnd will be the End // position of the last token. final Type type = getType(cas, getLayer().getName()); final Feature dependentFeature = type.getFeatureByBaseName(targetFeatureName); final Feature governorFeature = type.getFeatureByBaseName(sourceFeatureName); AnnotationFS newAnnotation = cas.createAnnotation(type, targetFS.getBegin(), targetFS.getEnd()); newAnnotation.setFeatureValue(dependentFeature, targetFS); newAnnotation.setFeatureValue(governorFeature, originFS); cas.addFsToIndexes(newAnnotation); return newAnnotation; }
private AnnotationFS createRelationAnnotation(CAS cas, AnnotationFS originFS, AnnotationFS targetFS) throws AnnotationException { if (targetFS == null || originFS == null) { throw new AnnotationException("Relation must have a source and a target!"); } // Set the relation offsets in DKPro Core style - the relation recieves the offsets from // the dependent // If origin and target spans are multiple tokens, dependentFS.getBegin will be the // the begin position of the first token and dependentFS.getEnd will be the End // position of the last token. final Type type = getType(cas, getLayer().getName()); final Feature dependentFeature = type.getFeatureByBaseName(targetFeatureName); final Feature governorFeature = type.getFeatureByBaseName(sourceFeatureName); AnnotationFS newAnnotation = cas.createAnnotation(type, targetFS.getBegin(), targetFS.getEnd()); newAnnotation.setFeatureValue(dependentFeature, targetFS); newAnnotation.setFeatureValue(governorFeature, originFS); cas.addFsToIndexes(newAnnotation); return newAnnotation; }
if (adapter.getLayer().isCrossSentence()) { List<AnnotationFS> mSpanAnnos = new ArrayList<>( getAllAnnoFss(jCas, governorFs.getType()));
if (adapter.getLayer().isCrossSentence()) { List<AnnotationFS> mSpanAnnos = new ArrayList<>( getAllAnnoFss(jCas, governorFs.getType()));