Struct whatlang::Detector [] [src]

pub struct Detector<'a> { /* fields omitted */ }

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

Examples

Specifying a whitelist:

use whatlang::{Detector, Lang};

const WHITELIST : &'static [Lang] = &[Lang::Eng, Lang::Rus];

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

Specifying a blacklist:

use whatlang::{Detector, Lang};

const BLACKLIST: &'static [Lang] = &[Lang::Eng, Lang::Ita];

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

Methods

impl<'a> Detector<'a>
[src]