Example usage for opennlp.tools.namefind TokenNameFinderFactory TokenNameFinderFactory

List of usage examples for opennlp.tools.namefind TokenNameFinderFactory TokenNameFinderFactory

Introduction

In this page you can find the example usage for opennlp.tools.namefind TokenNameFinderFactory TokenNameFinderFactory.

Prototype

public TokenNameFinderFactory(byte[] featureGeneratorBytes, final Map<String, Object> resources,
            SequenceCodec<String> seqCodec) 

Source Link

Usage

From source file:de.tudarmstadt.ukp.dkpro.core.opennlp.OpenNlpNamedEntityRecognizerTrainer.java

@Override
public void initialize(UimaContext aContext) throws ResourceInitializationException {
    super.initialize(aContext);

    stream = new CasNameSampleStream();

    TrainingParameters params = new TrainingParameters();
    params.put(TrainingParameters.ALGORITHM_PARAM, algorithm);
    //        params.put(TrainingParameters.TRAINER_TYPE_PARAM,
    //                TrainerFactory.getTrainerType(params.getSettings()).name());
    params.put(TrainingParameters.ITERATIONS_PARAM, Integer.toString(iterations));
    params.put(TrainingParameters.CUTOFF_PARAM, Integer.toString(cutoff));
    params.put(BeamSearch.BEAM_SIZE_PARAMETER, Integer.toString(beamSize));

    byte featureGenCfg[] = loadFeatureGen(featureGen);

    Callable<TokenNameFinderModel> trainTask = () -> {
        try {/*from  w  ww.j  a  va 2s  .co m*/
            return NameFinderME.train(language, null, stream, params, new TokenNameFinderFactory(featureGenCfg,
                    Collections.<String, Object>emptyMap(), sequenceEncoding.getCodec()));
        } catch (Throwable e) {
            stream.close();
            throw e;
        }
    };

    future = executor.submit(trainTask);
}