Skip to content

Add opt-in Unicode mark-preserving processor - #518

Open
jamesyshd19-cmyk wants to merge 1 commit into
rapidfuzz:mainfrom
jamesyshd19-cmyk:feat/unicode-mark-preserving-processor
Open

jamesyshd19-cmyk wants to merge 1 commit into
rapidfuzz:mainfrom
jamesyshd19-cmyk:feat/unicode-mark-preserving-processor

Conversation

@jamesyshd19-cmyk

Copy link
Copy Markdown

Closes #515.

Add utils.default_process_with_marks for text where vowel signs and other Unicode marks affect matching. It keeps alphanumeric characters and marks, as well as zero-width joiners and non-joiners between letters or marks. It replaces other characters with spaces, trims the ends, and lowercases the result. The existing default_process is unchanged.

The Sinhala and Tamil comparisons from #515 both scored 85.5 with the existing processor. With the opt-in processor they score 36.0 and approximately 51.4, leaving only the exact matches above the cutoff of 80. The tests also cover Sinhala conjuncts and Persian non-joiners.

Both backends use the same Python callable and the interpreter’s Unicode database to preprocess str inputs. Callers can apply Unicode normalization separately. Variation selectors are marks, so two emoji-only strings carrying the same selector can reduce to the same processed string.

Verification on Apple Silicon with Python 3.14

  • Built the native extension and passed all 24 focused tests in both backend modes.
  • Full suites had 562 passing tests in Python mode and 565 in C++ mode. The four Python-mode failures and one C++-mode failure also occur on clean upstream e5ba595, with identical failing test IDs.
  • Ruff, Black, and the Sphinx HTML build with warnings treated as errors passed.

@maxbachmann

Copy link
Copy Markdown
Member

Why does the native preprocessor implementation need to call the python implementation?

I feel like this could just be done in C++ by regenerating our unicode lookup tables

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

default_process strips combining marks, breaking Sinhala, Tamil, Hindi and other scripts (regression of #29?)

2 participants