Skip to content

OPENNLP-1220: Add support for Byte Pair Encoding (BPE)#1011

Merged
mawiesne merged 5 commits intomainfrom
OPENNLP-1220
Apr 7, 2026
Merged

OPENNLP-1220: Add support for Byte Pair Encoding (BPE)#1011
mawiesne merged 5 commits intomainfrom
OPENNLP-1220

Conversation

@mawiesne
Copy link
Copy Markdown
Contributor

@mawiesne mawiesne commented Apr 2, 2026

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 main)?

  • 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 GitHub Actions for build issues and submit an update to your PR as soon as possible.

@mawiesne mawiesne requested review from atarora and jzonthemtn April 2, 2026 14:16
@mawiesne mawiesne added the java Pull requests that update Java code label Apr 2, 2026
@mawiesne mawiesne marked this pull request as ready for review April 2, 2026 14:16
Copy link
Copy Markdown
Contributor Author

@mawiesne mawiesne left a comment

Choose a reason for hiding this comment

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

@rzo1 I've left comments for improvements and changes/additions. Some of which we should discuss.

Comment thread opennlp-core/opennlp-runtime/src/main/java/opennlp/tools/tokenize/BPEModel.java Outdated
rzo1 added 2 commits April 7, 2026 09:56
  - Use Collections.unmodifiableList() for BPEModel.getMerges()
  - Replace NullPointerException with IllegalArgumentException for input validation
  - Remove getMerges() from BPETokenizerFactory, access merges via model directly
  - Implement Trainer<Parameters> interface in BPETokenizerTrainer
  - Use InvalidFormatException instead of IOException for invalid merge lines
  - Add Javadoc to encodeToBPE(), applyMerges(), learnMerges(), applyMerge()
  - Document BufferedWriter/OutputStream ownership in BPEMergesSerializer
  - Refactor BPEModelTest into abstract base + EN/DE/FR test classes
  - Refactor BPETokenizerRealisticTest into abstract base + EN/DE/FR/IT/ES test classes
  - Use try-with-resources for ByteArrayOutputStream in tests
  - Fix German grammar: "die Monographie" (feminine article)
  - Use Collections.unmodifiableList() for BPEModel.getMerges()
  - Move merges storage from BPETokenizerFactory into BPEModel artifact map
  - Remove merges field and getMerges() from BPETokenizerFactory
  - Replace NullPointerException with IllegalArgumentException for input validation
  - Implement Trainer<Parameters> interface in BPETokenizerTrainer
  - Use InvalidFormatException for invalid merge lines in BPEMergesSerializer
  - Add Javadoc to encodeToBPE(), applyMerges(), learnMerges(), applyMerge()
  - Document BufferedWriter/OutputStream ownership in BPEMergesSerializer
  - Refactor BPEModelTest into abstract base + EN/DE/FR test classes
  - Refactor BPETokenizerRealisticTest into abstract base + EN/DE/FR/IT/ES
  - Use try-with-resources for ByteArrayOutputStream in tests
  - Fix German grammar (die Monographie) and use proper accents (ä/ö/ü/ß/é/ñ
@mawiesne mawiesne merged commit 97f97b6 into main Apr 7, 2026
9 checks passed
@mawiesne mawiesne deleted the OPENNLP-1220 branch April 7, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

java Pull requests that update Java code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants