Skip to main content

Module language

Module language 

Source
Expand description

Which language a text is in: music21’s Trigram, and its 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.

A Trigram needs none of that and is always here; the excerpts, and what reads a text against them, come with the language-detection feature.

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§

known_trigramlanguage-detection
The trigrams of a language’s excerpt, by its code: what music21’s LanguageDetector.trigrams holds.
language_name
The name of each language music21 knows, by its code.
most_likely_languagelanguage-detection
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_numericlanguage-detection
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.