Skip to main content

Module language

Module language 

Source
Available on crate feature language-detection only.
Expand description

Which language a text is in: music21’s LanguageDetector, with the language-detection feature. Which language a text is in, by the letters that follow each pair of letters: music21’s text.LanguageDetector and text.Trigram.

Each language is known by a long text in it, the excerpts music21 carries from Project Gutenberg (in src/features/language/, as music21 has them). A text is compared with each by how alike their counts of letter-after-two-letters are, and is in the language it is most like.

Structs§

Trigram
How often each letter follows each pair of letters in a text: music21’s Trigram.

Constants§

LANGUAGE_CODES
The languages known, in music21’s order: English, French, Italian, German, Chinese, Latin and Dutch.

Functions§

language_name
The name of each language music21 knows, by its code.
most_likely_language
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.
most_likely_language_numeric
The language a text is most like, as one more than its place in LANGUAGE_CODES, or nought for an empty text: music21’s mostLikelyLanguageNumeric.