DEDUPED Hot AI repos, turned into use cases Get 5 a day

How to check PDF-extracted Chinese text for look-alike glyphs with Cjkfold

Find Kangxi and radical look-alike characters in extracted text and fail an ingest run on them.

Who it is forA developer whose PDF ingest pipeline returns missed keyword matches on Chinese documents and needs to find out why.

The problemLook-alike characters display correctly but do not compare equal to the ordinary characters, so searches miss with no error.

The outcomeA report that lists each look-alike with its line, column and ordinary replacement, plus an exit code a pipeline can act on.

What you need first

  • Python 3.9 or newer with pip
  • Plain text extracted from the PDF, for example with pdftotext
  • A terminal for the command line examples, or a Python project for the library calls

Steps

  1. pip install cjkfold
  2. Extract the PDF to plain text with a tool such as pdftotext, and save the result as extracted.txt.
  3. cjkfold check extracted.txt
  4. Read the report. Each line gives the position, the look-alike character and the character it renders as.
  5. cjkfold check --quiet docs/*.txt in the ingest pipeline, so a non-zero exit stops bad files before they reach the index.

Prompt for your agent

Using the cjkfold repo, run `pip install cjkfold`, then run `cjkfold check <path-to-extracted-text-file>`. Report the number of look-alike characters and list the first three with their line and column. Verify by running `cjkfold fold -w` on a copy of the file and then `cjkfold check` on that copy, which should exit with code 0.

Caveat. The check command only looks for the look-alike family, so a file full of zero-width spaces will still report clean and needs the scan command as well.

Share: X LinkedIn Hacker News Email Copy link

Disclaimer

Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked "Seen in the wild", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email [email protected] and we will look at it promptly. Full disclaimer page