cld2/
lib.rs

1//! **DEPRECATED in favor of [whatlang][],** which is native Rust and
2//! smaller. If you have a compelling use-case for this code, please open
3//! an issue.
4//!
5//! [whatlang]: https://crates.io/crates/whatlang
6//!
7//! Detect the language of a string using the [cld2 library][cld2] from the
8//! Chromium project.
9//!
10//! ```
11//! use cld2::{detect_language, Format, Reliable, Lang};
12//!
13//! let text = "It is an ancient Mariner,
14//! And he stoppeth one of three.
15//! 'By thy long grey beard and glittering eye,
16//! Now wherefore stopp'st thou me?";
17//!
18//! assert_eq!((Some(Lang("en")), Reliable),
19//!            detect_language(text, Format::Text));
20//! ```
21//!
22//! This library wraps the `cld2-sys` library, which provides a raw
23//! interface to cld2.  The only major feature which isn't yet wrapped is
24//! the `ResultChunk` interface, because it tends to give fairly imprecise
25//! answers—it wouldn't make a very good multi-lingual spellchecker
26//! component, for example.  As always, pull requests are eagerly welcome!
27//!
28//! WARNING: We assume that nobody tries to change the loaded `cld2` data
29//! tables or calls the C++ function `CLD2::DetectLanguageVersion` behind
30//! our backs.  These configuration and debugging APIs in `cld2` are not
31//! thread safe.
32//!
33//! For more information, see the [GitHub project][github] for this
34//! library.
35//!
36//! [cld2]: https://code.google.com/p/cld2/
37//! [github]: https://github.com/emk/rust-cld2
38
39#![deny(missing_docs)]
40
41extern crate cld2_sys as ffi;
42#[macro_use]
43extern crate lazy_static;
44extern crate libc;
45
46pub use types::*;
47pub use detection::*;
48
49mod types;
50mod language;
51mod detection;