---
title: Identifying Parts of Speech
framework: foundation
role: article
role_heading: Article
path: foundation/identifying-parts-of-speech
---

# Identifying Parts of Speech

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

## Overview

Overview Identifying the parts of speech for words in natural language text can help your program understand the meaning of sentences. For example, given the transcription of a request spoken by the user, you might determine general intent by looking at only the nouns and verbs. The example below shows how to use NSLinguisticTagger to enumerate over natural language text and identify the part of speech for each word. let text = "The ripe taste of cheese improves with age." let tagger = NSLinguisticTagger(tagSchemes: [.lexicalClass], options: 0) tagger.string = text let range = NSRange(location: 0, length: text.utf16.count) let options: NSLinguisticTagger.Options = [.omitPunctuation, .omitWhitespace] tagger.enumerateTags(in: range, unit: .word, scheme: .lexicalClass, options: options) { tag, tokenRange, _ in     if let tag = tag {         let word = (text as NSString).substring(with: tokenRange)         print("\(word): \(tag)")     } } First, an instance of NSLinguisticTagger is created, specifying lexicalClass as the tag scheme to be used. Next, the string property of the linguistic tagger is set to the natural language text. Finally, the linguistic tagger enumerates over the entire range of the string, specifying NSLinguisticTaggerUnit.word as the tag unit and lexicalClass as the tag scheme, and omitting any punctuation or whitespace. In the enumeration block, the part of speech is provided by tag, and each word is obtained by taking a substring of the original text at tokenRange. When run, this code prints out each word and its part of speech on a new line, as shown below:  |   |   |   |   |   |   |   |   |

## See Also

### Related Documentation

- [Tokenizing Natural Language Text](foundation/tokenizing-natural-language-text.md)

### Enumerating Linguistic Tags

- [Identifying People, Places, and Organizations](foundation/identifying-people-places-and-organizations.md)
- [enumerateTags(in:unit:scheme:options:using:)](foundation/nslinguistictagger/enumeratetags(in:unit:scheme:options:using:).md)
- [enumerateTags(in:scheme:options:using:)](foundation/nslinguistictagger/enumeratetags(in:scheme:options:using:).md)
- [enumerateTags(for:range:unit:scheme:options:orthography:using:)](foundation/nslinguistictagger/enumeratetags(for:range:unit:scheme:options:orthography:using:).md)
- [NSLinguisticTagger.Options](foundation/nslinguistictagger/options.md)
