Struct Detector

Source
pub struct Detector<'m, H: BuildHasher + Default> {
    pub config: DetectorConfig<H>,
    pub models_storage: &'m ModelsStorage,
}

Fields§

§config: DetectorConfig<H>§models_storage: &'m ModelsStorage

Implementations§

Source§

impl<'m, H: BuildHasher + Default> Detector<'m, H>

Source

pub fn new(config: DetectorConfig<H>, models_storage: &'m ModelsStorage) -> Self

Source

pub fn preload_models(&self)
where H: Sync,

Preload models for the languages selected in the config of this detector

Source

pub fn unload_models(&self)

Drops all models loaded

Source

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.

Source

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.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,