Repository navigation
feat(ocr): let a preset read several languages - #1229
Open
KnifeLemon wants to merge 4 commits into
Open
KnifeLemon wants to merge 4 commits into
KnifeLemon wants to merge 4 commits into
Conversation
Scans that mix languages (Simplified Chinese and English, say) read badly with one language. PdfOptions.OcrLanguage now holds one code or several joined with + as Tesseract takes them (chi_sim+eng), so older settings keep working and no migration is needed. OcrLanguages.Parse is the one reader: unlisted codes are left out, repeats count once, none left means English. Tesseract gets every language's data through the existing download, and a failed download names its language. Apple Vision asks for the languages in their order with English last; one it doesn't read sends them all to Tesseract, or names that language when Tesseract is missing. The preset editor keeps the main language list and adds "Other languages in the text". Fixes #1123 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ocr-several-languages
From the review of #1229: - The "add a language" list is refreshed in place, so a language picked but not added stays picked when a row is removed or the main language changes; clearing the list made the combo box drop it. - An added language made the main one trades places with the old main language, which used to be lost. - Apple Vision keeps English first when it is the main language, so a refused combination falls back to it, not to the other language. - On a Mac, a language Vision can't read among the chosen ones sends them all to Tesseract, so the others show their download size too. For that the OCR lists hold OcrLanguageChoice, whose detail can change. - AppleVisionTests read Korean and English in both orders on real Vision. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With "eng+kor" Vision read the English line and dropped the Korean one on both Mac runners, while "kor+eng" read both. Those languages now go ahead of the others whatever order was picked; the rest keep theirs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 does this change?
Fixes #1123. A preset's OCR can now read more than one language, for scans that mix them (Simplified Chinese + English, for example).
PdfOptions.OcrLanguagestays one string: one code, or several joined with+, the main language first (chi_sim+eng), which is what Tesseract's-ltakes. Older settings with one code read as before, so there is no schema migration. An older Filee reading a joined value doesn't find it in its list and reads English, without an error.OcrLanguages.Parseis what every reader now goes through. Codes not in the list are left out (only listed codes ever reach a path or Tesseract's command line), repeats count once, and with none left English is read, as an unknown code did before.OcrLanguages.EnsureAsyncdownload and is copied into the job'stessdata. A failed download refuses the file witherror.ocr_language_download, naming that language, the way a single language does today.OcrLanguageChoice, whose detail can change while the window is open.group.add).docs/ENGINES.md.Type of change
How was it tested?
dotnet format --verify-no-changeson the changed C# filesdotnet test, on Windows 11 with Tesseract 5.4 (not the whole suites):Filee.Engines.Tests:OcrLanguageListTests,OcrTests,VisionLanguageTests,VisionConverterTests,AppleVisionTests(44 tests: 39 passed, the 5AppleVisionTestsskipped off a Mac). New real runs: a scan in Russian + English is read only withrus+eng(withengalone the Russian word is missing), and the scan of the issue, Simplified Chinese + English, reads both withchi_sim+eng; both download their language data. Others are new tests for parsing and bad codes, the failed download, and Vision's language order, mixed languages and fallback, with a stand-in recognizer.Filee.App.Tests:LocalizationTests(key and placeholder parity) and the preset editor tests (222 tests, all passed).Preset_editor_reads_and_saves_several_text_recognition_languagescovers loading, adding, removing, changing the main language, saving and older settings, rendered in English and Simplified Chinese.A_language_picked_but_not_added_stays_picked_while_the_lists_changeruns with the window shown, so the real ComboBox is attached; it failed before the fix.Preset_editor_shows_the_download_of_a_language_vision_reads_when_tesseract_would_read_them_alluses a stand-in for what Vision reads.Not tested here: real Apple Vision (no Mac here). The new
AppleVisionTests.Text_in_two_languages_is_read_with_bothreads Korean + English in both orders, and only runs in the macOS CI jobs. Translations other than English were written without a native review.Screenshots (UI changes)
Preset editor with
chi_sim+eng(English, light theme). English shows no size because its data is already downloaded here:Checklist
src/Filee.App/Assets/i18n/*.jsonfilesTHIRD-PARTY-NOTICES.md(none)🤖 Generated with Claude Code