NLP Laboratery Manual
NLP Laboratery Manual
BACHELOR OF TECHNOLOGY
7th - SEMESTER
Computer Science & Engineering Department
NAME :
Kasula PavanKumar
LABORATORY210303124588
MANUAL
ENROLLMENT NUMBER :
FACULTY OF ENGINEERING & TECHNOLOGY
Deep Learning With NLP Laboratory (203105477)
B. Tech – 4th Year 7th Semester
CERTIFICATE
Date of
Staff in charge HOD SIGNATURE
submission
INDEX
10
PRACTICAL – 01
AIM : Implementation of preprocessing of Text with NLTK (Tokenization, Stemming, Lemmatization and
removal of stop words in NLP.
# Install NLTK
!pip install nltk
nltk.download("all")
OUTPUT :
from nltk.tokenize import sent_tokenize, word_tokenize # Import both functions
text = """
I AM KASULA PAVANKUMAR PURSING MY BACHERLORS FROM PARUL UNIVERSITY AS A ARTIFICAL
INTELLIGENCE STUDENT IAM HAVNG PROFICIENT KNOWLEDGE IN MACHINE LEARNING AND DEEP
LEARNING AND WEB DEVELOPER
"""
# Sentence tokenization
sentences = sent_tokenize(text)
print("Sentence Tokenization:")
print(sentences)
# Word tokenization
words = word_tokenize(text) # Now you can use word_tokenize
print("\nWord Tokenization:")
4|Page ERP Number :210303124588
FACULTY OF ENGINEERING & TECHNOLOGY
Deep Learning With NLP Laboratory (203105477)
B. Tech – 4th Year 7th Semester
print(words)
OUTPUT :
from nltk.stem import PorterStemmer
# Apply stemming
stemmed_words = [stemmer.stem(word) for word in words]
print("\nStemming:")
print(stemmed_words)
OUTPUT :
from nltk.stem import WordNetLemmatizer
# Apply lemmatization
lemmatized_words = [lemmatizer.lemmatize(word) for word in words]
print("\nLemmatization:")
print(lemmatized_words)
OUTPUT :
OUTPUT :