<!--
{
  "availability" : [
    "iOS: 12.0.0 -",
    "iPadOS: 12.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.14.0 -",
    "tvOS: 12.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 5.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "NaturalLanguage",
  "identifier" : "/documentation/NaturalLanguage/NLLanguageRecognizer",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Natural Language"
    ],
    "preciseIdentifier" : "c:objc(cs)NLLanguageRecognizer"
  },
  "title" : "NLLanguageRecognizer"
}
-->

# NLLanguageRecognizer

The language of a body of text.

```
class NLLanguageRecognizer
```

## Overview

An [`NLLanguageRecognizer`](/documentation/NaturalLanguage/NLLanguageRecognizer) object automatically detects the language of a piece of text. It performs language identification by:

1. Identifying the dominant script of a piece of text. Some languages have a unique script (like Greek), but others share the same script (like English, French, and German, which all share the Latin script).
2. Identifying the language itself.

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

Use the convenience method, [`dominantLanguage(for:)`](/documentation/NaturalLanguage/NLLanguageRecognizer/dominantLanguage(for:)), to get the most likely language without creating an [`NLLanguageRecognizer`](/documentation/NaturalLanguage/NLLanguageRecognizer).

> Important:
> Don’t use an instance of ``doc://com.apple.naturallanguage/documentation/NaturalLanguage/NLLanguageRecognizer`` from more than one thread simultaneously.

## Topics

### Creating a recognizer

[`init()`](/documentation/NaturalLanguage/NLLanguageRecognizer/init())

Creates a recognizer that you can customize.

### Determining the language

[`dominantLanguage(for:)`](/documentation/NaturalLanguage/NLLanguageRecognizer/dominantLanguage(for:))

Finds the most likely language of a piece of text.

[`processString(_:)`](/documentation/NaturalLanguage/NLLanguageRecognizer/processString(_:))

Analyzes the piece of text to determine its dominant language.

[`dominantLanguage`](/documentation/NaturalLanguage/NLLanguageRecognizer/dominantLanguage)

The most likely language for the processed text.

[`languageHypotheses(withMaximum:)`](/documentation/NaturalLanguage/NLLanguageRecognizer/languageHypotheses(withMaximum:))

Generates the probabilities of possible languages for the processed text.

[`languageHypothesesWithMaximum:`](/documentation/NaturalLanguage/NLLanguageRecognizer/languageHypothesesWithMaximum:)

Generates the probabilities of possible languages for the processed text.

[`reset()`](/documentation/NaturalLanguage/NLLanguageRecognizer/reset())

Resets the recognizer to its initial state.

### Guiding the recognizer

[`languageHints`](/documentation/NaturalLanguage/NLLanguageRecognizer/languageHints-3gy00)

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

[`languageHints`](/documentation/NaturalLanguage/NLLanguageRecognizer/languageHints-7dwgv)

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

[`languageConstraints`](/documentation/NaturalLanguage/NLLanguageRecognizer/languageConstraints)

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



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)