Repository navigation
fix(text): idempotent Unicode cleaning, fewer false encoding alerts, international phones and punycode emails - #370
Merged
Merged
Conversation
…rnational phone and punycode email validation clean_text_value (#316): Unicode normalization ran first, before the control-character and zero-width removal steps. Removing a ZWSP between a base letter and a combining mark ("Jose" + U+200B + U+0301) left a decomposed sequence, so the output was not in the configured form and a second pass changed it again. The configured normalization now re-runs after all removal and custom steps (before whitespace collapse, strip and truncation). The transform name is recorded once. lint_text_encoding (#317): _script_of used the first word of the character name as the script, so modifier letters such as the katakana-hiragana prolonged sound mark (U+30FC) and the ideographic iteration mark (U+3005), and the ordinal indicators U+00AA / U+00BA, became their own "script" and ordinary Japanese and Spanish text was flagged as high-severity mixed_script. Modifier letters (category Lm) and the ordinal indicators are now script-neutral, and KATAKANA-HIRAGANA / IDEOGRAPHIC name heads join the CJK_JP family. The "Ã" + ASCII space alternative is removed from _MOJIBAKE_RE because it matched uppercase Portuguese ("MANHÃ DE SOL"); the NBSP form is still caught by the existing Ã[\x80-\xbf] range. validate_fields (#318): the phone regex capped the formatted string at 17 characters, rejecting "+49 (0) 30 12345678". The shape regex now allows up to 30 formatting characters and the length check is on the digit count (7-15, per E.164), applied the same way in detect_value_type, the per-value check and the vectorised suspect scan. The email TLD now also accepts punycode internationalized TLDs (xn--...). Closes #316 Closes #317 Closes #318
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
FreshData benchmark report —
|
| fixture | n_rows | n_cols | p50 s | p95 s | peak MB | repair % | false-repair % | preserve % | trust | monotonic | export % |
|---|
Authored-code reduction (Metric 6)
This was referenced Sep 15, 2026
Merged
kevincostner17
added a commit
that referenced
this pull request
Sep 15, 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.
Summary
clean_text_valueis now idempotent and in the configured Unicode form (clean_text_value output is not NFC or idempotent when a zero-width char precedes an accent #316). Normalization ran before zero-width/control-character removal, so"Jose" + U+200B + U+0301came out decomposed and a second pass changed it. The configured normalization now re-runs after the removal and custom steps (before whitespace collapse, strip and truncate); the transform name is recorded once.lint_text_encodingalerts (lint_text_encoding flags ordinary Japanese, Spanish and Portuguese text as high severity #317). Modifier letters (categoryLm, e.g.ー,々) and the ordinal indicatorsª/ºno longer count as their own script, andKATAKANA-HIRAGANA/IDEOGRAPHICcharacters join the Japanese family, soコーヒー,人々andNº 5are no longermixed_script. TheÃ+ ASCII-space mojibake pattern was dropped because it matched uppercase Portuguese (MANHÃ DE SOL); the NBSP form is still detected.validate_fields(validate_fields rejects valid '+49 (0) 30 ...' phone numbers and punycode-TLD emails #318). Phone validation now allows up to 30 formatting characters and checks for 7-15 digits (E.164), so+49 (0) 30 12345678passes. The same rule applies indetect_value_type, the per-value check and the vectorised suspect scan. Email TLDs may bexn--punycode.Behaviour changes
Ãfollowed by a plain space is no longer reported as mojibake.semantic/semantic_types.pykeeps its own phone/email patterns for type inference.Tests
New
tests/test_text_quality_fixes.py:école,don’t,São Paulo, the NBSP form) and real mixed script (Cyrillic/Greek in Latin text) are still detected;a@b.c,a@b.xn--,x@y), checked through both the scalar and the vectorised path.Verification
ruff check .: cleanmypy src/freshdata: clean (202 files)pytest -m "not online and not large"on Python 3.12: 4379 passed, 6 skippedpytest -m "not online and not large"on Python 3.9: 4375 passed, 10 skippedclean(clean(x)) == clean(x)with default settingsCloses #316
Closes #317
Closes #318