This classifier assumes the text input is written in a unique language. The probabilities reflect the belief in which language the text is written, not the proportion of languages.

For large texts, the classifier randomly selects snippets to determine the overall language.

In the current version, all texts must be written in one of their official alphabets.

OpenersPrimaryExamplesSection(Spacer1)Examples  (8)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Determine the languages of a list of examples:

Classify["Language", {"the house is blue", "la maison est bleue", "la casa es azul", "das Haus ist blau", "房子是蓝色的", "المنزل باللون الأزرق", "будинок синій"}]

Obtain the probabilities for the most likely languages:

Classify["Language","ella","TopProbabilities"->3]

Obtain a (RefLink[ClassifierFunction, paclet:ref/ClassifierFunction]) for this classifier:

c=Classify["Language"]

Apply the classifier to a list of texts:

c[{"the house is blue", "la maison est bleue", "la casa es azul", "das Haus ist blau","در زندگی زخم‌های هست" , "房子是蓝色的", "المنزل باللون الأزرق", "будинок синій"}]

OpenersExampleSection1(Spacer1)Scope  (1)

Load the (RefLink[ClassifierFunction, paclet:ref/ClassifierFunction]) corresponding to the built-in classifier:

c=Classify["Language"]

Obtain the possible classes:

Information[c,"Classes"]

OpenersExampleSection2(Spacer1)Options  (3)

OpenersExampleSubsection0(Spacer1)ClassPriors  (1)

Use a custom (RefLink[ClassPriors, paclet:ref/ClassPriors]) to restrict the possible outputs:

Classify["Language",{"What is this language?","¿Qué idioma es ese?","Quelle est cette langue?"},ClassPriors-><|(Entity["English", Entity["Language","English"], "Entity[\"Language\", \"English\"]", "language"])->0.5,(Entity["Spanish", Entity["Language","Spanish"], "Entity[\"Language\", \"Spanish\"]", "language"])->0.5|>]

OpenersExampleSubsection1(Spacer1)IndeterminateThreshold  (1)

Use a custom (RefLink[IndeterminateThreshold, paclet:ref/IndeterminateThreshold]):

Classify["Language","المنزل",IndeterminateThreshold->0.9]

OpenersExampleSubsection2(Spacer1)UtilityFunction  (1)

Obtain the utility function of the classifier:

utility=Information[Classify["Language"],"UtilityFunction"];

Modify this utility function to penalize (Entity["Persian", Entity["Language","Persian"], "Entity[\"Language\", \"Persian\"]", "language"]) being misclassified as (Entity["Arabic", Entity["Language","Arabic"], "Entity[\"Language\", \"Arabic\"]", "language"]):

utility[(Entity["Persian", Entity["Language","Persian"], "Entity[\"Language\", \"Persian\"]", "language"]), (Entity["Arabic", Entity["Language","Arabic"], "Entity[\"Language\", \"Arabic\"]", "language"])]=-1.;

Classify the text using this new utility:

Classify["Language","منزل",UtilityFunction->utility]

Compare to the result with the default utility:

Classify["Language", "منزل"]

OpenersExampleSection3(Spacer1)Possible Issues  (1)

In some cases, non-language texts are still recognized as one language:

Classify["Language","poivreibflkqwhlqhrgw"]

OpenersExampleSection4(Spacer1)Neat Examples  (1)

Obtain different possible languages with their corresponding probabilities:

possiblelanguages=Classify["Language","Die in een cleyn dingh te prysen eenichsins aerdich","Probabilities"];

Visualize the result using (RefLink[WordCloud, paclet:ref/WordCloud]):

WordCloud[possiblelanguages]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[LanguageIdentify, paclet:ref/LanguageIdentify])  ▪  (RefLink[Classify, paclet:ref/Classify])  ▪  (RefLink[TextCases, paclet:ref/TextCases])  ▪  (RefLink[TextTranslation, paclet:ref/TextTranslation])  ▪  (RefLink[Transliterate, paclet:ref/Transliterate])  ▪  (RefLink[Language, paclet:ref/Language])}, {Related Classifiers:  (RefLink[FacebookTopic, paclet:ref/classifier/FacebookTopic])  ▪  (RefLink[Sentiment, paclet:ref/classifier/Sentiment])  ▪  (RefLink[ProgrammingLanguage, paclet:ref/classifier/ProgrammingLanguage])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/22-machine-learning.html])(WebLink[: Machine Learning, https://www.wolfram.com/language/elementary-introduction/22-machine-learning.html])}, {(WebLink[DocumentationFooterIconsRelatedLinks-NeuralNetRepository.png(Spacer1)Wolfram Neural Net Repository, https://resources.wolframcloud.com/NeuralNetRepository/])}, {(Spacer1)▪(RefLinkPlain[(Spacer1)Machine Learning, paclet:guide/MachineLearning])}})}})