Model

Struct Model 

Source
pub struct Model { /* private fields */ }

Implementations§

Source§

impl Model

Source

pub fn set_langs(&mut self, langs: Option<HashSet<String>>) -> Result<(), Error>

Source

pub fn rank(&self, text: &str) -> Vec<(&str, f32)>

Return a list of languages in order of likelihood.

Examples found in repository?
examples/rank.rs (line 9)
3fn main() {
4    let model = Model::load(false).unwrap();
5    //model.set_langs(Some(vec![...])).unwrap();
6
7    let text = "This text is in English.";
8
9    let classification = model.rank(text);
10    println!("{:?}", classification);
11}
Source

pub fn classify(&self, text: &str) -> Option<(&str, f32)>

Classify an instance. Will return None if no language is detected.

Examples found in repository?
examples/classify.rs (line 9)
3fn main() {
4    let model = Model::load(false).unwrap();
5    //model.set_langs(Some(vec![...])).unwrap();
6
7    let text = "This text is in English.";
8
9    let classification = model.classify(text).unwrap();
10    println!("{:?}", classification);
11}
Source§

impl Model

Source

pub fn load(norm_probs: bool) -> Result<Self>

Examples found in repository?
examples/rank.rs (line 4)
3fn main() {
4    let model = Model::load(false).unwrap();
5    //model.set_langs(Some(vec![...])).unwrap();
6
7    let text = "This text is in English.";
8
9    let classification = model.rank(text);
10    println!("{:?}", classification);
11}
More examples
Hide additional examples
examples/classify.rs (line 4)
3fn main() {
4    let model = Model::load(false).unwrap();
5    //model.set_langs(Some(vec![...])).unwrap();
6
7    let text = "This text is in English.";
8
9    let classification = model.classify(text).unwrap();
10    println!("{:?}", classification);
11}

Trait Implementations§

Source§

impl Debug for Model

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Model

§

impl RefUnwindSafe for Model

§

impl Send for Model

§

impl Sync for Model

§

impl Unpin for Model

§

impl UnwindSafe for Model

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, 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.