Skip to content

feat(ocr): read Simplified Chinese scans - #1675

Merged
MBombeck merged 3 commits into
MBombeck:release/v1.50.0from
Remedy233:feat/150-ocr-chi-sim
Nov 30, 2026
Merged

MBombeck merged 3 commits into
MBombeck:release/v1.50.0from
Remedy233:feat/150-ocr-chi-sim

Conversation

@Remedy233

Copy link
Copy Markdown

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+eng only.

Changes

  • @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.
  • 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 locale outside German
    and English to read with three languages again.

On the size

The issue asked for the fast build, and the reason it asked is worth
correcting rather than restating: this package ships two builds, and the
small one is 4.0.0_best_int, the same directory every other language stages
from.

Directory chi_sim.traineddata.gz
4.0.0_best_int 1.6 MB
4.0.0 19.2 MB

For comparison, deu is 1.3 MB and kor 1.6 MB. The "20.87 MB" in the issue
is the whole npm package, which carries both builds. So Chinese needs no
special variant: public/tesseract/lang goes from 19.2 MB to 20.8 MB, and the
staging 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 on deu+eng. It reads a photographed
lab 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, with chi_sim staged through the same code the image
    uses
  • tsc --noEmit: clean
  • stage-tesseract-assets.mjs: writes 15 files

Depends on

The zh-CN bundle change: this flips the one line that change added.

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.
@MBombeck
MBombeck merged commit e95c14a into MBombeck:release/v1.50.0 Nov 30, 2026
41 checks passed
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.

2 participants