Search in sources :

Example 1 with TypeCapability

use of org.apache.uima.fit.descriptor.TypeCapability in project dkpro-tc by dkpro.

the class ExtractFeaturesTask method getRequiredTypesFromFeatureExtractors.

private Set<String> getRequiredTypesFromFeatureExtractors(List<ExternalResourceDescription> featureSet) throws Exception {
    Set<String> requirements = new HashSet<>();
    for (ExternalResourceDescription element : featureSet) {
        String implName;
        if (element.getResourceSpecifier() instanceof CustomResourceSpecifier) {
            implName = ((CustomResourceSpecifier) element.getResourceSpecifier()).getResourceClassName();
        } else {
            implName = element.getImplementationName();
        }
        TypeCapability annotation = ReflectionUtil.getAnnotation(Class.forName(implName), TypeCapability.class);
        if (annotation == null) {
            continue;
        }
        String[] inputs = annotation.inputs();
        StringBuilder sb = new StringBuilder();
        sb.append(implName + "|");
        for (int i = 0; i < inputs.length; i++) {
            sb.append(inputs[i]);
            if (i + 1 < inputs.length) {
                sb.append("|");
            }
        }
        requirements.add(sb.toString());
    }
    return requirements;
}
Also used : TypeCapability(org.apache.uima.fit.descriptor.TypeCapability) CustomResourceSpecifier(org.apache.uima.resource.CustomResourceSpecifier) HashSet(java.util.HashSet) ExternalResourceDescription(org.apache.uima.resource.ExternalResourceDescription)

Aggregations

HashSet (java.util.HashSet)1 TypeCapability (org.apache.uima.fit.descriptor.TypeCapability)1 CustomResourceSpecifier (org.apache.uima.resource.CustomResourceSpecifier)1 ExternalResourceDescription (org.apache.uima.resource.ExternalResourceDescription)1