@Test(expected = InsufficientTrainingDataException.class) public void insufficientTestData() throws IOException { ObjectStream<DocumentSample> samples = ObjectStreamUtils.createObjectStream( new DocumentSample("1", new String[]{"a", "b", "c"})); TrainingParameters params = new TrainingParameters(); params.put(TrainingParameters.ITERATIONS_PARAM, 100); params.put(TrainingParameters.CUTOFF_PARAM, 0); DocumentCategorizerME.train("x-unspecified", samples, params, new DoccatFactory()); }
public static DoccatModel train(String languageCode, ObjectStream<DocumentSample> samples, TrainingParameters mlParams, DoccatFactory factory) throws IOException { Map<String, String> manifestInfoEntries = new HashMap<>(); EventTrainer trainer = TrainerFactory.getEventTrainer( mlParams, manifestInfoEntries); MaxentModel model = trainer.train( new DocumentCategorizerEventStream(samples, factory.getFeatureGenerators())); return new DoccatModel(languageCode, model, manifestInfoEntries, factory); }
DocumentCategorizerME implements DocumentCategorizer { public static DoccatModel train(String languageCode, ObjectStream<DocumentSample> samples, TrainingParameters mlParams, DoccatFactory factory) throws IOException { Map<String, String> manifestInfoEntries = new HashMap<>(); EventTrainer trainer = TrainerFactory.getEventTrainer( mlParams, manifestInfoEntries); MaxentModel model = trainer.train( new DocumentCategorizerEventStream(samples, factory.getFeatureGenerators())); return new DoccatModel(languageCode, model, manifestInfoEntries, factory); } }
DocumentCategorizerME implements DocumentCategorizer { public static DoccatModel train(String languageCode, ObjectStream<DocumentSample> samples, TrainingParameters mlParams, DoccatFactory factory) throws IOException { Map<String, String> manifestInfoEntries = new HashMap<>(); EventTrainer trainer = TrainerFactory.getEventTrainer( mlParams, manifestInfoEntries); MaxentModel model = trainer.train( new DocumentCategorizerEventStream(samples, factory.getFeatureGenerators())); return new DoccatModel(languageCode, model, manifestInfoEntries, factory); } DocumentCategorizerME(DoccatModel model); }
DocumentCategorizerME implements DocumentCategorizer { public static DoccatModel train(String languageCode, ObjectStream<DocumentSample> samples, TrainingParameters mlParams, DoccatFactory factory) throws IOException { Map<String, String> manifestInfoEntries = new HashMap<>(); EventTrainer trainer = TrainerFactory.getEventTrainer( mlParams, manifestInfoEntries); MaxentModel model = trainer.train( new DocumentCategorizerEventStream(samples, factory.getFeatureGenerators())); return new DoccatModel(languageCode, model, manifestInfoEntries, factory); } DocumentCategorizerME(DoccatModel model); @Override double[] categorize(String[] text, Map<String, Object> extraInformation); @Override double[] categorize(String[] text); @Override Map<String, Double> scoreMap(String[] text); @Override SortedMap<Double, Set<String>> sortedScoreMap(String[] text); String getBestCategory(double[] outcome); int getIndex(String category); String getCategory(int index); int getNumberOfCategories(); String getAllResults(double[] results); static DoccatModel train(String languageCode, ObjectStream<DocumentSample> samples,
      TrainingParameters mlParams, DoccatFactory factory); }
DocumentCategorizerME implements DocumentCategorizer { public static DoccatModel train(String languageCode, ObjectStream<DocumentSample> samples, TrainingParameters mlParams, DoccatFactory factory) throws IOException { Map<String, String> manifestInfoEntries = new HashMap<>(); EventTrainer trainer = TrainerFactory.getEventTrainer( mlParams, manifestInfoEntries); MaxentModel model = trainer.train( new DocumentCategorizerEventStream(samples, factory.getFeatureGenerators())); return new DoccatModel(languageCode, model, manifestInfoEntries, factory); } DocumentCategorizerME(DoccatModel model); @Override double[] categorize(String[] text, Map<String, Object> extraInformation); @Override double[] categorize(String[] text); @Override Map<String, Double> scoreMap(String[] text); @Override SortedMap<Double, Set<String>> sortedScoreMap(String[] text); String getBestCategory(double[] outcome); int getIndex(String category); String getCategory(int index); int getNumberOfCategories(); String getAllResults(double[] results); static DoccatModel train(String languageCode, ObjectStream<DocumentSample> samples,
      TrainingParameters mlParams, DoccatFactory factory);  }