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

# NLGazetteer

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

```
class NLGazetteer
```

## Overview

Use an [`NLGazetteer`](/documentation/NaturalLanguage/NLGazetteer) to augment an [`NLTagger`](/documentation/NaturalLanguage/NLTagger) when you need to tag a specific set of terms (single words or short phrases) with a label. Typically, you add one gazetteer per language, or one language-independent gazetteer, to an [`NLTagger`](/documentation/NaturalLanguage/NLTagger) with its [`setGazetteers(_:for:)`](/documentation/NaturalLanguage/NLTagger/setGazetteers(_:for:)) method. The tagger uses its gazetteers to look up each term it processes. If a gazetteer has a label for a term, the tagger uses that label to tag the term, instead of inferring a tag itself.

Typically, you create a gazetteer at development time, such as in a macOS playground, with Create ML’s <doc://com.apple.documentation/documentation/CreateML/MLGazetteer>. Alternatively, you can create an [`NLGazetteer`](/documentation/NaturalLanguage/NLGazetteer) at runtime by using [`init(dictionary:language:)`](/documentation/NaturalLanguage/NLGazetteer/init(dictionary:language:)).

## Topics

### Creating a Gazetteer

[`-  initWithContentsOfURL:error:`](/documentation/NaturalLanguage/NLGazetteer/init(contentsOf:))

Creates a Natural Language gazetteer from a model created with the Create ML framework.

[`+  gazetteerWithContentsOfURL:error:`](/documentation/NaturalLanguage/NLGazetteer/gazetteerWithContentsOfURL:error:)

Creates a Natural Language gazetteer from a model created with the Create ML framework.

[`-  initWithData:error:`](/documentation/NaturalLanguage/NLGazetteer/init(data:))

Creates a gazetteer from a data instance.

[`-  initWithDictionary:language:error:`](/documentation/NaturalLanguage/NLGazetteer/init(dictionary:language:))

Creates a gazetteer from a set of labels for terms represented by a dictionary.

[`+  writeGazetteerForDictionary:language:toURL:error:`](/documentation/NaturalLanguage/NLGazetteer/write(_:language:to:))

Creates a gazetteer from a set of labels for terms represented by a dictionary and saves the gazetteer to a file.

### Looking Up Labels for Terms

[`-  labelForString:`](/documentation/NaturalLanguage/NLGazetteer/label(for:))

Retrieves the label for the given term.

### Inspecting a Gazetteer

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

The gazetteer represented as a data instance.

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

The language of the gazetteer.

## Relationships

### Conforms To

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Hashable`](/documentation/Swift/Hashable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)