1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
//! Whatlang is a Rust library to detect(regonize) natural languages. //! Apart from it, the library also recognizes scripts (writing system). //! Every language and script are represented by determined list of enums. //! //! # Examples //! //! Using `detect` function: //! //! ``` //! use whatlang::{detect, Lang, Script}; //! //! let text = "Ĉu vi ne volas eklerni Esperanton? Bonvolu! Estas unu de la plej bonaj aferoj!"; //! let info = detect(text).unwrap(); //! assert_eq!(info.lang(), Lang::Epo); //! assert_eq!(info.script(), Script::Latin); //! //! // Confidence is in the range from 0 to 1. //! assert_eq!(info.confidence(), 1.0); //! assert!(info.is_reliable()); //! ``` //! //! Using `Detector` with specified blacklist or whitelist: //! //! ``` //! use whatlang::{Detector, Lang}; //! //! let whitelist = vec![Lang::Eng, Lang::Rus]; //! //! // You can also create detector using with_blacklist function //! let detector = Detector::with_whitelist(whitelist); //! let lang = detector.detect_lang("There is no reason not to learn Esperanto."); //! assert_eq!(lang, Some(Lang::Eng)); //! mod constants; mod detect; mod detector; mod info; mod lang; mod options; mod script; mod trigrams; mod utils; pub use crate::detector::Detector; pub use crate::info::Info; pub use crate::lang::Lang; pub use crate::options::Options; pub use crate::script::Script; pub use crate::detect::detect; pub use crate::detect::detect_lang; pub use crate::detect::detect_with_options; pub use crate::script::detect_script;