NLTK Parts of Speech (POS) Tagging

To perform Parts of Speech (POS) Tagging with NLTK in Python, use nltk.pos_tag() method with tokens passed as argument.

The Natural Language Toolkit (NLTK) is a Python package for natural language processing. NLTK requires Python 3.5, 3.6, 3.7, 3.8, or 3.9. NLTK是Python上著名的⾃然语⾔处理库 ⾃带语料库,具有词性分类库 ⾃带分类,分词,等等功能。NLTK被称为“使用Python进行教学和计算语言学工作的绝佳工具”,以及“用自然语言进行游戏的神奇图书馆”。 安装语料库 pip install nltk.

where tokens is the list of words and pos_tag() returns a list of tuples with each

The prerequisite to use pos_tag() function is that, you should have averaged_perceptron_tagger package downloaded or download it programmatically before using the tagging method. In the following examples, we will use second method. The first method will be covered in: How to download nltk nlp packages?

Parts of Speech Tagging using NLTK

In the following example, we will take a piece of text and convert it to tokens. Then we shall do parts of speech tagging for these tokens using pos_tag() method.

The Parts Of Speech Tag List


In the above example, the output contained tags like NN, NNP, VBD, etc. Following is the complete list of such POS tags.

CC Coordinating Conjunction
CD Cardinal Digit
DT Determiner
EX Existential There. Example: “there is” … think of it like “there exists”)
FW Foreign Word.
IN Preposition/Subordinating Conjunction.
JJ Adjective.
JJR Adjective, Comparative.
JJS Adjective, Superlative.
LS List Marker 1.
MD Modal.
NN Noun, Singular.
NNS Noun Plural.
NNP Proper Noun, Singular.
NNPS Proper Noun, Plural.
PDT Predeterminer.
POS Possessive Ending. Example: parent’s
PRP Personal Pronoun. Examples: I, he, she
PRP$ Possessive Pronoun. Examples: my, his, hers
RB Adverb. Examples: very, silently,
RBR Adverb, Comparative. Example: better
RBS Adverb, Superlative. Example: best
RP Particle. Example: give up
TO to. Example: go ‘to’ the store.
UH Interjection. Example: errrrrrrrm
VB Verb, Base Form. Example: take
VBD Verb, Past Tense. Example: took
VBG Verb, Gerund/Present Participle. Example: taking
VBN Verb, Past Participle. Example: taken
VBP Verb, Sing Present, non-3d take
VBZ Verb, 3rd person sing. present takes
WDT wh-determiner. Example: which
WP wh-pronoun. Example: who, what
WP$ possessive wh-pronoun. Example: whose
WRB wh-abverb. Example: where, when

NLTK is a leading platform for building Python programs to work with human language data.It provides easy-to-use interfaces to over 50 corpora and lexicalresources such as WordNet,along with a suite of text processing libraries for classification, tokenization, stemming, tagging, parsing, and semantic reasoning,wrappers for industrial-strength NLP libraries,and an active discussion forum.

Thanks to a hands-on guide introducing programming fundamentals alongside topics in computational linguistics, plus comprehensive API documentation,NLTK is suitable for linguists, engineers, students, educators, researchers, and industry users alike.NLTK is available for Windows, Mac OS X, and Linux. Best of all, NLTK is a free, open source, community-driven project.

NLTK has been called “a wonderful tool for teaching, and working in, computational linguistics using Python,”and “an amazing library to play with natural language.”

Natural Language Processing with Python provides a practicalintroduction to programming for language processing.Written by the creators of NLTK, it guides the reader through the fundamentalsof writing Python programs, working with corpora, categorizing text, analyzing linguistic structure,and more.The online version of the book has been been updated for Python 3 and NLTK 3.(The original Python 2 version is still available at

Nltk Lemmatizer

Some simple things you can do with NLTK¶

Tokenize and tag some text:

Identify named entities:

Display a parse tree:

NB. If you publish work that uses NLTK, please cite the NLTK book asfollows:

Bird, Steven, Edward Loper and Ewan Klein (2009), Natural Language Processing with Python. O’Reilly Media Inc.

Nltk Sentiment

Next Steps¶