Main Content


Detect language of text


Use corpusLanguage to detect language of text.

The function supports English, Japanese, German, and Korean text.


language = corpusLanguage(str) detects the language of the text in str.


collapse all

Detect the language of a string array of text.

str = [
    "恋の悩みで 苦しむ。"
language = corpusLanguage(str)
language = 

Input Arguments

collapse all

Input text, specified as a string array, character vector, or cell array of character vectors.

Example: ["An example of a short sentence."; "A second short sentence."]

Data Types: string | char | cell

Output Arguments

collapse all

Detected language, returned as one of the following:

  • 'en' – Detected English text

  • 'ja' – Detected Japanese text

  • 'de' – Detected German text

  • 'ko' – Detected Korean text

Version History

Introduced in R2018b