pub struct Detector<'m, H: RealHasher> {
pub languages: HashSet<ScriptLanguage, H>,
pub long_text_minlen: usize,
/* private fields */
}Fields§
§languages: HashSet<ScriptLanguage, H>§long_text_minlen: usizeImplementations§
Source§impl<'m, H: RealHasher> Detector<'m, H>
impl<'m, H: RealHasher> Detector<'m, H>
Sourcepub fn clone_with_languages<H2: RealHasher>(
&self,
languages: HashSet<ScriptLanguage, H2>,
) -> Detector<'m, H2>
pub fn clone_with_languages<H2: RealHasher>( &self, languages: HashSet<ScriptLanguage, H2>, ) -> Detector<'m, H2>
Clone detector with new languages selected
Sourcepub fn preload_models(&self)
pub fn preload_models(&self)
Preloads models for the languages selected in this detector
Sourcepub fn unload_models(&self)
pub fn unload_models(&self)
Drops all models loaded
Sourcepub fn probabilities(&self, text: &str) -> Vec<(ScriptLanguage, f64)>
pub fn probabilities(&self, text: &str) -> Vec<(ScriptLanguage, f64)>
Returns probabilities for the provided text. Each value is a logarithmic probability between a negative infinity and 0.0.
Result is sorted by probabilities in a descending order.
If only a single language is identified by alphabet_detector,
the value 0.0 will be returned.
Sourcepub fn probabilities_relative(&self, text: &str) -> Vec<(ScriptLanguage, f64)>
pub fn probabilities_relative(&self, text: &str) -> Vec<(ScriptLanguage, f64)>
Returns probabilities for the provided text relative to other languages. Each value is a number between 0.0 and 1.0.
If only a single language is identified by alphabet_detector,
the value 1.0 will be returned.
Sourcepub fn detect_top_one_or_none(
&self,
text: &str,
minimum_distance: f64,
) -> Option<ScriptLanguage>
pub fn detect_top_one_or_none( &self, text: &str, minimum_distance: f64, ) -> Option<ScriptLanguage>
Detects a top one language of the provided text.
minimum_distance is a distance between a first and a second logarithmic probabilities,
which can help filter languages with close probabilities.
If a single language cannot be returned, None is returned.
Sourcepub fn detect_top_one_reordered_custom<F>(
&self,
text: &str,
reorder_distance_compute: F,
) -> Option<ScriptLanguage>
pub fn detect_top_one_reordered_custom<F>( &self, text: &str, reorder_distance_compute: F, ) -> Option<ScriptLanguage>
Detects a top one language of the provided text.
If multiple languages are covered by reorder distance (result of reorder_distance_compute),
reorders by total speakers of these languages.
Reorder distance is a distance between logarithmic probabilities, must be >= 0.0.
None is returned only when probabilities is empty.
Sourcepub fn detect_top_one_reordered(&self, text: &str) -> Option<ScriptLanguage>
pub fn detect_top_one_reordered(&self, text: &str) -> Option<ScriptLanguage>
Detects a top one language of the provided text. If multiple languages are covered by the reorder formula, reorders by total speakers of these languages. More sutable if you need better detection of common (more popular) languages.
None is returned only when probabilities is empty.
Sourcepub fn detect_top_one_raw(&self, text: &str) -> Option<ScriptLanguage>
pub fn detect_top_one_raw(&self, text: &str) -> Option<ScriptLanguage>
Detects a top one language of the provided text. More sutable if you need better detection of rare (less popular) languages.
None is returned only when probabilities is empty.
pub fn detect_top_one( &self, text: &str, reorder: bool, ) -> Option<ScriptLanguage>
Trait Implementations§
Auto Trait Implementations§
impl<'m, H> Freeze for Detector<'m, H>where
H: Freeze,
impl<'m, H> !RefUnwindSafe for Detector<'m, H>
impl<'m, H> Send for Detector<'m, H>where
H: Send,
impl<'m, H> Sync for Detector<'m, H>where
H: Sync,
impl<'m, H> Unpin for Detector<'m, H>where
H: Unpin,
impl<'m, H> !UnwindSafe for Detector<'m, H>
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<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 more