Monday, November 14, 2022

AI/ML What is POS Tagging?

This is a mechanism for mark up the words in text format for a particular part of a speech based on its definition and context.

Some of the examples are 

JJS adjective, superlative (largest)

LS list market

MD modal (could, will)

NN noun, singular (cat, tree)

NNS noun plural (desks)

NNP proper noun, singular (sarah)

NNPS proper noun, plural (indians or americans)


To count tokens, 


from collections import Counter

import nltk

text = "Shiv is one of the best sites to learn WEB, SAP, Ethical Hacking and much more online."

lower_case = text.lower()

tokens = nltk.word_tokenize(lower_case)

tags = nltk.pos_tag(tokens)

counts = Counter( tag for word,  tag in tags)

print(counts)



references:

https://www.guru99.com/pos-tagging-chunking-nltk.html

No comments:

Post a Comment