SequenceClassificationModel<String> seqPosModel = null; if (TrainerType.EVENT_MODEL_TRAINER.equals(trainerType)) { ObjectStream<Event> es = new POSSampleEventStream(samples, contextGenerator);
/** * Tests that the outcomes for a single sentence match the * expected outcomes. */ @Test public void testOutcomesForSingleSentence() throws Exception { String sentence = "That_DT sounds_VBZ good_JJ ._."; POSSample sample = POSSample.parse(sentence); try (ObjectStream<Event> eventStream = new POSSampleEventStream( ObjectStreamUtils.createObjectStream(sample))) { Assert.assertEquals("DT", eventStream.read().getOutcome()); Assert.assertEquals("VBZ", eventStream.read().getOutcome()); Assert.assertEquals("JJ", eventStream.read().getOutcome()); Assert.assertEquals(".", eventStream.read().getOutcome()); Assert.assertNull(eventStream.read()); } } }
/** * * @param samples * @param tagDictionary * @param ngramDictionary * @param cutoff * * @throws IOException its throws if an {@link IOException} is thrown * during IO operations on a temp file which is created during training occur. */ public static POSModel train(String languageCode, ObjectStream<POSSample> samples, POSDictionary tagDictionary, Dictionary ngramDictionary, int cutoff, int iterations) throws IOException { GISModel posModel = opennlp.maxent.GIS.trainModel(iterations, new TwoPassDataIndexer(new POSSampleEventStream(samples, new DefaultPOSContextGenerator(ngramDictionary)), cutoff)); return new POSModel(languageCode, posModel, tagDictionary, ngramDictionary); }
if (encoding == null) { if (dict == null) { es = new POSSampleEventStream(new WordTagSampleStream(( new InputStreamReader(new FileInputStream(inFile))))); POSContextGenerator cg = new DefaultPOSContextGenerator(new Dictionary(new FileInputStream(dict))); es = new POSSampleEventStream(new WordTagSampleStream(( new InputStreamReader(new FileInputStream(inFile)))), cg); if (dict == null) { es = new POSSampleEventStream(new WordTagSampleStream(( new InputStreamReader(new FileInputStream(inFile), encoding)))); POSContextGenerator cg = new DefaultPOSContextGenerator(new Dictionary(new FileInputStream(dict))); es = new POSSampleEventStream(new WordTagSampleStream(( new InputStreamReader(new FileInputStream(inFile), encoding))), cg);
SequenceClassificationModel<String> seqPosModel = null; if (TrainerType.EVENT_MODEL_TRAINER.equals(trainerType)) { ObjectStream<Event> es = new POSSampleEventStream(samples, contextGenerator);
SequenceClassificationModel<String> seqPosModel = null; if (TrainerType.EVENT_MODEL_TRAINER.equals(trainerType)) { ObjectStream<Event> es = new POSSampleEventStream(samples, contextGenerator);