Struct whatlang::Detector
[−]
[src]
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));
Methods
impl Detector
[src]
fn new() -> Self
fn with_whitelist(whitelist: Vec<Lang>) -> Self
fn with_blacklist(blacklist: Vec<Lang>) -> Self
fn with_options(options: Options) -> Self
fn detect(&self, text: &str) -> Option<Info>
fn detect_lang(&self, text: &str) -> Option<Lang>
fn detect_script(&self, text: &str) -> Option<Script>
Trait Implementations
impl Debug for Detector
[src]
impl Clone for Detector
[src]
fn clone(&self) -> Detector
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more