pub enum OcrLang {
En,
Ch,
}Expand description
OCR recognition language: which PP-OCRv3 model + dictionary pair runs when the PP-OCRv6 recognizer is not installed.
With .models/ocr_rec_v6.onnx + .models/ocr_rec_v6_dict.txt on disk
(#570; download_dependencies.sh fetches them) both languages run that
one multilingual model — RapidOCR’s PP-OCRv6_rec_small, the recognizer
docling runs for English and Chinese alike, and the single largest factor
in the FUNSD word-recall gap once the detector’s lines are the crops
(0.70 → 0.77 on 30 forms). Without it, the PP-OCRv3 pairs: the default is
English (.models/ocr_rec_en.onnx + .models/en_dict.txt) — the
multilingual ch_ v3 model reads Latin scripts with badly degraded word
spacing (glued words on ordinary English scans) — and Ch selects the
ch_ pair (.models/ocr_rec.onnx + .models/ppocr_keys_v1.txt), what
the PDF conformance baselines were pinned against;
scripts/conformance/pdf_*.sh pin it explicitly by path, which wins over
this selector and over the v6 preference.
Variants§
En
en_PP-OCRv3 — English-only, proper Latin word spacing.
Ch
ch_PP-OCRv3 — multilingual; the docling-conformance model.
Implementations§
Source§impl OcrLang
impl OcrLang
Sourcepub const ACCEPTED: &'static str = "en | ch, or a BCP-47 tag for English or Chinese such as en-US, eng, zh, zh-Hans, zh-TW"
pub const ACCEPTED: &'static str = "en | ch, or a BCP-47 tag for English or Chinese such as en-US, eng, zh, zh-Hans, zh-TW"
The accepted spellings, for error messages and docs.
Sourcepub fn parse(s: &str) -> Option<Self>
pub fn parse(s: &str) -> Option<Self>
Parse a user-supplied language id (#388): the engine’s own codes
(en, ch) and BCP-47 tags naming a language one of the two
recognizers reads, trimmed and case-insensitive. None for anything
else — callers surface their own error/warning.
docling canonicalizes OCR languages across its engines (docling#4075):
a bare value is the engine’s native code, an iso:-prefixed value a
BCP-47 tag reduced to a language-script pair with the region dropped
(zh-CN and zh-Hans are the same recognizer, en-GB is en), and
the RapidOCR adapter maps en → its en model and zh-Hans → ch.
With only those two PP-OCRv3 pairs on board there is no ambiguity, so
the prefix is optional here: en-US, eng, zh, zh-Hans, iso:zh-CN
all resolve without a warning. Accepted primary subtags: English as
en / ISO 639-2/3 eng / docling’s legacy english; Chinese as the
engine code ch (and RapidOCR’s chinese_cht), zh / zho / chi /
cmn / legacy chinese / EasyOCR’s ch_sim / ch_tra. Script,
region and variant subtags (-Hans, -Hant, -CN, -TW, _US) are
ignored: a traditional-script request (zh-Hant, zh-TW) gets the
multilingual ch recognizer too, the closest model shipped — upstream
would pick RapidOCR’s separate chinese_cht, which this engine does
not carry. Genuinely unsupported languages (de, fr, ja, …) parse
to None and keep warning.
Trait Implementations§
impl Copy for OcrLang
impl Eq for OcrLang
impl StructuralPartialEq for OcrLang
Auto Trait Implementations§
impl Freeze for OcrLang
impl RefUnwindSafe for OcrLang
impl Send for OcrLang
impl Sync for OcrLang
impl Unpin for OcrLang
impl UnsafeUnpin for OcrLang
impl UnwindSafe for OcrLang
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().