Skip to content

Conversation

@Alanscut
Copy link
Contributor

Thank you for contributing to Apache OpenNLP.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced
    in the commit message?

  • Does your PR title start with OPENNLP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.

  • Has your PR been rebased against the latest commit within the target branch (typically master)?

  • Is your initial contribution a single, squashed commit?

For code changes:

  • Have you ensured that the full suite of tests is executed via mvn clean install at the root opennlp folder?
  • Have you written or updated unit tests to verify your changes?
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE file, including the main LICENSE file in opennlp folder?
  • If applicable, have you updated the NOTICE file, including the main NOTICE file found in opennlp folder?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered?

Note:

Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.

@jzonthemtn
Copy link
Contributor

@Alanscut Thanks for the pull request!

Copy link
Member

@kinow kinow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cloned the repository from GitHub, using the master branch. Then created an extra Maven project, and added the snapshot as dependency. After everything was built, started testing each code changed in this PR.

Found a few lines that didn't compile. Tried setting JVM to 8+, but I think the issues are legit. Will wait for @Alanscut 's feedback, but other than that, looks like a good improvement.

Thanks @Alanscut !

InputStreamFactory dataIn = null;
try (dataIn = new FileInputStream("en-sentiment.train")) {
try (dataIn = new MarkableFileInputStreamFactory(new File("en-sentiment.train"))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think PlainTextByLineStream is (at least on master) an ObjectStream<String>. So the code with NameSample as generic type doesn't compile?

POSModel model = null;
try (InputStream dataIn = new FileInputStream("en-pos.train")){
try (InputStreamFactory dataIn = new MarkableFileInputStreamFactory(new File("en-pos.train"))){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InputStreamFactory is not autocloseable?

@Alanscut
Copy link
Contributor Author

Sorry I didn't notice that is try-with-resources statement insteadof try-catch block, update now

Copy link
Member

@kinow kinow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Alanscut thanks for updating the code! There's only one last thing, but I might be nit-picking. Now the factories are created as expected, but with the variable name dataIn. The constructor of the classes that take a factory are clear with the variable name (e.g. inputStreamFactory). Perhaps we should rename the variable in the examples too, but happy with the changes as-is too.

@jzonthemtn jzonthemtn merged commit 6c439ae into apache:master Mar 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants