feat: add posseg (part-of-speech tagging) HMM for OOV words#146
Merged
Conversation
Implement a compound-state HMM Viterbi (4 positions × 64 POS tags = 256 states) for POS-tagging unknown/OOV Chinese words, ported from Python jieba's posseg module. - Add `posseg.rs` with dense 256×256 transition matrix for O(1) lookup - Embed probability data (start, trans, emit, char_state_tab) via `include_flate`, gated on `default-dict` feature - Improve `tag()` to use posseg HMM for OOV CJK words instead of falling back to `"x"` (e.g. `"张尧"` now correctly tagged as `"nr"`/person name) - Add conversion script (`scripts/convert_posseg.py`) for regenerating `posseg.txt` from Python jieba's pickle files - Add benchmark for `tag_with_oov` (~2.5µs per call)
Merging this PR will not alter performance
Performance Changes
Comparing |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #146 +/- ##
==========================================
+ Coverage 80.99% 82.85% +1.85%
==========================================
Files 9 10 +1
Lines 1684 1971 +287
==========================================
+ Hits 1364 1633 +269
- Misses 320 338 +18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Implement a compound-state HMM Viterbi (4 positions × 64 POS tags = 256 states) for POS-tagging unknown/OOV Chinese words, ported from Python jieba's posseg module.
posseg.rswith dense 256×256 transition matrix for O(1) lookupinclude_flate, gated ondefault-dictfeaturetag()to use posseg HMM for OOV CJK words instead of falling back to"x"(e.g."张尧"now correctly tagged as"nr"/person name)scripts/convert_posseg.py) for regeneratingposseg.txtfrom Python jieba's pickle filestag_with_oov(~2.5µs per call)