Type Alias

NLTagScheme

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

Declaration

typedef NSString *NLTagScheme;

Discussion

When initializing a linguistic tagger with init(_:), you specify one or more tag schemes that correspond to the kind of information you're interested in for a selection of natural language text. To ensure optimal performance, avoid specifying tag schemes that you won't use.

Some tag schemes are only available for certain units and languages. Use availableTagSchemesForUnit:language: to determine the possible values for a specified language and linguistic unit.

When working with linguistic tags using the methods described in Getting Linguistic Tags and Enumerating Linguistic Tags, the returned tag value depends on the specified scheme. For example, given the token "Überraschung", the returned tag is NLTagNoun when using the NLTagSchemeLexicalClass tag scheme, NLLanguageGerman (German language) when using the NLTagSchemeLanguage tag scheme, and "Latn" (Latin script) when using the NLTagSchemeScript tag scheme, as shown in the following code.

let tagger = NLTagger(tagSchemes: [.lexicalClass, .language, .script], options: 0)
tagger.string = "Überraschung"

tagger.tag(at: 0, unit: .word, scheme: .lexicalClass, tokenRange: nil) // Noun
tagger.tag(at: 0, unit: .word, scheme: .language, tokenRange: nil) // german
tagger.tag(at: 0, unit: .word, scheme: .script, tokenRange: nil) // Latn

Topics

Schemes

NLTagSchemeTokenType

A scheme that classifies tokens according to their broad type: word, punctuation, or whitespace.

NLTagSchemeLexicalClass

A scheme that classifies tokens according to class: part of speech, type of punctuation, or whitespace.

NLTagSchemeNameType

A scheme that classifies tokens according to whether they are part of a named entity.

NLTagSchemeNameTypeOrLexicalClass

A scheme that classifies tokens corresponding to names according to NLTagSchemeNameType, and classifies all other tokens according to NLTagSchemeLexicalClass.

NLTagSchemeLemma

A scheme that supplies a stem form of a word token, if known.

NLTagSchemeLanguage

A scheme that supplies the language for a token, if it can determine one.

NLTagSchemeScript

A scheme that supplies the script for a token, if it can determine one..

NLTagSchemeSentimentScore

A scheme that scores text as positive, negative, or neutral based on its sentiment polarity.

Beta

See Also

Getting the Tag Schemes

+ availableTagSchemesForUnit:language:

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

+ requestAssetsForLanguage:tagScheme:completionHandler:

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

Beta
NLTaggerAssetsResult

The response to an asset request.

Beta
tagSchemes

The tag schemes configured for this linguistic tagger.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software