Skip to main content

most_likely_language

Function most_likely_language 

Source
pub fn most_likely_language(text: &str) -> Option<&'static str>
Available on crate feature language-detection only.
Expand description

The language a text is most like, by its code, or nothing for an empty text or one like none of them: music21’s LanguageDetector.mostLikelyLanguage. Where two are as alike, the first of LANGUAGE_CODES wins.

use music21_rs::features::language::most_likely_language;

let text = "Ich habe ein Buch, und ich gehe nach Hause mit meinem Bruder.";
assert_eq!(most_likely_language(text), Some("de"));
assert_eq!(most_likely_language(""), None);