DBMS
DBMS
Program: Write a python program to POS (Parts of Speech) tagging for the
give sentence usingNLTK?
nltk.download('averaged_perceptron_tagger')
def pos_tagging(sentence):
words = nltk.word_tokenize(sentence)
return nltk.pos_tag(words)
# Example usage
sentence = "The quick brown fox jumps over the lazy dog."
tags = pos_tagging(sentence)
print(tags)
Output:
[(‘The’, ‘DT’), (‘quick’, ‘JJ’), (‘brown’, ‘JJ’), (‘fox’, ‘NN’), (‘jumps’ ,
‘VBZ’) , (‘over’, ‘IN’), (‘the’, ‘DT’), (‘lazy’, ‘JJ’),(‘dog’ , ‘NN’)]
EXPERIMENT-10
Program: Write a python program to implement Lemmatization using
NLTK?
nltk.download('punkt')
def lemmatization(sentence):
lemmatizer = WordNetLemmatizer()
words = nltk.word_tokenize(sentence)
# Example usage
sentence = "The striped striped cats are running faster."
result = lemmatization(sentence)
print(result)
Output:
"The striped striped cats are running faster."