Struct lingua::LanguageDetector
source · [−]pub struct LanguageDetector { /* private fields */ }
Expand description
This struct detects the language of given input text.
Implementations
sourceimpl LanguageDetector
impl LanguageDetector
sourcepub fn detect_language_of<T: Into<String>>(&self, text: T) -> Option<Language>
pub fn detect_language_of<T: Into<String>>(&self, text: T) -> Option<Language>
Detects the language of given input text.
If the language cannot be reliably detected, None
is returned.
sourcepub fn compute_language_confidence_values<T: Into<String>>(
&self,
text: T
) -> Vec<(Language, f64)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn compute_language_confidence_values<T: Into<String>>(
&self,
text: T
) -> Vec<(Language, f64)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Computes confidence values for each language considered possible for the given input text.
A vector of all possible languages is returned, sorted by their confidence value in descending order. The values that this method computes are part of a relative confidence metric, not of an absolute one. Each value is a number between 0.0 and 1.0. The most likely language is always returned with value 1.0. All other languages get values assigned which are lower than 1.0, denoting how less likely those languages are in comparison to the most likely language.
The vector returned by this method does not necessarily contain all languages which the
calling instance of LanguageDetector
was built from. If the rule-based engine decides
that a specific language is truly impossible, then it will not be part of the returned
vector. Likewise, if no ngram probabilities can be found within the detector’s languages
for the given input text, the returned vector will be empty. The confidence value for
each language not being part of the returned vector is assumed to be 0.0.
Auto Trait Implementations
impl RefUnwindSafe for LanguageDetector
impl Send for LanguageDetector
impl Sync for LanguageDetector
impl Unpin for LanguageDetector
impl UnwindSafe for LanguageDetector
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more