extern crate cld2;
use std::default::Default;
use cld2::{detect_language_ext, Format};
static TEXTS: &'static [&'static str] = &[
"It is an ancient Mariner,
And he stoppeth one of three.
'By thy long grey beard and glittering eye,
Now wherefore stopp'st thou me?",
"Sur le pont d'Avignon,
L'on y danse, l'on y danse,
Sur le pont d'Avignon
L'on y danse tous en rond.
Les belles dames font comme ça
Et puis encore comme ça.
Les messieurs font comme ça
Et puis encore comme ça.",
"It is an ancient Mariner,
And he stoppeth one of three.
'By thy long grey beard and glittering eye,
Now wherefore stopp'st thou me?
Sur le pont d'Avignon,
L'on y danse, l'on y danse,
Sur le pont d'Avignon
L'on y danse tous en rond.
Les belles dames font comme ça
Et puis encore comme ça.
Les messieurs font comme ça
Et puis encore comme ça.",
"𓂋𓏤𓈖𓉐𓂋𓏏𓂻𓅓𓉔𓂋𓅱𓇳",
"blah"
];
fn main() {
for (i, &text) in TEXTS.iter().enumerate() {
println!("=== Text #{}\n", i + 1);
let detected =
detect_language_ext(text, Format::Text, &Default::default());
println!("Language: {:?}", detected.language);
println!("Reliability: {:?}", detected.reliability);
println!("Bytes of text: {}", detected.text_bytes);
println!("\n= Per-language scores:\n");
for score in detected.scores.iter() {
println!("Language: {:?}", score.language);
println!("Percent of input: {}%", score.percent);
println!("Norm: {}\n", score.normalized_score);
}
}
}