new opennlp.tools.lemmatizer.LemmatizerME(model), missclassifiedListener, reportListener);
@Before public void startup() throws IOException { // train the lemmatizer ObjectStream<LemmaSample> sampleStream = new LemmaSampleStream( new PlainTextByLineStream(new MockInputStreamFactory( new File("opennlp/tools/lemmatizer/trial.old.tsv")), "UTF-8")); TrainingParameters params = new TrainingParameters(); params.put(TrainingParameters.ITERATIONS_PARAM, 100); params.put(TrainingParameters.CUTOFF_PARAM, 5); LemmatizerModel lemmatizerModel = LemmatizerME.train("eng", sampleStream, params, new LemmatizerFactory()); this.lemmatizer = new LemmatizerME(lemmatizerModel); }
.load(new File(args[0])); LemmatizerME lemmatizer = new LemmatizerME(model);
private double trainAndEval(String lang, File trainFile, TrainingParameters params, File evalFile) throws IOException { ConlluTagset tagset = ConlluTagset.X; ObjectStream<LemmaSample> trainSamples = new ConlluLemmaSampleStream(new ConlluStream( new MarkableFileInputStreamFactory(trainFile)), tagset); LemmatizerModel model = LemmatizerME.train(lang, trainSamples, params, new LemmatizerFactory()); LemmatizerEvaluator evaluator = new LemmatizerEvaluator(new LemmatizerME(model)); evaluator.evaluate(new ConlluLemmaSampleStream(new ConlluStream( new MarkableFileInputStreamFactory(evalFile)), tagset)); return evaluator.getWordAccuracy(); }
@Override protected LemmatizerME produceResource(InputStream aStream) throws Exception { // Load the lemmatizer model from the location the model provider offers LemmatizerModel model = new LemmatizerModel(aStream); // Create a new POS tagger instance from the loaded model return new LemmatizerME(model); } };
/** * Creates a new model-based lemmatizer. * @param modelPath The full path to the directory containing the model. * @param modelManifest The {@link StandardModelManifest manifest} of the lemmatizer model. * @param validator The {@link ModelValidator} used to validate the model. * @throws ModelLoaderException Thrown if the model cannot be loaded. */ public DefaultLemmatizer(String modelPath, StandardModelManifest modelManifest, ModelValidator validator) throws ModelLoaderException { isModelBased = true; LocalModelLoader<LemmatizerModel> lemmaModelLoader = new LocalModelLoader<LemmatizerModel>(validator, modelPath); LemmatizerModel model = lemmaModelLoader.getModel(modelManifest, LemmatizerModel.class); lemmatizer = new LemmatizerME(model); }
new opennlp.tools.lemmatizer.LemmatizerME(model), missclassifiedListener, reportListener);
new opennlp.tools.lemmatizer.LemmatizerME(model), missclassifiedListener, reportListener);
.load(new File(args[0])); LemmatizerME lemmatizer = new LemmatizerME(model);
.load(new File(args[0])); LemmatizerME lemmatizer = new LemmatizerME(model);