Word tagging

Tagging, or POS-Tagging, is the association between a word (or a token) and its part-of-speech tag (POS-Tag). After tagging, you know what (and where) the verbs, adjectives, nouns, and so on, are in the sentence. Even in this case, NLTK makes this complex operation very easy:

In: import nltk    print (nltk.pos_tag(nltk_tokens))Out: [('The', 'DT'), ('coolest', 'NN'), ('job', 'NN'), ('in', 'IN'),       ('the', 'DT'), ('next', 'JJ'), ('10', 'CD'), ('years', 'NNS'),       ('will', 'MD'), ('be', 'VB'), ('statisticians', 'NNS'), ('.', '.'),       ('People', 'NNS'), ('think', 'VBP'), ('I', 'PRP'), ("'m", 'VBP'),       ('joking', 'VBG'), (',', ','), ('but', 'CC'), ('who', 'WP'),       ('would', 'MD'), ("'ve", 'VB'), ('guessed', 'VBN'), ('that', 'IN'),  ('computer', ...

Get Python Data Science Essentials - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.