PoS stands for part of speech. The main objective of POS tagging is to discover the syntactic type of words, such as nouns, pronouns, adjectives, verbs, adverbs, and prepositions. PoS tagging finds the relationship among words within a sentence.
Let's see how to get POS tags for words using NLTK:
# import Word Tokenizer and PoS Tagger
from nltk.tokenize import word_tokenize
from nltk import pos_tag
# Sample sentence
sentence = "Taj Mahal is one of the beautiful monument."
# Tokenize the sentence
sent_tokens = word_tokenize(sentence)
# Create PoS tags
sent_pos = pos_tag(sent_tokens)
# Print tokens with PoS
print(sent_pos)
This results in the following output:
[('Taj', 'NNP'), ('Mahal', 'NNP'), ('is', 'VBZ'), ('one', 'CD'), ('of', 'IN'), ('the', 'DT'), ('beautiful', 'JJ'), ('monument', 'NN'), ('.', &apos...