enumerateTags(for:range:unit:scheme:options:orthography:using:)
Enumerates over a given string and calls the specified block for each tag.
Declaration
class func enumerateTags(for string: String, range: NSRange, unit: NSLinguisticTaggerUnit, scheme: NSLinguisticTagScheme, options: NSLinguisticTagger.Options = [], orthography: NSOrthography?, using block: (NSLinguisticTag?, NSRange, UnsafeMutablePointer<ObjCBool>) -> Void)Parameters
- string:
The string to enumerate over.
- range:
The range to analyze.
- unit:
The linguistic unit. For possible values, see Nslinguistictaggerunit
- scheme:
The tag scheme. For possible values, see Nslinguistictagscheme.
- options:
The linguistic tagger options to use. See Options for possible values.
- orthography:
The orthography of the string. If unspecified, the orthography is automatically detected.
- block:
The block to apply to ranges of the string.
The block takes the following arguments:
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.
This is a convenience method for initializing a linguistic tagger, setting the string property, and calling the enumerateTags(in:unit:scheme:options:using:) method. If you analyze the same string more than once, you should create a linguistic tagger object instead of calling this method.