[][src]Struct whatlang::Detector

pub struct Detector { /* fields omitted */ }

Configurable structure that holds detection options and provides functions to detect language and script.

Examples

Specifying a whitelist:

use whatlang::{Detector, Lang};

// Create detector with whitelist
let detector = Detector::with_whitelist(vec![Lang::Eng, Lang::Rus]);
let lang = detector.detect_lang("That is not Russian");
assert_eq!(lang, Some(Lang::Eng));

Specifying a blacklist:

use whatlang::{Detector, Lang};

let detector = Detector::with_blacklist(vec![Lang::Eng, Lang::Ita]);
let lang = detector.detect_lang("Jen la trinkejo fermitis, ni iras tra mallumo kaj pluvo.");
assert_eq!(lang, Some(Lang::Epo));

Implementations

impl Detector[src]

pub fn new() -> Self[src]

pub fn with_whitelist(whitelist: Vec<Lang>) -> Self[src]

pub fn with_blacklist(blacklist: Vec<Lang>) -> Self[src]

pub fn with_options(options: Options) -> Self[src]

pub fn detect(&self, text: &str) -> Option<Info>[src]

pub fn detect_lang(&self, text: &str) -> Option<Lang>[src]

pub fn detect_script(&self, text: &str) -> Option<Script>[src]

Trait Implementations

impl Clone for Detector[src]

impl Debug for Detector[src]

impl Default for Detector[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.