0% found this document useful (0 votes)
15 views2 pages

DBMS

Uploaded by

khushiyadav88400
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

DBMS

Uploaded by

khushiyadav88400
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

EXPERIMENT-09

Program: Write a python program to POS (Parts of Speech) tagging for the
give sentence usingNLTK?

Source Code: : import nltk


nltk.download('punkt')

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?

Source Code:- from nltk.stem import WordNetLemmatizer


nltk.download('wordnet')

nltk.download('punkt')

def lemmatization(sentence):

lemmatizer = WordNetLemmatizer()

words = nltk.word_tokenize(sentence)

return ' '.join([lemmatizer.lemmatize(word) for word in words])

# Example usage
sentence = "The striped striped cats are running faster."

result = lemmatization(sentence)

print(result)

Output:
"The striped striped cats are running faster."

You might also like