Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPENNLP-1285: Fix Java 8 vs 11 test inconsistencies #377

Merged
merged 1 commit into from
Jun 10, 2020

Conversation

jzonthemtn
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 jzonthemtn changed the title Fix Java 8 vs 11 test inconsistencies OPENNLP-1285: Fix Java 8 vs 11 test inconsistencies Jun 4, 2020
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.

Looks good to me. I wonder what's the performance penalty for this change? Hopefully small enough that it compensates to have the builds more reproducible. 👍

@@ -410,7 +410,7 @@ public void evalParserModel() throws Exception {
}
}

Assert.assertEquals(new BigInteger("312218841713337505306598301082074515847"),
Assert.assertEquals(new BigInteger("68039262350771988792233880373220954061"),
Copy link
Member

Choose a reason for hiding this comment

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

The change of precision in the other tests was small compared to this one. This was the only thing that got my eye from reading the changes here. Pretty much everything else appears to be just s/Math/StrictMath.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will double-check that one and make sure that value is correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kinow This number changed a lot because it is an MD5 hash value. Looks like the test is using the parser chunking model to parse the leipzig/eng_news_2010_300K-sentences.txt input file. At the end it computes the hash of the parse string and compares it to an expected value.

StrictMath must be causing a difference that's visible in the hash value. I'm guessing it's probably like those other tests where it's a small rounding difference somewhere.

I did verify that 68039262350771988792233880373220954061 is the same value on Java 8 and Java 11.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, got it @jzonthemtn , had no idea it was a md5 hash. All good then 🥇 👍

Copy link
Member

@kottmann kottmann left a comment

Choose a reason for hiding this comment

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

+1 lgtm. I performed a test with the tokenizer to see if this changes makes it slower, the runtime was almost identical and I didn't notice a slow down. The change is a big win if this helps to make test run more reliable across JVM versions and different CPUs.

@jzonthemtn
Copy link
Contributor Author

This also fixed OPENNLP-1113.

@jzonthemtn jzonthemtn merged commit 7c10174 into apache:master Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants