Implement PyThaiNLP-compatible test_newmm with numeric pattern tokenization#9
Merged
wannaphong merged 3 commits intomainfrom Jan 11, 2026
Merged
Conversation
- Create newmm module with segment function for PyThaiNLP compatibility - Add keep_whitespace parameter support to word_tokenize - Fix numeric tokenization to handle patterns like 19..., 19., 19.84, etc. - Group consecutive same punctuation characters (e.g., ...) - Add missing word จุ๋ม to dictionary - All tests now pass including new test_newmm test Co-authored-by: wannaphong <8536487+wannaphong@users.noreply.github.com>
- Remove unused is_valid_numeric_continuation function - Fix import example in newmm.py docstring Co-authored-by: wannaphong <8536487+wannaphong@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix tests for newmm segment functionality
Implement PyThaiNLP-compatible test_newmm with numeric pattern tokenization
Jan 11, 2026
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.
Adds comprehensive test suite matching PyThaiNLP's newmm tokenization behavior, requiring fixes to numeric/punctuation handling and API compatibility.
Changes
API Compatibility
cthainlp.newmmmodule withsegment()function acceptingNone/empty inputskeep_whitespaceparameter toword_tokenize()(default:True)Numeric Pattern Tokenization (
src/newmm.c)"19..."→["19", "..."]instead of["19..."]"19.84"→["19.84"]"127.0.0.1"→["127.0.0.1"]"..."as single tokenImplementation uses lookahead to distinguish valid numeric patterns (decimal, IP) from punctuation boundaries.
Test Suite (
tests/python/test_tokenize.py)test_newmm()with 16 assertions covering edge cases, numeric patterns, whitespace handling, and special charactersDictionary
จุ๋มfor correct Thai tokenizationOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.