Repository navigation
tokenize-uk 2.0: LanguageTool-grade engines by default, 2016 engines behind legacy=True - #13
Merged
Merged
Conversation
Apply 27 upstream commits of drift since the 2022-05-08 port (LT 510b8f97..0761ec3): new abbreviations in five patterns (спр, ап, бул, бульв, др, Ол, свт, Авг, ам, біол, болг, дир, іл, інж, кін, крим, нач, нім, нпр, оз, пом, порівн, рос, санскр, суч, цит, япон, дес, дол, пов, стст...), new нар./чл.-кор./web-entity handling, DATE_PATTERN removed, */_ handling moved into SPLIT_CHARS lookarounds, superscript digits split after Cyrillic, №/§/~/× now split, -20/–20 and +digits breaking, NUMBER_MISSING_SPACE simplified. Test file synced with upstream (578 -> 748 lines): 3 changed expectations, ~45 new cases incl. markdown, web entities and superscript suites. All 15 test methods pass. Also drop the stale commented-out Java block. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Verified byte-identical to LanguageTool master UkrainianWordTokenizer (compiled from source with a stubbed Tokenizer interface) on four real corpora: 3,871,085 tokens across Militarny (100k lines), uanews.dp.ua (133k lines), Liga.net and a 5k sample - zero differences, Python 1.3-4x faster than the Java driver. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
tokenize_words/tokenize_sents/tokenize_text keep their signatures and return shapes, now backed by choppa-srx sentence segmentation (uk_two) and the LT word tokenizer (whitespace tokens dropped to preserve the historical shape). legacy=True falls back to the 2016 regex engines, preserved byte-for-byte in tokenize_uk.legacy with type hints and docstrings (regexes re-expressed as raw strings with identical runtime bytes - kills py3.12 SyntaxWarnings). Old fixtures now pin the legacy engine; new-engine tests cover abbreviation-aware behavior the old engine could not do. Version 2.0.0. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- pyproject.toml (name tokenize_uk, deps regex + choppa-srx, py3.9-3.14),
py.typed, tokenize-uk console script (-l words|sents|text, --legacy)
- GitHub Actions: test matrix + tag-triggered PyPI trusted publishing
- README.md rewrite with the engine comparison and verification table;
docs/{api,design,history}.md; CHANGELOG.md; AUTHORS.md
- scripts/java-harness/: LT master UkrainianWordTokenizer compiled
against a stubbed Tokenizer interface + driver, for reproducible
byte-level differentials (scripts/benchmark.py --java)
- tests moved out of the package; 2016-era packaging (setup.py, tox,
travis, sphinx scaffolding) removed
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…I streaming - scripts/java-harness/README.md pins the LT sync commit (0761ec3ecea3e1030fcc391246a8c23d48c91e8d) with a fetch command and the output contract; design.md no longer claims the LGPL Java file is committed (it is fetched on demand) and references the anchor - tokenize_words drops invisible-character tokens (ZWSP family, bidi controls, BOM, soft hyphen) the LT engine emits as standalone tokens but the 2016 engine never did - shape parity for scraped web text; pinned by new tests - CLI -l words streams line by line: the whole-input path was quadratic on URL-bearing text (the URL placeholder loop rescans per URL; measured 89x at 4k lines) - tokenize_sents gains keyword-only language_code (uk_two default, uk_one for LT's single-line-break mode); legacy is keyword-only on all three functions - pipeline dedup: tokenize_text delegates to tokenize_sents/words with legacy passthrough (was a copy of the legacy loop); module-level stateless UkrainianWordTokenizer instead of a lazy getter; lru_cache for the SRX splitter incl. the per-call import - dead code from the 2022 port removed: DOTTED_NUMBERS_REPL (no Java counterpart), ABBR_DOT_INVALID_DOT_PATTERN/ABBR_DOT_PATTERN8 commented out to mirror the Java, 14-line commented Java block and stale TODOs dropped; test ceremony trimmed; benchmark.py skips rendering when neither --out nor --java is given - api.md/CHANGELOG: keyword-only args, accurate startup costs, 0.x physical-import-path note Verified: 27 tests green; word output still byte-identical to Java on 1.74M + 1.97M token corpora; CLI streaming output correct. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
90% -> 99% (the two remaining lines are the stdin-isatty notice and the __main__ guard). 33 tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- tokenize_words_with_spans / tokenize_sents_with_spans: exact character offsets for both engines (the raw LT token stream concatenates to the input, so a running offset is exact; legacy words via finditer, legacy sentences via ordered cursor search) - property tests (hypothesis): raw tokens concatenate to input, spans match input slices, spans agree with tokenize_words - for arbitrary Unicode outside the placeholder/normalization sets - CI java-identity job: fetches LT's UkrainianWordTokenizer.java pinned to the sync commit, compiles the harness, and byte-diffs the port on a committed CC BY-SA Wikipedia corpus (92,833 tokens) on every PR - weekly upstream-watch workflow opens an issue when LT's tokenizer moves past the pinned commit - the 27-commit silent drift cannot recur Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Git does not track empty directories, so the pinned-source curl had nowhere to write in a fresh checkout (exit 23). Also add -f so an HTTP error fails the step instead of compiling an error page. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…_pipeline pip install tokenize_uk[spacy] adds tokenize_uk.spacy: - UkrainianTokenizer: spaCy tokenizer backed by the LT word tokenizer (or the 2016 engine with legacy=True); doc.text round-trips the input exactly because the raw LT token stream concatenates to it. Registered as tokenize_uk.UkrainianTokenizer.v1, so config-built pipelines and spacy.load() reconstruct it (plain nlp.tokenizer assignment would not survive serialization). - tokenize_uk_sentencizer: sentence boundaries from choppa's SRX segmentation aligned to token offsets; config keys legacy and language_code. - blank_pipeline(): ready-to-use blank uk pipeline, fully serializable. - Entry points for spacy_factories and spacy_tokenizers; CI job running the integration tests with the extra installed; README/api.md docs. 46 tests green (5 spaCy tests skip cleanly when spaCy is absent). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ontracts - scripts/java-harness/LT_COMMIT is now the machine-readable sync pin; both workflows read and validate it (the old first-40-hex-in-README grep could silently repoint if any hash appeared earlier in prose); README/design.md reference the file instead of repeating the value - CANONICAL_SUBSTITUTIONS table in the tokenizer replaces five chained .replace calls (byte-identical behavior, re-verified vs Java on 1.97M + 92k tokens); the property-test alphabet now derives its exclusions from it instead of hand-mirroring invisible literals - content-token predicate extracted (_is_content_token) and shared by tokenize_words and the spans function; tokenize_sents derives from tokenize_sents_with_spans - each contract now has one definition - spacy.py uses only public API (own UkrainianWordTokenizer instance, legacy gaps via tokenize_words_with_spans) - no more _WORD_TOKENIZER or _legacy private imports; single sentencizer call; registry/spacy imports folded into the top guard; token.is_sent_start without re-indexing - tests: pytest.importorskip replaces the HAS_SPACY scaffolding, dead isatty patch dropped; pip cache on the spacy CI job Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
typer 0.26 stopped declaring click as a dependency while spaCy's CLI still imports it, so 'import spacy' fails on fresh installs. The old test scaffolding silently skipped in that situation (the CI job was green while testing nothing); pytest.importorskip's exit-5 exposed it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The entry points pointed at the bare module; spaCy's registry loads the entry-point value verbatim and later fails inspect.signature() on it. This only manifests when the package is installed (entry points active) - the uv-based local test envs never installed it, CI's pip install -e . did. Point both entry points at create_sentencizer / create_tokenizer, and add a test that spacy.load() works in a fresh process that never imported tokenize_uk.spacy (skipped when the package is not installed), so the entry-point contract is pinned. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The default path yielded the LT engine's token stream verbatim, so inputs with characters the engine canonicalizes 1:1 (U+2019 et al.) came back with ASCII apostrophes in doc.text, breaking the documented byte-exact roundtrip. Both engine paths now walk tokenize_words_with_spans and cut tokens from the input at the exact offsets (gaps become whitespace tokens), which also makes token text verbatim input. Found by ultrareview on PR #13. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Swept in by a git add -A; a published library has no use for a lockfile (CI installs via pip, consumers resolve their own deps). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 5, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Finishes what the
languagetoolsbranch started in 2022, using the methodology proven on choppa (lang-uk/choppa#6).What changed
нар./чл.-кор./web-entity handling,*/_markdown rules, superscripts,№/§splitting,-20/+20handling, and more. LT's current test suite ported (15 methods, all passing).scripts/java-harness/compiles LT master'sUkrainianWordTokenizer.javaagainst a stubbed interface (no Maven, no lagging release jars). Corpus differential: 3,871,085 tokens across four corpora — zero differences, Python 1.3–4x faster than the Java driver.tokenize_words/sents/textkeep their signatures and return shapes, now backed by the LT word tokenizer + choppa-srx sentences (uk_two).legacy=True(ortokenize_uk.legacy) reproduces the 2016 behavior exactly — old fixtures pin it in CI.tokenize-ukCLI, CI matrix 3.9–3.14, tag-triggered trusted publishing, docs (api/design/history), benchmark + harness inscripts/.24 tests green. To release after merge: configure the trusted publisher for the existing
tokenize_ukPyPI project (repolang-uk/tokenize-uk, workflowrelease.yml, environmentpypi), then tagv2.0.0.🤖 Generated with Claude Code