Instance Method

enumerateTagsInRange:unit:scheme:options:usingBlock:

Enumerates a block over the tagger’s string, given a range, token unit, and tag scheme.

Declaration

- (void)enumerateTagsInRange:(NSRange)range unit:(NLTokenUnit)unit scheme:(NLTagScheme)scheme options:(NLTaggerOptions)options usingBlock:(void (^)(NLTag tag, NSRange tokenRange, BOOL *stop))block;

Parameters

range

The range of the string you want the tagger to analyze.

unit

The linguistic unit of scale you’re interested in, such as NLTokenUnitWord, NLTokenUnitSentence, NLTokenUnitParagraph, or NLTokenUnitDocument.

scheme

The tag scheme the tagger uses to tag the string, such as NLTagSchemeLanguage or NLTagSchemeScript. This scheme determines which types of NLTag the method passes to your block. For other tag schemes, see NLTagScheme.

options

The set of linguistic tagger options to use, such as NLTaggerOmitWhitespace. For all available options, see NLTaggerOptions.

block

The block this method uses to iterate over the tagger’s string property. The block has the following parameters:

tag

The tag of the token.

tokenRange

The range of the token.

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

Use this method to iterate your block over the given range of a string. The method divides up the string with the given NLTokenUnit and NLTagScheme and then calls your block. For example, use the NLTagSchemeLexicalClass tag scheme to identify which tokens are parts of speech, types of whitespace, or types of punctuation. Use the NLTagSchemeLemma tag scheme to identify the stem form of each word token, if known.

See Also

Enumerating Linguistic Tags

NLTaggerOptions

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

NLTag

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