Skip to content

fix dediac_hsb stripping the alef-wasla letter#170

Open
CodingSelim wants to merge 1 commit into
CAMeL-Lab:masterfrom
CodingSelim:fix-hsb-dediac-alefwasla
Open

fix dediac_hsb stripping the alef-wasla letter#170
CodingSelim wants to merge 1 commit into
CAMeL-Lab:masterfrom
CodingSelim:fix-hsb-dediac-alefwasla

Conversation

@CodingSelim

Copy link
Copy Markdown

dediac_hsb was silently dropping alef-wasla from valid hsb text. the cause is in HSB_DIAC_CHARSET, it lists Ä (U+00C4) as a diacritic, but Ä is the hsb encoding of alef-wasla (U+0671) which is a letter. dediac deletes every char in the diac set so the letter went with it.

quick repro from the ar side to show intent, the arabic path keeps it but hsb doesn't:

from camel_tools.utils.dediac import dediac_hsb, dediac_ar
dediac_hsb("Äalm")   # 'lm'   <- alef-wasla dropped
dediac_ar("ٱلَم")     # 'ٱلم'  <- alef-wasla kept, correct

to be sure about the right set i rebuilt the hsb diac charset straight from the ar2hsb charmap (mapping every char in AR_DIAC_CHARSET) and it comes out to exactly the current set minus Ä, so the fix is just removing that one char. Ä stays in HSB_LETTERS_CHARSET where it belongs.

there was no test_dediac.py so i added one covering ar/bw/hsb, the two hsb cases fail before this change and pass after. ran the charmap/transliterate/stringutils suites too, all green (test_meta fails to collect on a pre-existing unrelated import, not touched here).

HSB_DIAC_CHARSET had Ä (U+00C4) in it, but that's the HSB encoding of
alef-wasla (U+0671) which is a letter, not a diacritic. dediac_hsb deletes
every char in the diac set so it was silently dropping alef-wasla from valid
hsb text. derived the real diac set from the ar2hsb charmap to confirm, it's
exactly the current set minus Ä. added test_dediac.py (there wasn't one),
the hsb cases fail before and pass after.
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.

1 participant