<!--
{
  "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/NLTagger",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Natural Language"
    ],
    "preciseIdentifier" : "c:objc(cs)NLTagger"
  },
  "title" : "NLTagger"
}
-->

# NLTagger

A tagger that analyzes natural language text.

```
class NLTagger
```

## Overview

[`NLTagger`](/documentation/NaturalLanguage/NLTagger) supports many different languages and scripts. Use it to segment natural language text into paragraph, sentence, or word units and to tag each unit with information like part of speech, lexical class, lemma, script, and language.

When you create a linguistic tagger, you specify what kind of information you’re interested in by passing one or more [`NLTagScheme`](/documentation/NaturalLanguage/NLTagScheme) values. Set the [`string`](/documentation/NaturalLanguage/NLTagger/string) property to the natural language text you want to analyze, and the linguistic tagger processes it according to the specified tag schemes. You can then enumerate over the tags in a specified range, using the methods described in Enumerating linguistic tags, to get the information requested for a given scheme and unit.

> Important:
> Don’t use an instance of ``doc://com.apple.naturallanguage/documentation/NaturalLanguage/NLTagger`` simultaneously from multiple threads.

## Topics

### Creating a tagger

[`init(tagSchemes:)`](/documentation/NaturalLanguage/NLTagger/init(tagSchemes:))

Creates a linguistic tagger instance using the specified tag schemes and options.

[`string`](/documentation/NaturalLanguage/NLTagger/string)

The string being analyzed by the linguistic tagger.

### Getting the tag schemes

[`availableTagSchemes(for:language:)`](/documentation/NaturalLanguage/NLTagger/availableTagSchemes(for:language:))

Retrieves the tag schemes available for a particular unit (like word or sentence) and language on the current device.

[`requestAssets(for:tagScheme:completionHandler:)`](/documentation/NaturalLanguage/NLTagger/requestAssets(for:tagScheme:completionHandler:))

Asks the Natural Language framework to load any missing assets for a tag scheme onto the device for the given language.

[`NLTagger.AssetsResult`](/documentation/NaturalLanguage/NLTagger/AssetsResult)

The response to an asset request.

[`tagSchemes`](/documentation/NaturalLanguage/NLTagger/tagSchemes)

The tag schemes configured for this linguistic tagger.

[`NLTagScheme`](/documentation/NaturalLanguage/NLTagScheme)

Constants for the tag schemes specified when initializing a linguistic tagger.

### Determining the dominant language and orthography

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

The dominant language of the string set for the linguistic tagger.

[`setLanguage(_:range:)`](/documentation/NaturalLanguage/NLTagger/setLanguage(_:range:))

Sets the language for a range of text within the tagger’s string.

[`setLanguage:range:`](/documentation/NaturalLanguage/NLTagger/setLanguage:range:)

Sets the language for a range of text within the tagger’s string.

[`setOrthography(_:range:)`](/documentation/NaturalLanguage/NLTagger/setOrthography(_:range:))

Sets the orthography for the specified range.

[`setOrthography:range:`](/documentation/NaturalLanguage/NLTagger/setOrthography:range:)

Sets the orthography for the specified range.

### Enumerating linguistic tags

[`enumerateTags(in:unit:scheme:options:using:)`](/documentation/NaturalLanguage/NLTagger/enumerateTags(in:unit:scheme:options:using:))

Enumerates a block over the tagger’s string, given a range, token unit, and tag scheme.

[`enumerateTagsInRange:unit:scheme:options:usingBlock:`](/documentation/NaturalLanguage/NLTagger/enumerateTagsInRange:unit:scheme:options:usingBlock:)

Enumerates a block over the tagger’s string, given a range, token unit, and tag scheme.

[`NLTagger.Options`](/documentation/NaturalLanguage/NLTagger/Options)

Constants for linguistic tagger enumeration specifying which tokens to omit and whether to join names.

[`NLTag`](/documentation/NaturalLanguage/NLTag)

A token type, lexical class, name, lemma, language, or script returned by a linguistic tagger for natural language text.

### Getting linguistic tags

[`tags(in:unit:scheme:options:)`](/documentation/NaturalLanguage/NLTagger/tags(in:unit:scheme:options:))

Finds an array of linguistic tags and token ranges for a given string range and linguistic unit.

[`tagsInRange:unit:scheme:options:tokenRanges:`](/documentation/NaturalLanguage/NLTagger/tagsInRange:unit:scheme:options:tokenRanges:)

Finds an array of linguistic tags and token ranges for a given string range and linguistic unit.

[`tag(at:unit:scheme:)`](/documentation/NaturalLanguage/NLTagger/tag(at:unit:scheme:))

Finds a tag for a given linguistic unit, for a single scheme, at the specified character position.

[`tagAtIndex:unit:scheme:tokenRange:`](/documentation/NaturalLanguage/NLTagger/tagAtIndex:unit:scheme:tokenRange:)

Finds a tag for a given linguistic unit, for a single scheme, at the specified character position.

[`tagHypotheses(at:unit:scheme:maximumCount:)`](/documentation/NaturalLanguage/NLTagger/tagHypotheses(at:unit:scheme:maximumCount:))

Finds multiple possible tags for a given linguistic unit, for a single scheme, at the specified character position.

[`tagHypothesesAtIndex:unit:scheme:maximumCount:tokenRange:`](/documentation/NaturalLanguage/NLTagger/tagHypothesesAtIndex:unit:scheme:maximumCount:tokenRange:)

Finds multiple possible tags for a given linguistic unit, for a single scheme, at the specified character position.

### Determining the range of a unit token

[`tokenRange(at:unit:)`](/documentation/NaturalLanguage/NLTagger/tokenRange(at:unit:))

Returns the range of the linguistic unit containing the specified character index.

[`tokenRangeAtIndex:unit:`](/documentation/NaturalLanguage/NLTagger/tokenRangeAtIndex:unit:)

Returns the range of the linguistic unit containing the specified character index.

[`tokenRange(for:unit:)`](/documentation/NaturalLanguage/NLTagger/tokenRange(for:unit:))

Finds the entire range of all tokens of the specified linguistic unit contained completely or partially within the specified range.

[`tokenRangeForRange:unit:`](/documentation/NaturalLanguage/NLTagger/tokenRangeForRange:unit:)

Finds the entire range of all tokens of the specified linguistic unit contained completely or partially within the specified range.

[`NLTokenUnit`](/documentation/NaturalLanguage/NLTokenUnit)

Constants representing linguistic units.

### Using models with a tagger

[`setModels(_:forTagScheme:)`](/documentation/NaturalLanguage/NLTagger/setModels(_:forTagScheme:))

Assigns models for a tag scheme.

[`models(forTagScheme:)`](/documentation/NaturalLanguage/NLTagger/models(forTagScheme:))

Returns the models that apply to the given tag scheme.

### Using gazetteers with a tagger

[`setGazetteers(_:for:)`](/documentation/NaturalLanguage/NLTagger/setGazetteers(_:for:))

Attaches gazetteers to a tag scheme, typically one gazetteer per language or one language-independent gazetteer.

[`gazetteers(for:)`](/documentation/NaturalLanguage/NLTagger/gazetteers(for:))

Retrieves the gazetteers attached to a tag scheme.

[`NLGazetteer`](/documentation/NaturalLanguage/NLGazetteer)

A collection of terms and their labels, which take precedence over a word tagger.



---

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)