Skip to content

fix: map long-s-t ligature (U+FB05) to 'st' not 'ft'#4386

Open
NishchayMahor wants to merge 1 commit into
Unstructured-IO:mainfrom
NishchayMahor:fix/ligature-long-s-t-mapping
Open

fix: map long-s-t ligature (U+FB05) to 'st' not 'ft'#4386
NishchayMahor wants to merge 1 commit into
Unstructured-IO:mainfrom
NishchayMahor:fix/ligature-long-s-t-mapping

Conversation

@NishchayMahor

@NishchayMahor NishchayMahor commented Jul 5, 2026

Copy link
Copy Markdown

Summary

clean_ligatures maps U+FB05 (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:

word (with U+FB05) current output correct
la laft last
fir firft first
be beft best

This flows straight into partitioned/cleaned text and downstream chunks, so RAG pipelines ingest laft / firft / beft instead of last / first / best.

Why "st" is correct

  • Unicode NFKC settles it: unicodedata.normalize("NFKC", "ſt") == "st" (name: LATIN SMALL LIGATURE LONG S T).
  • The table is already internally inconsistent: the adjacent U+FB06 (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.
  • There is no "ft" ligature in the Alphabetic Presentation Forms block (U+FB00–FB06 = ff, fi, fl, ffi, ffl, ſt, st); the original "ft" appears to have mistaken the long-s (ſ) for an f.

Change

  • unstructured/cleaners/core.pyclean_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_ligatures14 passed. Pure-Python, no network/models.

Review in cubic

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).

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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