[−][src]Struct whatlang::Detector
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
Auto Trait Implementations
impl RefUnwindSafe for Detector
impl Send for Detector
impl Sync for Detector
impl Unpin for Detector
impl UnwindSafe for Detector
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,