---
title: MLGazetteer
framework: createml
role: symbol
role_heading: Structure
path: createml/mlgazetteer
---

# MLGazetteer

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

## Declaration

```swift
struct MLGazetteer
```

## Overview

Overview Use an 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 NLGazetteer, which augments an 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. 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, save it to an .mlmodel file to include in your app. 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:)](createml/mlgazetteer/init(dictionary:parameters:).md)
- [init(labeledData:textColumn:labelColumn:parameters:)](createml/mlgazetteer/init(labeleddata:textcolumn:labelcolumn:parameters:).md)
- [MLGazetteer.ModelParameters](createml/mlgazetteer/modelparameters-swift.struct.md)
- [modelParameters](createml/mlgazetteer/modelparameters-swift.property.md)

### Testing a gazetteer

- [prediction(from:)](createml/mlgazetteer/prediction(from:).md)
- [predictions(from:)](createml/mlgazetteer/predictions(from:).md)
- [predictions(from:)](createml/mlgazetteer/predictions(from:)-2rej.md)
- [predictions(from:)](createml/mlgazetteer/predictions(from:)-2jaui.md)

### Saving a gazetteer

- [write(to:metadata:)](createml/mlgazetteer/write(to:metadata:).md)
- [write(toFile:metadata:)](createml/mlgazetteer/write(tofile:metadata:).md)

### Describing a gazetteer

- [model](createml/mlgazetteer/model.md)
- [description](createml/mlgazetteer/description.md)
- [debugDescription](createml/mlgazetteer/debugdescription.md)
- [playgroundDescription](createml/mlgazetteer/playgrounddescription.md)

### Default Implementations

- [CustomDebugStringConvertible Implementations](createml/mlgazetteer/customdebugstringconvertible-implementations.md)
- [CustomPlaygroundDisplayConvertible Implementations](createml/mlgazetteer/customplaygrounddisplayconvertible-implementations.md)
- [CustomStringConvertible Implementations](createml/mlgazetteer/customstringconvertible-implementations.md)

## Relationships

### Conforms To

- [Copyable](swift/copyable.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomPlaygroundDisplayConvertible](swift/customplaygrounddisplayconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Escapable](swift/escapable.md)

## See Also

### Text models

- [Creating a text classifier model](createml/creating-a-text-classifier-model.md)
- [Creating a word tagger model](createml/creating-a-word-tagger-model.md)
- [MLTextClassifier](createml/mltextclassifier.md)
- [MLWordTagger](createml/mlwordtagger.md)
- [MLWordEmbedding](createml/mlwordembedding.md)
