[
https://issues.apache.org/jira/browse/OPENNLP-1319?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17250887#comment-17250887
]
ASF GitHub Bot commented on OPENNLP-1319:
-----------------------------------------
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:
[email protected]
> The Training API code is outdated in Manual
> -------------------------------------------
>
> Key: OPENNLP-1319
> URL: https://issues.apache.org/jira/browse/OPENNLP-1319
> Project: OpenNLP
> Issue Type: Documentation
> Reporter: Alan Wang
> Priority: Major
>
> {code:java}
> POSModel model = null;
> try (InputStream dataIn = new FileInputStream("en-pos.train")){
> ObjectStream<String> lineStream = new PlainTextByLineStream(dataIn,
> StandardCharsets.UTF_8);
> ObjectStream<POSSample> sampleStream = new WordTagSampleStream(lineStream);
> model = POSTaggerME.train("en", sampleStream,
> TrainingParameters.defaultParams(), null, null);
> }
> {code}
> 1、PlainTextByLineStream use InputStreamFactory now.
> 2、Update parameters of the train method.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)