Search in sources :

Example 6 with AnalysisEngine

use of org.apache.uima.analysis_engine.AnalysisEngine in project stanbol by apache.

the class UIMALocal method activate.

@Override
protected void activate(ComponentContext ctx) throws ConfigurationException {
    super.activate(ctx);
    Dictionary<String, Object> props = ctx.getProperties();
    this.uimaUri = (String) props.get(UIMA_CONTENTPART_URIREF);
    this.uimaSourceName = (String) props.get(UIMA_SOURCENAME);
    this.uimaDescriptorPath = (String) props.get(UIMA_DESCRIPTOR_PATH);
    SUPPORTED_MIMETYPES = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList((String[]) props.get(UIMA_SUPPORTED_MIMETYPES))));
    aeProvider = AEProviderFactory.getInstance().getAEProvider(uimaSourceName, uimaDescriptorPath, new HashMap<String, Object>());
    try {
        AnalysisEngine ae = aeProvider.getAE();
        TypeDescription[] aeTypes = ae.getAnalysisEngineMetaData().getTypeSystem().getTypes();
        uimaTypeNames = new ArrayList<String>();
        for (TypeDescription aeType : aeTypes) {
            String aeTypeName = aeType.getName();
            logger.info("Configuring Analysis Engine Type:" + aeTypeName);
            uimaTypeNames.add(aeTypeName);
        }
    } catch (ResourceInitializationException ex) {
        logger.error("Cannot retrieve AE from AEProvider. ", ex);
        throw new ConfigurationException(uimaDescriptorPath, "Cannot retreive AE from AEProvider", ex);
    }
}
Also used : HashMap(java.util.HashMap) ConfigurationException(org.osgi.service.cm.ConfigurationException) ResourceInitializationException(org.apache.uima.resource.ResourceInitializationException) TypeDescription(org.apache.uima.resource.metadata.TypeDescription) HashSet(java.util.HashSet) AnalysisEngine(org.apache.uima.analysis_engine.AnalysisEngine)

Aggregations

AnalysisEngine (org.apache.uima.analysis_engine.AnalysisEngine)6 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)1 JCas (org.apache.uima.jcas.JCas)1 ResourceInitializationException (org.apache.uima.resource.ResourceInitializationException)1 ResourceSpecifier (org.apache.uima.resource.ResourceSpecifier)1 TypeDescription (org.apache.uima.resource.metadata.TypeDescription)1 XMLInputSource (org.apache.uima.util.XMLInputSource)1 ConfigurationException (org.osgi.service.cm.ConfigurationException)1