/** * Initializes the current instance. * * @param elements * @param numberOfPartitions */ public CrossValidationPartitioner(Collection<E> elements, int numberOfPartitions) { this(new CollectionObjectStream<>(elements), numberOfPartitions); }
/** * Checks if the {@link AbstractEventStream} behavior is correctly * if the {@link AbstractEventStream#createEvents(Object)} method * return iterators with events and empty iterators. */ @Test public void testStandardCase() throws IOException { List<RESULT> samples = new ArrayList<>(); samples.add(RESULT.EVENTS); samples.add(RESULT.EMPTY); samples.add(RESULT.EVENTS); try (TestEventStream eventStream = new TestEventStream(new CollectionObjectStream<>(samples))) { int eventCounter = 0; while (eventStream.read() != null) { eventCounter++; } Assert.assertEquals(2, eventCounter); } }
/** * Checks if the {@link AbstractEventStream} behavior is correctly * if the {@link AbstractEventStream#createEvents(Object)} method * only returns empty iterators. */ @Test public void testEmtpyEventStream() throws IOException { List<RESULT> samples = new ArrayList<>(); samples.add(RESULT.EMPTY); try (TestEventStream eventStream = new TestEventStream(new CollectionObjectStream<>(samples))) { Assert.assertNull(eventStream.read()); // now check if it can handle multiple empty event iterators samples.add(RESULT.EMPTY); samples.add(RESULT.EMPTY); } try (TestEventStream eventStream = new TestEventStream(new CollectionObjectStream<>(samples))) { Assert.assertNull(eventStream.read()); } }
/** * Initializes the current instance. * * @param elements * @param numberOfPartitions */ public CrossValidationPartitioner(Collection<E> elements, int numberOfPartitions) { this(new CollectionObjectStream<>(elements), numberOfPartitions); }
/** * Initializes the current instance. * * @param elements * @param numberOfPartitions */ public CrossValidationPartitioner(Collection<E> elements, int numberOfPartitions) { this(new CollectionObjectStream<>(elements), numberOfPartitions); }
static TokenizerModel createSimpleMaxentTokenModel() throws IOException { List<TokenSample> samples = new ArrayList<>(); samples.add(new TokenSample("year", new Span[]{new Span(0, 4)})); samples.add(new TokenSample("year,", new Span[]{ new Span(0, 4), new Span(4, 5)})); samples.add(new TokenSample("it,", new Span[]{ new Span(0, 2), new Span(2, 3)})); samples.add(new TokenSample("it", new Span[]{ new Span(0, 2)})); samples.add(new TokenSample("yes", new Span[]{ new Span(0, 3)})); samples.add(new TokenSample("yes,", new Span[]{ new Span(0, 3), new Span(3, 4)})); TrainingParameters mlParams = new TrainingParameters(); mlParams.put(TrainingParameters.ITERATIONS_PARAM, 100); mlParams.put(TrainingParameters.CUTOFF_PARAM, 0); return TokenizerME.train(new CollectionObjectStream<>(samples), TokenizerFactory.create(null, "eng", null, true, null), mlParams); }
new WordTagSampleStream(new CollectionObjectStream<>(sampleString))) { POSSample sample = stream.read(); String[] words = sample.getSentence();