Class

NLLanguageRecognizer

The language of a body of text.

Declaration

class NLLanguageRecognizer : NSObject

Overview

The identification obtained from an NLLanguageRecognizer object can be either a single most likely language, access through dominantLanguage, or a set of language candidates with probabilities, using languageHypotheses(withMaximum:). You can reset the recognizer to its initial state, to be reused for new analysis.

Use the convenience method, dominantLanguage(for:), to get the most likely language without creating an NLLanguageRecognizer.

Topics

Creating a Recognizer

init()

Creates a recognizer that you can customize.

Determining the Language

class func dominantLanguage(for: String) -> NLLanguage?

Finds the most likely language of a piece of text.

func processString(String)

Analyzes the piece of text to determine its dominant language.

var dominantLanguage: NLLanguage?

The most likely language for the processed text.

func languageHypotheses(withMaximum: Int) -> [NLLanguage : Double]

Generates the probabilities of possible languages for the processed text.

func reset()

Resets the recognizer to its initial state.

Guiding the Recognizer

var languageHints: [NLLanguage : Double]

A dictionary that maps languages to their probabilities in the language identification process.

var languageConstraints: [NLLanguage]

Limits the set of possible languages that the recognizer will return.

Relationships

Inherits From

Conforms To

See Also

Language Identification

struct NLLanguage

The languages supported by the Natural Language framework.