use of org.apache.uima.resource.metadata.impl.TypeSystemDescription_impl in project webanno by webanno.
the class AnnotationSchemaServiceImpl method getProjectTypes.
@Override
public TypeSystemDescription getProjectTypes(Project aProject) {
// Create a new type system from scratch
TypeSystemDescription tsd = new TypeSystemDescription_impl();
for (AnnotationLayer type : listAnnotationLayer(aProject)) {
if (type.getType().equals(SPAN_TYPE) && !type.isBuiltIn()) {
TypeDescription td = tsd.addType(type.getName(), "", CAS.TYPE_NAME_ANNOTATION);
generateFeatures(tsd, td, type);
} else if (type.getType().equals(RELATION_TYPE) && !type.isBuiltIn()) {
TypeDescription td = tsd.addType(type.getName(), "", CAS.TYPE_NAME_ANNOTATION);
AnnotationLayer attachType = type.getAttachType();
td.addFeature(WebAnnoConst.FEAT_REL_TARGET, "", attachType.getName());
td.addFeature(WebAnnoConst.FEAT_REL_SOURCE, "", attachType.getName());
generateFeatures(tsd, td, type);
} else if (type.getType().equals(CHAIN_TYPE) && !type.isBuiltIn()) {
TypeDescription tdChains = tsd.addType(type.getName() + "Chain", "", CAS.TYPE_NAME_ANNOTATION_BASE);
tdChains.addFeature("first", "", type.getName() + "Link");
// Custom features on chain layers are currently not supported
// generateFeatures(tsd, tdChains, type);
TypeDescription tdLink = tsd.addType(type.getName() + "Link", "", CAS.TYPE_NAME_ANNOTATION);
tdLink.addFeature("next", "", type.getName() + "Link");
tdLink.addFeature("referenceType", "", CAS.TYPE_NAME_STRING);
tdLink.addFeature("referenceRelation", "", CAS.TYPE_NAME_STRING);
}
}
return tsd;
}
use of org.apache.uima.resource.metadata.impl.TypeSystemDescription_impl in project webanno by webanno.
the class DiffUtils method createMultiLinkWithRoleTestTypeSytem.
public static TypeSystemDescription createMultiLinkWithRoleTestTypeSytem(String... aFeatures) throws Exception {
List<TypeSystemDescription> typeSystems = new ArrayList<>();
TypeSystemDescription tsd = new TypeSystemDescription_impl();
// Link type
TypeDescription linkTD = tsd.addType(LINK_TYPE, "", CAS.TYPE_NAME_TOP);
linkTD.addFeature("role", "", CAS.TYPE_NAME_STRING);
linkTD.addFeature("target", "", Token.class.getName());
// Link host
TypeDescription hostTD = tsd.addType(HOST_TYPE, "", CAS.TYPE_NAME_ANNOTATION);
hostTD.addFeature("links", "", CAS.TYPE_NAME_FS_ARRAY, linkTD.getName(), false);
for (String feature : aFeatures) {
hostTD.addFeature(feature, "", CAS.TYPE_NAME_STRING);
}
typeSystems.add(tsd);
typeSystems.add(TypeSystemDescriptionFactory.createTypeSystemDescription());
return CasCreationUtils.mergeTypeSystems(typeSystems);
}
use of org.apache.uima.resource.metadata.impl.TypeSystemDescription_impl in project webanno by webanno.
the class DiffUtils method createMultiLinkWithRoleTestTypeSytem.
public static TypeSystemDescription createMultiLinkWithRoleTestTypeSytem() throws Exception {
List<TypeSystemDescription> typeSystems = new ArrayList<>();
TypeSystemDescription tsd = new TypeSystemDescription_impl();
// Link type
TypeDescription linkTD = tsd.addType(LINK_TYPE, "", CAS.TYPE_NAME_TOP);
linkTD.addFeature("role", "", CAS.TYPE_NAME_STRING);
linkTD.addFeature("target", "", Token.class.getName());
// Link host
TypeDescription hostTD = tsd.addType(HOST_TYPE, "", CAS.TYPE_NAME_ANNOTATION);
hostTD.addFeature("links", "", CAS.TYPE_NAME_FS_ARRAY, linkTD.getName(), false);
typeSystems.add(tsd);
typeSystems.add(TypeSystemDescriptionFactory.createTypeSystemDescription());
return CasCreationUtils.mergeTypeSystems(typeSystems);
}
Aggregations