Type Method


Enumerates over a given string and calls the specified block for each tag.


+ (void)enumerateTagsForString:(NSString *)string range:(NSRange)range unit:(NSLinguisticTaggerUnit)unit scheme:(NSLinguisticTagScheme)scheme options:(NSLinguisticTaggerOptions)options orthography:(NSOrthography *)orthography usingBlock:(void (^)(NSLinguisticTag tag, NSRange tokenRange, BOOL *stop))block;



The string to enumerate over.


The range to analyze.


The linguistic unit. For possible values, see NSLinguisticTaggerUnit


The tag scheme. For possible values, see NSLinguisticTagScheme.


The linguistic tagger options to use. See NSLinguisticTaggerOptions for possible values.


The orthography of the string. If unspecified, the orthography is automatically detected.


The block to apply to ranges of the string.

The block takes the following arguments:


The located linguistic tag.


The range of the linguistic tag.


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


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 NSLinguisticTagSchemeLexicalClass, 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 NSLinguisticTagSchemeLemma, 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 enumerateTagsInRange:unit:scheme:options:usingBlock: method. If you analyze the same string more than once, you should create a linguistic tagger object instead of calling this method.

See Also

Enumerating Linguistic Tags

Identifying Parts of Speech

Classify nouns, verbs, adjectives, and other parts of speech in a string.

Identifying People, Places, and Organizations

Use a linguistic tagger to perform named entity recognition on a string.

- enumerateTagsInRange:unit:scheme:options:usingBlock:

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

- enumerateTagsInRange:scheme:options:usingBlock:

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


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