Classify nouns, verbs, adjectives, and other parts of speech in a string.
- Natural Language
Identifying the parts of speech for words in natural language text can help your program understand the meaning of sentences. For example, provided the transcription of a request spoken by the user, you might programmatically determine general intent by looking at only the nouns and verbs.
The example below shows how to use NLTagger to enumerate over natural language text and identify the part of speech for each word.
Create an instance of
NLTagas the tag scheme to be used.
Scheme Lexical Class
Set the string property of the linguistic tagger to the natural language text.
Create the options to omit punctuation and whitespace.
In the enumeration block, take a substring of the original text at
tokento obtain each word.
Run this code to print out each word and its part of speech on a new line.