Search in sources :

Example 1 with POSModelResource

use of opennlp.uima.postag.POSModelResource 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)

Aggregations

POSModel (opennlp.tools.postag.POSModel)1 POSTaggerME (opennlp.tools.postag.POSTaggerME)1 POSModelResource (opennlp.uima.postag.POSModelResource)1 ResourceAccessException (org.apache.uima.resource.ResourceAccessException)1 ResourceInitializationException (org.apache.uima.resource.ResourceInitializationException)1