Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

ARTIFICIAL INTELLIGENCE

LAB
MCA first year

Session: (2023-2024)

SUBMITTED BY: SUBMITTED TO:


Aadil khan Umakant Ahirwar
Roll No: 2384200001 (Class Advisor)

SECTION – A
Assignment
Q-1 Write a Python program to implement Lemmatization using NLTK.
import nltk
from nltk.tokenize import word_tokenize
from nltk.stem import WordNetLemmatizer

nltk.download('punkt')
nltk.download('wordnet')

def lemmatization(sentence):
words = word_tokenize(sentence)

lemmatizer = WordNetLemmatizer()

lemmatized_words = [lemmatizer.lemmatize(word) for word in words]

lemmatized_sentence = ' '.join(lemmatized_words)

return lemmatized_sentence

# Example usage:
if name == " main ":
sentence = "The quick brown foxes are jumping over the lazy dogs"
lemmatized_sentence = lemmatization(sentence)
print("Original sentence:", sentence)
print("Lemmatized sentence:", lemmatized_sentence)

Output
Python program to implement Breadth First

You might also like