Instance Method

enumerateTags(in:unit:scheme:options:using:)

Enumerates over a given range of the string for a particular unit and calls the specified block for each tag.

Declaration

@nonobjc func enumerateTags(in range: Range<String.Index>, unit: NLTokenUnit, scheme: NLTagScheme, options: NLTagger.Options = [], using block: (NLTag?, Range<String.Index>) -> Bool)

Parameters

range

The range to analyze.

unit

The linguistic unit. For possible values, see NLTokenUnit.

scheme

The tag scheme. For possible values, see NLTagScheme.

options

The linguistic tagger options to use. For possible values, see NLTagger.Options.

block

The block to apply to ranges of the string.

The block takes the following arguments:

tag

The located linguistic tag.

tokenRange

The range of the linguistic tag.

stop

A reference to a Boolean value. The block can set the value to true to stop further processing of the set. The stop argument is an out-only argument. You should only ever set this Boolean to true within the block.

Discussion

This method’s block is called for all tokens intersecting a given range, supplying tags and ranges. The tagger segments the string into sentences and tokens as necessary, and return those ranges along with a tag for any scheme in its array of tag schemes. For example, if the tag scheme is lexicalClass, the tags specify the part of speech (for word tokens) or the type of whitespace or punctuation (for whitespace or punctuation tokens). If the tag scheme is lemma, the tags specify the stem form of the word (if known) for each word token.

See Also

Enumerating Linguistic Tags

struct NLTagger.Options

Constants for linguistic tagger enumeration specifying which tokens to omit and whether to join names.

struct NLTag

A token type, lexical class, name, lemma, language, or script returned by a linguistic tagger for natural language text.

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