Applications of POS tagging

POS tagging finds applications in Named Entity Recognition (NER), sentiment analysis, question answering, and word sense disambiguation. We will look at an example of word sense disambiguation in the following code. In the sentences I left the room and Left of the room, the word left conveys different meanings. A POS tagger would help to differentiate between the two meanings of the word left. We will now look at how these two different usages of the same word are tagged:

>>> import nltk>>> text1 = nltk.word_tokenize("I left the room")>>> text2 = nltk.word_tokenize("Left of the room")>>> nltk.pos_tag(text1,tagset='universal')[('I', 'PRON'), ('left', 'VERB'), ('the', 'DET'), ('room', 'NOUN')]>>> nltk.pos_tag(text2, ...

Get Hands-On Natural Language Processing with Python 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.