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


@interface NLGazetteer : NSObject


Use an NLGazetteer to augment an 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 with its setGazetteers:forTagScheme: 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 MLGazetteer. Alternatively, you can create an NLGazetteer at runtime by using initWithDictionary:language:error:.


Creating a Gazetteer

+ initWithContentsOfURL:error:

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

- initWithData:error:

Creates a gazetteer from a data instance.

- initWithDictionary:language:error:

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

Looking Up Labels for Terms

- labelForString:

Retrieves the label for the given term.

Inspecting a Gazetteer


The gazetteer represented as a data instance.


The language of the gazetteer.

Type Methods

+ writeGazetteerForDictionary:language:toURL:error:

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


Inherits From

See Also

Using Gazetteers with a Tagger

- setGazetteers:forTagScheme:

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

- gazetteersForTagScheme:

Retrieves the gazetteers attached to a tag scheme.