Search in sources :

Example 1 with ResourceInitializationException

use of org.apache.uima.resource.ResourceInitializationException in project deeplearning4j by deeplearning4j.

the class PoStagger method initialize.

/**
     * Initializes the current instance with the given context.
     * 
     * Note: Do all initialization in this method, do not use the constructor.
     */
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
    super.initialize(context);
    this.context = context;
    this.logger = context.getLogger();
    if (this.logger.isLoggable(Level.INFO)) {
        this.logger.log(Level.INFO, "Initializing the OpenNLP " + "Part of Speech annotator.");
    }
    POSModel model;
    try {
        POSModelResource modelResource = (POSModelResource) context.getResourceObject(UimaUtil.MODEL_PARAMETER);
        model = modelResource.getModel();
    } catch (ResourceAccessException e) {
        throw new ResourceInitializationException(e);
    }
    Integer beamSize = AnnotatorUtil.getOptionalIntegerParameter(context, UimaUtil.BEAM_SIZE_PARAMETER);
    if (beamSize == null)
        beamSize = POSTaggerME.DEFAULT_BEAM_SIZE;
    this.posTagger = new POSTaggerME(model, beamSize, 0);
}
Also used : POSModelResource(opennlp.uima.postag.POSModelResource) ResourceInitializationException(org.apache.uima.resource.ResourceInitializationException) POSModel(opennlp.tools.postag.POSModel) POSTaggerME(opennlp.tools.postag.POSTaggerME) ResourceAccessException(org.apache.uima.resource.ResourceAccessException)

Example 2 with ResourceInitializationException

use of org.apache.uima.resource.ResourceInitializationException in project lucene-solr by apache.

the class UIMAAnnotationsTokenizer method initializeIterator.

@Override
protected void initializeIterator() throws IOException {
    try {
        analyzeInput();
    } catch (AnalysisEngineProcessException | ResourceInitializationException e) {
        throw new IOException(e);
    }
    finalOffset = correctOffset(cas.getDocumentText().length());
    Type tokenType = cas.getTypeSystem().getType(tokenTypeString);
    iterator = cas.getAnnotationIndex(tokenType).iterator();
}
Also used : Type(org.apache.uima.cas.Type) ResourceInitializationException(org.apache.uima.resource.ResourceInitializationException) IOException(java.io.IOException) AnalysisEngineProcessException(org.apache.uima.analysis_engine.AnalysisEngineProcessException)

Example 3 with ResourceInitializationException

use of org.apache.uima.resource.ResourceInitializationException in project lucene-solr by apache.

the class UIMATypeAwareAnnotationsTokenizer method initializeIterator.

@Override
protected void initializeIterator() throws IOException {
    try {
        analyzeInput();
    } catch (AnalysisEngineProcessException | ResourceInitializationException e) {
        throw new IOException(e);
    }
    featurePath = cas.createFeaturePath();
    try {
        featurePath.initialize(typeAttributeFeaturePath);
    } catch (CASException e) {
        featurePath = null;
        throw new IOException(e);
    }
    finalOffset = correctOffset(cas.getDocumentText().length());
    Type tokenType = cas.getTypeSystem().getType(tokenTypeString);
    iterator = cas.getAnnotationIndex(tokenType).iterator();
}
Also used : Type(org.apache.uima.cas.Type) ResourceInitializationException(org.apache.uima.resource.ResourceInitializationException) IOException(java.io.IOException) CASException(org.apache.uima.cas.CASException) AnalysisEngineProcessException(org.apache.uima.analysis_engine.AnalysisEngineProcessException)

Example 4 with ResourceInitializationException

use of org.apache.uima.resource.ResourceInitializationException in project lucene-solr by apache.

the class UIMAUpdateRequestProcessorFactory method getInstance.

@Override
public UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next) {
    SolrUIMAConfiguration configuration = new SolrUIMAConfigurationReader(args).readSolrUIMAConfiguration();
    synchronized (this) {
        if (ae == null && pool == null) {
            AEProvider aeProvider = AEProviderFactory.getInstance().getAEProvider(req.getCore().getName(), configuration.getAePath(), configuration.getRuntimeParameters());
            try {
                ae = aeProvider.getAE();
                pool = new JCasPool(10, ae);
            } catch (ResourceInitializationException e) {
                throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
            }
        }
    }
    return new UIMAUpdateRequestProcessor(next, req.getCore().getName(), configuration, ae, pool);
}
Also used : AEProvider(org.apache.lucene.analysis.uima.ae.AEProvider) ResourceInitializationException(org.apache.uima.resource.ResourceInitializationException) JCasPool(org.apache.uima.util.JCasPool) SolrException(org.apache.solr.common.SolrException)

Example 5 with ResourceInitializationException

use of org.apache.uima.resource.ResourceInitializationException in project deeplearning4j by deeplearning4j.

the class ConcurrentTokenizer method initialize.

/**
     * Initializes the current instance with the given context.
     *
     * Note: Do all initialization in this method, do not use the constructor.
     */
public void initialize(UimaContext context) throws ResourceInitializationException {
    super.initialize(context);
    TokenizerModel model;
    try {
        TokenizerModelResource modelResource = (TokenizerModelResource) context.getResourceObject(UimaUtil.MODEL_PARAMETER);
        model = modelResource.getModel();
    } catch (ResourceAccessException e) {
        throw new ResourceInitializationException(e);
    }
    tokenizer = new TokenizerME(model);
}
Also used : ResourceInitializationException(org.apache.uima.resource.ResourceInitializationException) TokenizerModelResource(opennlp.uima.tokenize.TokenizerModelResource) TokenizerME(opennlp.tools.tokenize.TokenizerME) TokenizerModel(opennlp.tools.tokenize.TokenizerModel) ResourceAccessException(org.apache.uima.resource.ResourceAccessException)

Aggregations

ResourceInitializationException (org.apache.uima.resource.ResourceInitializationException)8 IOException (java.io.IOException)4 AnalysisEngineProcessException (org.apache.uima.analysis_engine.AnalysisEngineProcessException)3 Type (org.apache.uima.cas.Type)2 ResourceAccessException (org.apache.uima.resource.ResourceAccessException)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 POSModel (opennlp.tools.postag.POSModel)1 POSTaggerME (opennlp.tools.postag.POSTaggerME)1 TokenizerME (opennlp.tools.tokenize.TokenizerME)1 TokenizerModel (opennlp.tools.tokenize.TokenizerModel)1 POSModelResource (opennlp.uima.postag.POSModelResource)1 TokenizerModelResource (opennlp.uima.tokenize.TokenizerModelResource)1 IRI (org.apache.clerezza.commons.rdf.IRI)1 AEProvider (org.apache.lucene.analysis.uima.ae.AEProvider)1 SolrException (org.apache.solr.common.SolrException)1 FeatureStructure (org.apache.stanbol.commons.caslight.FeatureStructure)1 FeatureStructureListHolder (org.apache.stanbol.commons.caslight.FeatureStructureListHolder)1 Blob (org.apache.stanbol.enhancer.servicesapi.Blob)1 EngineException (org.apache.stanbol.enhancer.servicesapi.EngineException)1