fix: map long-s-t ligature (U+FB05) to 'st' not 'ft'#4386
Open
NishchayMahor wants to merge 1 commit into
Open
Conversation
clean_ligatures mapped U+FB05 (LATIN SMALL LIGATURE LONG S T, the long-s +
t glyph 'ſt') to 'ft', which corrupted real text: words like last/first/best
typeset with that ligature became laft/firft/beft. Unicode NFKC normalizes
U+FB05 to 'st', and the adjacent U+FB06 ('st') is already mapped to 'st' in
the same table. Map U+FB05 to 'st' and fix the test case that encoded the
old behavior (the prior example used the st-ligature to spell 'craftsman',
which is not what the glyph represents).
Contributor
There was a problem hiding this comment.
No issues found across 2 files
Shadow auto-approve: would auto-approve. Corrects Unicode ligature mapping (U+FB05) from incorrect "ft" to "st", aligning with Unicode NFKC normalization. Only 2 lines changed in core logic and test. Highly isolated, low-risk fix.
Re-trigger cubic
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_ligaturesmaps U+FB05ſt(LATIN SMALL LIGATURE LONG S T) to"ft". That's incorrect — the glyph is the long-s + t ligature (ſt), so it represents "st", not "ft". As a result, real text that uses this ligature is silently corrupted:ſtſtſtThis flows straight into partitioned/cleaned text and downstream chunks, so RAG pipelines ingest
laft/firft/beftinstead oflast/first/best.Why "st" is correct
unicodedata.normalize("NFKC", "ſt") == "st"(name:LATIN SMALL LIGATURE LONG S T).st(LATIN SMALL LIGATURE ST) — which also NFKC-normalizes to"st"— is correctly mapped to"st"two lines below. U+FB05 and U+FB06 are both "st" ligatures and should map identically."ft"appears to have mistaken the long-s (ſ) for an f.Change
unstructured/cleaners/core.py—clean_ligatures:"ſt": "ft"→"ſt": "st".test_unstructured/cleaners/test_core.py— the existing case encoded the old behavior by using the st-ligature to spell "craftsman" ("The craſtsman…" → "The craftsman…"), which the glyph can't represent. Replaced with a correct example:"The laſt chapter was the best." → "The last chapter was the best."Testing
pytest test_unstructured/cleaners/test_core.py::test_clean_ligatures→ 14 passed. Pure-Python, no network/models.