#[repr(u8)]pub enum Language {
Show 13 variants
English = 0,
German = 1,
French = 2,
Spanish = 3,
Italian = 4,
Portuguese = 5,
Russian = 6,
Chinese = 7,
Japanese = 8,
Korean = 9,
Arabic = 10,
Hebrew = 11,
Other = 12,
}Expand description
Supported languages for text analysis.
Variants are intentionally ordered for indexed access in detect_language.
The repr(u8) is required for safe conversion from index to enum variant.
Variants§
English = 0
English language
German = 1
German language
French = 2
French language
Spanish = 3
Spanish language
Italian = 4
Italian language
Portuguese = 5
Portuguese language
Russian = 6
Russian language
Chinese = 7
Chinese language (Simplified/Traditional)
Japanese = 8
Japanese language
Korean = 9
Korean language
Arabic = 10
Arabic language
Hebrew = 11
Hebrew language
Other = 12
Other/unknown language
Implementations§
Source§impl Language
impl Language
Sourcepub fn is_cjk(&self) -> bool
pub fn is_cjk(&self) -> bool
Returns true if this is a CJK (Chinese, Japanese, Korean) language.
Sourcepub fn is_rtl(&self) -> bool
pub fn is_rtl(&self) -> bool
Returns true if this is a right-to-left language (Arabic, Hebrew).
Sourcepub fn uses_latin_capitalization(&self) -> bool
pub fn uses_latin_capitalization(&self) -> bool
Returns true if this language uses the Latin script with sentence-initial capitalization (English, French, Spanish, German, Italian, Portuguese).
Used to gate capitalization adjustments in pronoun rewriting: only these languages capitalize the first word of a sentence, so replacing a sentence-initial pronoun with a proper noun needs case adjustment.
Source§impl Language
impl Language
Sourcepub fn from_code(code: &str) -> Option<Language>
pub fn from_code(code: &str) -> Option<Language>
Parse from ISO 639-1/639-3 code or English name.
Returns None for unrecognized codes (rather than silently defaulting).
use anno::Language;
assert_eq!(Language::from_code("en"), Some(Language::English));
assert_eq!(Language::from_code("de"), Some(Language::German));
assert_eq!(Language::from_code("english"), Some(Language::English));
assert_eq!(Language::from_code("xyz"), None);Trait Implementations§
impl Copy for Language
impl Eq for Language
impl StructuralPartialEq for Language
Auto Trait Implementations§
impl Freeze for Language
impl RefUnwindSafe for Language
impl Send for Language
impl Sync for Language
impl Unpin for Language
impl UnsafeUnpin for Language
impl UnwindSafe for Language
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
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read moreSource§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.