<!--
{
  "availability" : [
    "macOS: 10.15.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CreateML",
  "identifier" : "/documentation/CreateML/MLGazetteer",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Create ML"
    ],
    "preciseIdentifier" : "s:8CreateML11MLGazetteerV"
  },
  "title" : "MLGazetteer"
}
-->

# MLGazetteer

A collection of terms and their labels, which augments a tagger that analyzes natural language text.

```
struct MLGazetteer
```

## Overview

Use an [`MLGazetteer`](/documentation/CreateML/MLGazetteer) to configure a gazetteer and save it to a file, which you then add to your app in Xcode.
Your app uses the gazetteer file at runtime to create an instance of
<doc://com.apple.documentation/documentation/NaturalLanguage/NLGazetteer>,
which augments an
<doc://com.apple.documentation/documentation/NaturalLanguage/NLTagger> to
tag specific terms with a label.

You configure a gazetteer with a dictionary, keyed by labels. Each value in the dictionary is an array
of terms (words or phrases) for each label. For example, you can store the names of real and fictional planets in a
gazetteer.

```swift
let planets = [
    "real planet": ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"],
    "fictional planet" : ["Arrakis", "Hoth", "Vulcan", "Pandora", "Tatooine", "Bajor", "Alderaan", "Romulus"]
]

let parameters = MLGazetteer.ModelParameters(language: .english)
let planetGazetteer = try! MLGazetteer(dictionary: planets, parameters: parameters)
```

Once you’ve configured an [`MLGazetteer`](/documentation/CreateML/MLGazetteer), save it to an `.mlmodel` file to include in your app.

```swift
try planetGazetteer.write(toFile: "~/Desktop/PlanetGazetteer.mlmodel")
```

A gazetteer file can efficiently store many labels, and many terms for each label.

## Topics

### Creating a gazetteer

[`init(dictionary:parameters:)`](/documentation/CreateML/MLGazetteer/init(dictionary:parameters:))

Creates a gazetteer from a dictionary of labels and terms.

[`init(labeledData:textColumn:labelColumn:parameters:)`](/documentation/CreateML/MLGazetteer/init(labeledData:textColumn:labelColumn:parameters:))

Creates a gazetteer from a table of labels and terms.

[`MLGazetteer.ModelParameters`](/documentation/CreateML/MLGazetteer/ModelParameters-swift.struct)

The model configuration parameters.

[`modelParameters`](/documentation/CreateML/MLGazetteer/modelParameters-swift.property)

The model configuration parameters.

### Testing a gazetteer

[`prediction(from:)`](/documentation/CreateML/MLGazetteer/prediction(from:))

Predicts the label for the given term.

[`predictions(from:)`](/documentation/CreateML/MLGazetteer/predictions(from:))

Predicts the labels for the given terms.

[`predictions(from:)`](/documentation/CreateML/MLGazetteer/predictions(from:)-2rej)

Predicts the labels for the given terms.

[`predictions(from:)`](/documentation/CreateML/MLGazetteer/predictions(from:)-2jaui)

Predicts the labels for the given terms in the table column.

### Saving a gazetteer

[`write(to:metadata:)`](/documentation/CreateML/MLGazetteer/write(to:metadata:))

Exports the gazetteer as a Core ML model file at the specified URL.

[`write(toFile:metadata:)`](/documentation/CreateML/MLGazetteer/write(toFile:metadata:))

Exports the gazetteer as a Core ML model file at the specified file path.

### Describing a gazetteer

[`model`](/documentation/CreateML/MLGazetteer/model)

The gazetteer contained within a Core ML model file stored in memory.

[`description`](/documentation/CreateML/MLGazetteer/description)

A text representation of the gazetteer.

[`debugDescription`](/documentation/CreateML/MLGazetteer/debugDescription)

A text representation of the gazetteer that’s suitable for output during debugging.

[`playgroundDescription`](/documentation/CreateML/MLGazetteer/playgroundDescription)

A description of the gazetteer shown in a playground.



---

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)