Fix OCR dropping German umlauts by loading the German model
Tesseract only loaded the English model, which has no ä/ö/ü/ß, so they were misread as plain letters. Load deu+eng and normalize output to NFC. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
be421d83cb
commit
7107846624
1 changed files with 3 additions and 1 deletions
|
|
@ -2,13 +2,15 @@ let workerPromise: Promise<import("tesseract.js").Worker> | null = null;
|
|||
|
||||
function getWorker() {
|
||||
if (!workerPromise) {
|
||||
workerPromise = import("tesseract.js").then(({ createWorker }) => createWorker("eng"));
|
||||
// "deu" is needed for umlauts and ß; the English model can't produce them.
|
||||
workerPromise = import("tesseract.js").then(({ createWorker }) => createWorker("deu+eng"));
|
||||
}
|
||||
return workerPromise;
|
||||
}
|
||||
|
||||
function cleanUpText(raw: string): string {
|
||||
return raw
|
||||
.normalize("NFC")
|
||||
.replace(/[ \t]+\n/g, "\n")
|
||||
.replace(/\n{3,}/g, "\n\n")
|
||||
.trim();
|
||||
|
|
|
|||
Loading…
Reference in a new issue