You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@opennlp.apache.org by GitBox <gi...@apache.org> on 2020/12/17 08:16:05 UTC
[GitHub] [opennlp] kinow commented on a change in pull request #386: OPENNLP-1319: The Training API code is outdated in Manual
kinow commented on a change in pull request #386:
URL: https://github.com/apache/opennlp/pull/386#discussion_r544889034
##########
File path: opennlp-docs/src/docbkx/namefinder.xml
##########
@@ -506,8 +506,8 @@ System.out.println(result.toString());]]>
To perform cross validation the ObjectStream must be resettable.
<programlisting language="java">
<![CDATA[
-FileInputStream sampleDataIn = new FileInputStream("en-ner-person.train");
-ObjectStream<NameSample> sampleStream = new PlainTextByLineStream(sampleDataIn.getChannel(), StandardCharsets.UTF_8);
+InputStreamFactory dataIn = new MarkableFileInputStreamFactory(new File("en-ner-person.train"));
+ObjectStream<NameSample> sampleStream = new PlainTextByLineStream(dataIn, StandardCharsets.UTF_8);
Review comment:
I think `PlainTextByLineStream` is (at least on `master`) an `ObjectStream<String>`. So the code with `NameSample` as generic type doesn't compile?
##########
File path: opennlp-docs/src/docbkx/doccat.xml
##########
@@ -127,14 +127,14 @@ $ opennlp DoccatTrainer -model en-doccat.bin -lang en -data en-doccat.train -enc
<programlisting language="java">
<![CDATA[
DoccatModel model = null;
-InputStream dataIn = null;
+InputStreamFactory dataIn = null;
-try (dataIn = new FileInputStream("en-sentiment.train")) {
+try (dataIn = new MarkableFileInputStreamFactory(new File("en-sentiment.train"))) {
Review comment:
It didn't compile for me. I tried to move the declaration to a single statement, but that also didn't work. It complained that `InputStreamFactory` is not a closeable? Did you try this code @Alanscut ? I think we need some sort of input stream here, not the factory being open/closed?
##########
File path: opennlp-docs/src/docbkx/postagger.xml
##########
@@ -206,11 +206,11 @@ $ opennlp POSTaggerTrainer -type maxent -model en-pos-maxent.bin \
<![CDATA[
POSModel model = null;
-try (InputStream dataIn = new FileInputStream("en-pos.train")){
+try (InputStreamFactory dataIn = new MarkableFileInputStreamFactory(new File("en-pos.train"))){
Review comment:
`InputStreamFactory` is not autocloseable?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org