rzo1 commented on code in PR #742: URL: https://github.com/apache/opennlp/pull/742#discussion_r1922529947
########## opennlp-tools/src/main/java/opennlp/tools/formats/BioNLP2004NameSampleStreamFactory.java: ########## @@ -30,55 +29,56 @@ /** * @see BioNLP2004NameSampleStream */ -public class BioNLP2004NameSampleStreamFactory<P> extends AbstractSampleStreamFactory<NameSample, P> { +public class BioNLP2004NameSampleStreamFactory extends + AbstractSampleStreamFactory<NameSample, BioNLP2004NameSampleStreamFactory.Parameters> { - interface Parameters extends BasicFormatParams { + public interface Parameters extends BasicFormatParams { @ParameterDescription(valueName = "DNA,protein,cell_type,cell_line,RNA") String getTypes(); } public static void registerFactory() { StreamFactoryRegistry.registerFactory(NameSample.class, - "bionlp2004", new BioNLP2004NameSampleStreamFactory<>(Parameters.class)); + "bionlp2004", new BioNLP2004NameSampleStreamFactory(Parameters.class)); } - protected BioNLP2004NameSampleStreamFactory(Class<P> params) { + protected BioNLP2004NameSampleStreamFactory(Class<Parameters> params) { super(params); } @Override public ObjectStream<NameSample> create(String[] args) { - - Parameters params = ArgumentParser.parse(args, Parameters.class); + Parameters params = validateBasicFormatParameters(args, Parameters.class); int typesToGenerate = 0; - - if (params.getTypes().contains("DNA")) { + String types = params.getTypes(); Review Comment: This test would be green regardless of the else cascade because it just checks for `null`. Maybe update to ```java @Test void testCreateWithValidParameter() throws IOException { try (ObjectStream<NameSample> stream = factory.create( new String[]{"-types", "DNA,protein,cell_type,cell_line,RNA", "-data", sampleFileFullPath})) { NameSample sample = stream.read(); assertNotNull(sample); assertEquals(5, sample.getNames().length); assertEquals("protein", sample.getNames()[0].getType()); assertEquals("protein", sample.getNames()[1].getType()); assertEquals("protein", sample.getNames()[2].getType()); assertEquals("protein", sample.getNames()[3].getType()); assertEquals("cell_type", sample.getNames()[4].getType()); } } ``` to check for the assumption from the given sample file as well. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@opennlp.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org