Class

NSLinguisticTagger

Analyze natural language text to tag part of speech and lexical class, identify names, perform lemmatization, and determine the language and script.

Declaration

@interface NSLinguisticTagger : NSObject

Overview

NSLinguisticTagger provides a uniform interface to a variety of natural language processing functionality with support for many different languages and scripts. You can use this class to segment natural language text into paragraphs, sentences, or words, and tag information about those segments, such as part of speech, lexical class, lemma, script, and language.

When you create a linguistic tagger, you specify what kind of information you're interested in by passing one or more NSLinguisticTagScheme values. Set the string property to the natural language text you want to analyze, and the linguistic tagger processes it according to the specified tag schemes. You can then enumerate over the tags in a specified range, using the methods described in Enumerating Linguistic Tags, to get the information requested for a given scheme and unit.

Thread Safety

A single instance of NSLinguisticTagger should not be used simultaneously from multiple threads.

Topics

First Steps

Tokenizing Natural Language Text

Enumerate the words in a string.

- initWithTagSchemes:options:

Creates a linguistic tagger instance using the specified tag schemes and options.

string

The string being analyzed by the linguistic tagger.

Getting the Tag Schemes

+ availableTagSchemesForUnit:language:

Returns the tag schemes available for a particular unit and language on the current device.

+ availableTagSchemesForLanguage:

Returns the tag schemes available for a particular language on the current device.

tagSchemes

Returns the tag schemes configured for this linguistic tagger. For possible values, see NSLinguisticTagScheme.

Determining the Dominant Language and Orthography

+ dominantLanguageForString:

Returns the dominant language for the specified string.

dominantLanguage

Returns the dominant language of the string set for the linguistic tagger.

- orthographyAtIndex:effectiveRange:

Returns the orthography at the index and also returns the effective range.

- setOrthography:range:

Sets the orthography for the specified range.

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.

+ enumerateTagsForString:range:unit:scheme:options:orthography:usingBlock:

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

NSLinguisticTaggerOptions

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

Getting Linguistic Tags

- tagAtIndex:unit:scheme:tokenRange:

Returns a tag for a single scheme, for a given linguistic unit, at the specified character position.

- tagAtIndex:scheme:tokenRange:sentenceRange:

Returns a tag for a single scheme at the specified character position.

+ tagForString:atIndex:unit:scheme:orthography:tokenRange:

Returns a tag for a single scheme, for a given linguistic unit, at the specified character position in a string.

- tagsInRange:unit:scheme:options:tokenRanges:

Returns an array of linguistic tags and token ranges for a given string range and linguistic unit.

- tagsInRange:scheme:options:tokenRanges:

Returns an array of linguistic tags and token ranges for a given string range.

+ tagsForString:range:unit:scheme:options:orthography:tokenRanges:

Returns an array of linguistic tags and token ranges for a given string and linguistic unit.

Determining the Range of a Unit Token

- tokenRangeAtIndex:unit:

Returns the range of the linguistic unit containing the specified character index.

- sentenceRangeForRange:

Returns the range of a sentence containing the specified range.

Determining the Possible Tags

- possibleTagsAtIndex:scheme:tokenRange:sentenceRange:scores:

Returns an array of possible tags for the given scheme at the specified range, supplying matching scores.

Notifying for Changes to the Analyzed String

- stringEditedInRange:changeInLength:

Notifies the linguistic tagger that the string (if mutable) has changed as specified by the parameters.

Supporting Types

NSLinguisticTagScheme

Constants for the tag schemes specified when initializing a linguistic tagger.

NSLinguisticTaggerUnit

Constants representing linguistic units.

NSLinguisticTag

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

Relationships

Inherits From