Expand description
A port of langdetect (itself a port of Nakatani
Shuyo’s language-detection) that reproduces its results bit for bit, including the random
walk: with the same seed, the probabilities equal those of langdetect 1.0.9 on the CPython
version selected by Compat.
use langdetect::{DetectorFactory, Seed};
assert_eq!(langdetect::detect("Ein, zwei, drei, vier").unwrap(), "de");
let mut factory = DetectorFactory::builtin().clone();
factory.seed = Seed::Int(0);
let langs = factory.detect_langs("Ceci est une phrase en français.").unwrap();
assert_eq!(langs[0].lang, "fr");Modules§
- text
- Text preprocessing of
Detector.append,Detector.cleaning_textandNGram.
Structs§
- Compat
- The Python behaviour to reproduce. Results are bit-identical to langdetect running on a CPython whose version matches these settings.
- Detect
Options - Options of one detection, the attributes of
langdetect.detector.Detector. - Detector
- Detects the language of the appended text, the equivalent of
langdetect.detector.Detector. - Detector
Factory - Language profiles and n-gram probabilities, the equivalent of
DetectorFactory. - Lang
Profile - A language profile: n-gram counts and the total number of 1-, 2- and 3-grams.
- Language
- A detected language and its probability.
Enums§
- Error
- An error, mirroring the exception langdetect raises in the same situation.
- Error
Code - Error codes of
langdetect.lang_detect_exception.ErrorCode. - Seed
- Seed of the random walk, mirroring
DetectorFactory.seed. - SumMode
- How
sum()adds the probabilities when they are normalised. - Unicode
Version - Unicode version that decides which characters
str.isupper()reports as uppercase.
Functions§
- detect
- The most probable language of
textwith the built-in profiles and a random seed. - detect_
langs - Languages of
textwith probability above 0.1, most probable first.