pub struct Detector<'m, H: BuildHasher + Default> {
pub config: DetectorConfig<H>,
pub models_storage: &'m ModelsStorage,
}Fields§
§config: DetectorConfig<H>§models_storage: &'m ModelsStorageImplementations§
Source§impl<'m, H: BuildHasher + Default> Detector<'m, H>
impl<'m, H: BuildHasher + Default> Detector<'m, H>
pub fn new(config: DetectorConfig<H>, models_storage: &'m ModelsStorage) -> Self
Sourcepub fn preload_models(&self)where
H: Sync,
pub fn preload_models(&self)where
H: Sync,
Preload models for the languages selected in the config of 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 given 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 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 given text relative to other languages. Each value is a number between 0.0 and 1.0.
If only single language is identified by alphabet_detector, the value 1.0 will be returned.
Sourcepub fn detect_top_one(
&self,
text: &str,
minimum_distance: f64,
) -> Option<ScriptLanguage>
pub fn detect_top_one( &self, text: &str, minimum_distance: f64, ) -> Option<ScriptLanguage>
Detects the top one language of the input text.
If single language cannot be returned, None is returned.
Auto Trait Implementations§
impl<'m, H> Freeze for Detector<'m, H>where
H: Freeze,
impl<'m, H> RefUnwindSafe for Detector<'m, H>where
H: RefUnwindSafe,
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>where
H: UnwindSafe,
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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