feat(text-normalizer): opt-in Arabic search equivalences, named profiles and analyze() - #5
Merged
Merged
Conversation
The working tree had reverted testUnicodeEdgeCases to the expectation that shipped broken on the v0.1.x branch: 'à' kept its accent and the emoji left no trace. Neither holds. This profile folds 'à' to 'a' like any other Latin diacritic, and the variation selector trailing the emoji (U+FE0F) is a combining mark the profile does not claim, so it survives by the same rule that keeps Arabic harakat.
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
Two additions for v0.2.0: the Arabic profile stops imposing one folding convention on every caller, and normalization can now return a result object instead of a bare string.
Arabic: search vs strict
ة → هis a search-index convention, not a Unicode equivalence — it makesمدرسةandمدرسهcollide, which is what a search index wants and what a strict comparison does not. It was hardcoded, so callers who needed the distinction had no way back.NormalizerProfile::arabic()now takessearchEquivalences(defaulttrue, preserving current behaviour). Passingfalsekeeps Ta Marbuta intact; every other mapping — alif variants, yeh, kaf, heh, Arabic-Indic digits — is unconditional, being genuine orthographic variance rather than a search convention.all()forwards the flag.Named profiles and
analyze()Profiles carry a
name(latin,arabic_search,arabic_strict, composed onmerge()asarabic_search_latin).TextNormalizer::analyze()returns aNormalizedTextvalue object — original, normalized, profile name, plusisEmpty(),length(),originalLength(),wasModified()and__toString().normalize()is untouched, so nothing existing has to change.Test plan
composer test— 49 tests, 77 assertionscomposer analyse— no errorsNote
One commit here restores an assertion in
testUnicodeEdgeCasesthat the working tree had reverted to the version that shipped broken before #4. Unrelated to the v0.2.0 work, but the suite is red without it.