use of de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature in project webanno by webanno.
the class TypeSystemAnalysis method analyzeFeature.
private AnnotationFeature analyzeFeature(TypeSystem aTS, FeatureDescription aFD, Feature aFeat) {
AnnotationFeature feat = new AnnotationFeature();
feat.setType(aFeat.getRange().getName());
feat.setName(aFeat.getShortName());
feat.setUiName(aFeat.getShortName());
feat.setDescription(trimToNull(aFD.getDescription()));
feat.setEnabled(true);
if (isSlotFeature(aTS, aFeat)) {
feat.setType(aFeat.getRange().getComponentType().getFeatureByBaseName("target").getRange().getName());
feat.setMode(MultiValueMode.ARRAY);
feat.setLinkMode(LinkMode.WITH_ROLE);
// Need to strip the "[]" marking the type as multi-valued off the type name
feat.setLinkTypeName(removeEnd(aFeat.getRange().getName(), "[]"));
// FIXME Instead of hard-coding the feature names here, try to auto-detect them by
// looking for a String feature and a feature whose type is subsumed by Annotation
feat.setLinkTypeRoleFeatureName("role");
feat.setLinkTypeTargetFeatureName("target");
}
return feat;
}
use of de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature in project webanno by webanno.
the class TypeSystemAnalysisTest method testSpanWithPrimitiveFeatures.
@Test
public void testSpanWithPrimitiveFeatures() throws Exception {
TypeSystemDescription tsd = createTypeSystemDescription("tsd/spanWithPrimitiveFeatures");
TypeSystemAnalysis analysis = TypeSystemAnalysis.of(tsd);
AnnotationLayer spanLayer = new AnnotationLayer();
spanLayer.setName("webanno.custom.Span");
spanLayer.setUiName("Span");
spanLayer.setType(WebAnnoConst.SPAN_TYPE);
spanLayer.setLockToTokenOffset(false);
spanLayer.setAllowStacking(true);
spanLayer.setCrossSentence(true);
AnnotationFeature stringFeature = new AnnotationFeature("stringFeature", CAS.TYPE_NAME_STRING);
AnnotationFeature intFeature = new AnnotationFeature("intFeature", CAS.TYPE_NAME_INTEGER);
AnnotationFeature booleanFeature = new AnnotationFeature("booleanFeature", CAS.TYPE_NAME_BOOLEAN);
AnnotationFeature floatFeature = new AnnotationFeature("floatFeature", CAS.TYPE_NAME_FLOAT);
SoftAssertions softly = new SoftAssertions();
softly.assertThat(analysis.getLayers()).containsExactly(spanLayer).usingFieldByFieldElementComparator();
softly.assertThat(analysis.getFeatures(spanLayer.getName())).containsExactlyInAnyOrder(stringFeature, intFeature, booleanFeature, floatFeature).usingFieldByFieldElementComparator();
softly.assertAll();
}
use of de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature in project webanno by webanno.
the class TypeSystemAnalysisTest method testSpanWithSlotFeatures.
@Test
public void testSpanWithSlotFeatures() throws Exception {
TypeSystemDescription tsd = createTypeSystemDescription("tsd/spanWithSlotFeatures");
TypeSystemAnalysis analysis = TypeSystemAnalysis.of(tsd);
AnnotationLayer slotSpanLayer = new AnnotationLayer();
slotSpanLayer.setName("webanno.custom.SlotSpan");
slotSpanLayer.setUiName("SlotSpan");
slotSpanLayer.setType(WebAnnoConst.SPAN_TYPE);
slotSpanLayer.setLockToTokenOffset(false);
slotSpanLayer.setAllowStacking(true);
slotSpanLayer.setCrossSentence(true);
AnnotationFeature freeSlot = new AnnotationFeature("freeSlot", CAS.TYPE_NAME_ANNOTATION);
AnnotationFeature boundSlot = new AnnotationFeature("boundSlot", "webanno.custom.SlotSpan");
SoftAssertions softly = new SoftAssertions();
softly.assertThat(analysis.getLayers()).containsExactly(slotSpanLayer).usingFieldByFieldElementComparator();
softly.assertThat(analysis.getFeatures(slotSpanLayer.getName())).containsExactlyInAnyOrder(freeSlot, boundSlot).usingFieldByFieldElementComparator();
softly.assertAll();
}
use of de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature in project webanno by webanno.
the class TypeSystemAnalysisTest method testChain.
@Test
public void testChain() throws Exception {
TypeSystemDescription tsd = createTypeSystemDescription("tsd/chain");
TypeSystemAnalysis analysis = TypeSystemAnalysis.of(tsd);
AnnotationLayer chainLayer = new AnnotationLayer();
chainLayer.setName("webanno.custom.Chain");
chainLayer.setUiName("Chain");
chainLayer.setType(WebAnnoConst.CHAIN_TYPE);
chainLayer.setLockToTokenOffset(false);
chainLayer.setAllowStacking(true);
chainLayer.setCrossSentence(true);
AnnotationFeature referenceRelationFeature = new AnnotationFeature("referenceRelation", CAS.TYPE_NAME_STRING);
AnnotationFeature referenceTypeFeature = new AnnotationFeature("referenceType", CAS.TYPE_NAME_STRING);
SoftAssertions softly = new SoftAssertions();
softly.assertThat(analysis.getLayers()).containsExactlyInAnyOrder(chainLayer).usingFieldByFieldElementComparator();
softly.assertThat(analysis.getFeatures(chainLayer.getName())).containsExactlyInAnyOrder(referenceRelationFeature, referenceTypeFeature).usingFieldByFieldElementComparator();
softly.assertAll();
}
use of de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature in project webanno by webanno.
the class TypeSystemAnalysisTest method testRelationWithPrimitiveFeatures.
@Test
public void testRelationWithPrimitiveFeatures() throws Exception {
TypeSystemDescription tsd = createTypeSystemDescription("tsd/relationWithPrimitiveFeatures");
TypeSystemAnalysis analysis = TypeSystemAnalysis.of(tsd);
AnnotationLayer relationLayer = new AnnotationLayer();
relationLayer.setName("webanno.custom.Relation");
relationLayer.setUiName("Relation");
relationLayer.setType(WebAnnoConst.RELATION_TYPE);
relationLayer.setLockToTokenOffset(false);
relationLayer.setAllowStacking(true);
relationLayer.setCrossSentence(true);
AnnotationLayer relationTargetLayer = new AnnotationLayer();
relationTargetLayer.setName("webanno.custom.RelationTarget");
relationTargetLayer.setUiName("RelationTarget");
relationTargetLayer.setType(WebAnnoConst.SPAN_TYPE);
relationTargetLayer.setLockToTokenOffset(false);
relationTargetLayer.setAllowStacking(true);
relationTargetLayer.setCrossSentence(true);
AnnotationFeature stringFeature = new AnnotationFeature("stringFeature", CAS.TYPE_NAME_STRING);
AnnotationFeature intFeature = new AnnotationFeature("intFeature", CAS.TYPE_NAME_INTEGER);
AnnotationFeature booleanFeature = new AnnotationFeature("booleanFeature", CAS.TYPE_NAME_BOOLEAN);
AnnotationFeature floatFeature = new AnnotationFeature("floatFeature", CAS.TYPE_NAME_FLOAT);
SoftAssertions softly = new SoftAssertions();
softly.assertThat(analysis.getLayers()).containsExactlyInAnyOrder(relationLayer, relationTargetLayer).usingFieldByFieldElementComparator();
softly.assertThat(analysis.getFeatures(relationLayer.getName())).containsExactlyInAnyOrder(stringFeature, intFeature, booleanFeature, floatFeature).usingFieldByFieldElementComparator();
softly.assertAll();
}
Aggregations