Search in sources :

Example 1 with TypeSystemDescription_impl

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;
}
Also used : TypeSystemDescription_impl(org.apache.uima.resource.metadata.impl.TypeSystemDescription_impl) TypeSystemDescription(org.apache.uima.resource.metadata.TypeSystemDescription) TypeDescription(org.apache.uima.resource.metadata.TypeDescription) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer)

Example 2 with TypeSystemDescription_impl

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);
}
Also used : TypeSystemDescription_impl(org.apache.uima.resource.metadata.impl.TypeSystemDescription_impl) TypeSystemDescription(org.apache.uima.resource.metadata.TypeSystemDescription) ArrayList(java.util.ArrayList) TypeDescription(org.apache.uima.resource.metadata.TypeDescription) Token(de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token)

Example 3 with TypeSystemDescription_impl

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);
}
Also used : TypeSystemDescription_impl(org.apache.uima.resource.metadata.impl.TypeSystemDescription_impl) TypeSystemDescription(org.apache.uima.resource.metadata.TypeSystemDescription) ArrayList(java.util.ArrayList) TypeDescription(org.apache.uima.resource.metadata.TypeDescription) Token(de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token)

Aggregations

TypeDescription (org.apache.uima.resource.metadata.TypeDescription)3 TypeSystemDescription (org.apache.uima.resource.metadata.TypeSystemDescription)3 TypeSystemDescription_impl (org.apache.uima.resource.metadata.impl.TypeSystemDescription_impl)3 Token (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token)2 ArrayList (java.util.ArrayList)2 AnnotationLayer (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer)1