Repository navigation
fix: tokenize currency/symbol chars as punct, not control chars (#500) - #685
Merged
Merged
Conversation
…500) Currency symbols like £ ¥ € (Unicode category Sc) are not matched by unicu::isPunct (ICU's u_ispunct excludes Sc), nor by the alpha/num/white checks, so Tok::nextTok dropped them into the PNCTRL (control-char) bucket. dicttok then stamped a bogus ("CTRL" <lead-byte>) attribute -- e.g. £ (UTF-8 C2 A3) showed as ("CTRL" 194). - Add unicu::isSymbol(): true for currency/math/modifier/other symbol categories (u_charType). - Tok::nextTok: classify symbols as PNPUNCT before the PNCTRL fallback. This covers both the `tokenize` and `dicttok` passes (dicttok calls nextTok). Now $ £ ¥ € all tokenize as punct (like $ already did), with no spurious CTRL attribute. Blast radius is minimal: ASCII symbols (+ < = > | ~) were already caught by isPunct128, so only previously-misclassified non-ASCII symbols move from PNCTRL to PNPUNCT. Verified: £ ¥ € -> punct; emailaddress analyzer still extracts email; plain ASCII (alpha/punct/num) unchanged. Not addressed: the legacy byte-based cmltok tokenizer (rarely used) remains non-Unicode-aware. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ddehilster
force-pushed
the
fix/tokenize-currency-symbols
branch
from
July 6, 2026 21:17
f44c954 to
55fe7c8
Compare
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.
Summary
Fixes #500: currency symbols like
£ ¥ €were tokenized as control characters instead of symbols.Root cause
£(U+00A3, Unicode category Sc = currency symbol) isn't matched byunicu::isPunct(ICU'su_ispunctexcludes Sc), nor by the alpha/num/white checks — soTok::nextTokfell through to thePNCTRL(control-char) bucket (tok.cpp).dicttokthen stamped a bogus("CTRL" <lead-byte>)attribute — e.g.£(UTF-8C2 A3) showed as("CTRL" 194).Fix
unicu::isSymbol()— true for currency / math / modifier / other symbol categories (u_charType).Tok::nextTokclassifies symbols asPNPUNCTbefore thePNCTRLfallback. This covers both thetokenizeanddicttokpasses (dicttokcallsnextTok).Result
$£¥€("CTRL" 194)Blast radius is minimal: ASCII symbols (
+ < = > | ~) were already caught byisPunct128, so only previously-misclassified non-ASCII symbols move fromPNCTRLtoPNPUNCT.Testing
£ ¥ €now tokenize aspunct(no spuriousCTRL).emailaddressstill extracts email; plain ASCII (alpha/punct/num) unchanged.Not addressed
The legacy byte-based
cmltoktokenizer (rarely used) is still non-Unicode-aware; fixing it means a UTF-8 rewrite — out of scope.NLP_ENGINE_VERSION→ 3.7.2, which assumes #684 (3.7.1) merges first. If this merges before #684, resolve the trivialmain.cppversion-line conflict (keep 3.7.2) so master doesn't skip 3.7.1.Fixes #500.
🤖 Generated with Claude Code