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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.