Skip to content

OPENNLP-1885: Add the SentencePiece subword add-on - #184

Draft
krickert wants to merge 4 commits into
mainfrom
OPENNLP-1885-subword
Draft

krickert wants to merge 4 commits into
mainfrom
OPENNLP-1885-subword

Conversation

@krickert

Copy link
Copy Markdown
Contributor

Replaces #178, which GitHub closed when the base branch was removed on the #183 merge. This one is based on main and headed from apache/opennlp-addons, so committers can push to it.

The first add-on under the layout #183 established.

What it is

A pure JVM SentencePiece tokenizer implementing SubwordTokenizer from opennlp-api. Unigram and BPE models, the SentencePiece normalizer, byte fallback, and a double-array trie for piece lookup. No native library and no JNI.

Conventions from #183

Group org.apache.opennlp.addons, artifact id subword with no suffix, and a description. RAT skips the generated test fixtures, which are TSV and plain text with no comment syntax; the .model binaries need no entry, because RAT identifies them as binary.

Why this is a draft

It needs SubwordTokenizer, which reached core after 3.0.0-M5. The module therefore resolves 3.0.0-SNAPSHOT from the ASF snapshot repository, already configured in the root POM. Per the manual's "Contributing an Add-on" chapter, a contribution that needs an unreleased core API remains a draft until it builds with a published artifact. Ready for review once a release with that interface exists.

No extra setup is required to build it now, since the snapshot resolves from repository.apache.org.

Verification

mvn clean verify -Dopennlp.forkCount=1

Every module passes. The subword module runs 66 tests with 0 failures and 1 skipped, that being the real-model evaluation, which needs a model outside the repository. RAT clean, and the dependency license report is generated.

A pure JVM SentencePiece tokenizer implementing the SubwordTokenizer
interface from opennlp-api. Unigram and BPE models, the SentencePiece
normalizer, byte fallback, and a double-array trie for piece lookup.

The module follows the repository conventions: group org.apache.opennlp.addons,
an artifact id without a suffix, and a description. RAT skips the generated
test fixtures, which are TSV and plain text formats with no comment syntax.

This needs SubwordTokenizer, which landed in core after 3.0.0-M5, so the module
resolves the OpenNLP snapshot from the ASF repository and remains a draft until
a release with that interface is published.

66 tests, one skipped: the real-model evaluation needs a model that is not
part of the repository.
@krickert
krickert marked this pull request as ready for review September 10, 2026 00:28
@krickert

krickert commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

The add-ons build is a 3.0.0-SNAPSHOT, so a snapshot dependency on core is consistent. Snapshot-to-snapshot resolution is ordinary Maven practice; the restriction applies at release time, where maven-release-plugin rejects non-released dependencies.

The core snapshot resolves from repository.apache.org through the apache.snapshots repository that the root POM already configures, so reviewing or building this needs no local build of core.

Only subword/pom.xml overrides opennlp.version. The other modules remain on 3.0.0-M5 and remain releasable. That override becomes a released version before any add-ons release.

@krickert
krickert marked this pull request as draft September 10, 2026 00:40
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.

1 participant