NLTagScheme
Constants for the tag schemes specified when initializing a linguistic tagger.
Declaration
struct NLTagSchemeOverview
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 availableTagSchemes(for: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 in NLTagger, the returned tag value depends on the specified scheme. For example, given the token “Überraschung”, the returned tag is noun when using the lexicalClass tag scheme, german (German language) when using the language tag scheme, and “Latn” (Latin script) when using the script 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