Repository navigation
feat(ocr): read Simplified Chinese scans - #1675
Merged
MBombeck merged 3 commits intoNov 30, 2026
Merged
Conversation
The document reader ships one language pack per app language, so a Chinese reader's scanned reports were read with deu+eng only. This adds `chi_sim` and maps the new locale to it. - `@tesseract.js-data/chi_sim` at 1.0.0, with `pnpm-lock.yaml` updated so `--frozen-lockfile` keeps working. - `stage-tesseract-assets.mjs` stages it like every other language, from `4.0.0_best_int`. That is the size story: this package ships two builds and the *other* one is 19.2 MB against 1.6 MB here, which is what a Latin language's data costs (`deu` 1.3 MB). The whole `public/tesseract/lang` tree goes from 19.2 MB to 20.8 MB. - `server-ocr.ts`: `chi_sim` joins `LANGUAGE_ORDER` and `zh-CN` joins `LOCALE_LANGUAGE`, replacing the interim `"eng"` the bundle change put there so that branch could typecheck alone. - The OCR test stages `chi_sim` too and expects every non-German-and-English locale to read with three languages again. The browser scan (`local-ocr.ts`) deliberately stays on `deu+eng`: it reads a photographed lab sheet whose analyte names and units are Latin, and a third pack there would load for every user regardless of language. Verified: 17/17 in `server-ocr`, `tsc --noEmit` clean, and the real staging script writes 15 files. Depends on the zh-CN bundle change: this flips the one line that change added.
This was referenced Nov 28, 2026
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.
What this does
Lets the document reader read a Simplified Chinese scan.
The reader ships one language pack per app language, so a Chinese reader's
scanned reports were read with
deu+engonly.Changes
@tesseract.js-data/chi_simat1.0.0, withpnpm-lock.yamlupdated so--frozen-lockfilekeeps working.stage-tesseract-assets.mjsstages it like every other language, from4.0.0_best_int.server-ocr.ts:chi_simjoinsLANGUAGE_ORDERandzh-CNjoinsLOCALE_LANGUAGE, replacing the interim"eng"the bundle change put thereso that branch could typecheck alone.
chi_simtoo, and expects every locale outside Germanand English to read with three languages again.
On the size
The issue asked for the
fastbuild, and the reason it asked is worthcorrecting rather than restating: this package ships two builds, and the
small one is
4.0.0_best_int, the same directory every other language stagesfrom.
chi_sim.traineddata.gz4.0.0_best_int4.0.0For comparison,
deuis 1.3 MB andkor1.6 MB. The "20.87 MB" in the issueis the whole npm package, which carries both builds. So Chinese needs no
special variant:
public/tesseract/langgoes from 19.2 MB to 20.8 MB, and thestaging script stays uniform.
Measured by running the real staging script: 15 files, 11 languages, 20.8 MB.
Deliberately unchanged
The browser scan (
local-ocr.ts) stays ondeu+eng. It reads a photographedlab sheet whose analyte names and units are Latin, and a third pack there would
load a megabyte into every user's browser regardless of their language. The
server path is the one that reads arbitrary documents.
Checks
server-ocr: 17/17, withchi_simstaged through the same code the imageuses
tsc --noEmit: cleanstage-tesseract-assets.mjs: writes 15 filesDepends on
The zh-CN bundle change: this flips the one line that change added.