public void run(String[] args) { if (args.length != 2) { System.out.println(getHelp()); } else { File parserModelInFile = new File(args[0]); ParserModel parserModel = new ParserModelLoader().load(parserModelInFile); File taggerModelInFile = new File(args[1]); POSModel taggerModel = new POSModelLoader().load(taggerModelInFile); ParserModel updatedParserModel = parserModel.updateTaggerModel(taggerModel); CmdLineUtil.writeModel("parser", parserModelInFile, updatedParserModel); } } }
System.out.println(); CmdLineUtil.writeModel("name finder", modelOutFile, model);
CmdLineUtil.writeModel("parser", modelFile, updatedParserModel);
public boolean writeModel(String path) { File outFile = new File(path + ".wsd.model"); CmdLineUtil.writeModel("wsd model", outFile, this); return true; }
CmdLineUtil.writeModel("language detector", modelOutFile, model);
public void run(String format, String[] args) { super.run(format, args); mlParams = CmdLineUtil.loadTrainingParameters(params.getParams(), false); if (mlParams == null) { mlParams = ModelUtil.createDefaultTrainingParameters(); } File modelOutFile = params.getModel(); CmdLineUtil.checkOutputFile("lemmatizer model", modelOutFile); LemmatizerModel model; try { LemmatizerFactory lemmatizerFactory = LemmatizerFactory .create(params.getFactory()); model = LemmatizerME.train(params.getLang(), sampleStream, mlParams, lemmatizerFactory); } catch (IOException e) { throw createTerminationIOException(e); } finally { try { sampleStream.close(); } catch (IOException e) { // sorry that this can fail } } CmdLineUtil.writeModel("lemmatizer", modelOutFile, model); } }
CmdLineUtil.writeModel("chunker", modelOutFile, model);
@Override public void run(String format, String[] args) { super.run(format, args); mlParams = CmdLineUtil.loadTrainingParameters(params.getParams(), false); if (mlParams == null) { mlParams = ModelUtil.createDefaultTrainingParameters(); } File modelOutFile = params.getModel(); CmdLineUtil.checkOutputFile("document categorizer model", modelOutFile); FeatureGenerator[] featureGenerators = createFeatureGenerators(params .getFeatureGenerators()); DoccatModel model; try { DoccatFactory factory = DoccatFactory.create(params.getFactory(), featureGenerators); model = DocumentCategorizerME.train(params.getLang(), sampleStream, mlParams, factory); } catch (IOException e) { throw createTerminationIOException(e); } finally { try { sampleStream.close(); } catch (IOException e) { // sorry that this can fail } } CmdLineUtil.writeModel("document categorizer", modelOutFile, model); }
CmdLineUtil.writeModel("sentence detector", modelOutFile, model);
CmdLineUtil.writeModel("tokenizer", modelOutFile, model);
CmdLineUtil.writeModel("pos tagger", modelOutFile, model);
public static void main(String[] args) { if (args.length < 2) { System.out.println("usage: <input> <output>\n"); System.exit(0); } String input = args[0]; String output = args[1]; TrainingParameters params = new TrainingParameters(); params.put(TrainingParameters.CUTOFF_PARAM, Integer.toString(0)); params.put(TrainingParameters.ITERATIONS_PARAM, Integer.toString(100)); //params.put(TrainingParameters.ALGORITHM_PARAM, NaiveBayesTrainer.NAIVE_BAYES_VALUE); AgeClassifyModel model; try { model = AgeClassifySparkTrainer.createModel("en", input, "opennlp.tools.tokenize.SentenceTokenizer", "opennlp.tools.tokenize.BagOfWordsTokenizer", params); } catch (IOException e) { throw new TerminateToolException(-1, "IO error while reading training data or indexing data: " + e.getMessage(), e); } CmdLineUtil.writeModel("age classifier", new File(output), model); } }
CmdLineUtil.writeModel("parser", modelOutFile, model);
public void run(String[] args) { if (args.length != 2) { System.out.println(getHelp()); } else { File parserModelInFile = new File(args[0]); ParserModel parserModel = new ParserModelLoader().load(parserModelInFile); File taggerModelInFile = new File(args[1]); POSModel taggerModel = new POSModelLoader().load(taggerModelInFile); ParserModel updatedParserModel = parserModel.updateTaggerModel(taggerModel); CmdLineUtil.writeModel("parser", parserModelInFile, updatedParserModel); } } }
public void run(String[] args) { if (args.length != 2) { System.out.println(getHelp()); } else { File parserModelInFile = new File(args[0]); ParserModel parserModel = new ParserModelLoader().load(parserModelInFile); File taggerModelInFile = new File(args[1]); POSModel taggerModel = new POSModelLoader().load(taggerModelInFile); ParserModel updatedParserModel = parserModel.updateTaggerModel(taggerModel); CmdLineUtil.writeModel("parser", parserModelInFile, updatedParserModel); } } }
/** * Main access to the train functionalities. * * @throws IOException * input output exception if problems with corpora */ public final void train() throws IOException { // load training parameters file String paramFile = parsedArguments.getString("params"); TrainingParameters params = InputOutputUtils .loadTrainingParameters(paramFile); String outModel = null; if (params.getSettings().get("OutputModel") == null || params.getSettings().get("OutputModel").length() == 0) { outModel = Files.getNameWithoutExtension(paramFile) + ".bin"; params.put("OutputModel", outModel); } else { outModel = Flags.getModel(params); } Trainer nercTrainer = new FixedTrainer(params); TokenNameFinderModel trainedModel = nercTrainer.train(params); CmdLineUtil.writeModel("ixa-pipe-nerc", new File(outModel), trainedModel); }
CmdLineUtil.writeModel("language detector", modelOutFile, model);
public void run(String format, String[] args) { super.run(format, args); mlParams = CmdLineUtil.loadTrainingParameters(params.getParams(), false); if (mlParams == null) { mlParams = ModelUtil.createDefaultTrainingParameters(); } File modelOutFile = params.getModel(); CmdLineUtil.checkOutputFile("lemmatizer model", modelOutFile); LemmatizerModel model; try { LemmatizerFactory lemmatizerFactory = LemmatizerFactory .create(params.getFactory()); model = LemmatizerME.train(params.getLang(), sampleStream, mlParams, lemmatizerFactory); } catch (IOException e) { throw createTerminationIOException(e); } finally { try { sampleStream.close(); } catch (IOException e) { // sorry that this can fail } } CmdLineUtil.writeModel("lemmatizer", modelOutFile, model); } }
CmdLineUtil.writeModel("chunker", modelOutFile, model);
public void run(String format, String[] args) { super.run(format, args); mlParams = CmdLineUtil.loadTrainingParameters(params.getParams(), false); if (mlParams == null) { mlParams = ModelUtil.createDefaultTrainingParameters(); } File modelOutFile = params.getModel(); CmdLineUtil.checkOutputFile("lemmatizer model", modelOutFile); LemmatizerModel model; try { LemmatizerFactory lemmatizerFactory = LemmatizerFactory .create(params.getFactory()); model = LemmatizerME.train(params.getLang(), sampleStream, mlParams, lemmatizerFactory); } catch (IOException e) { throw createTerminationIOException(e); } finally { try { sampleStream.close(); } catch (IOException e) { // sorry that this can fail } } CmdLineUtil.writeModel("lemmatizer", modelOutFile, model); } }