0% found this document useful (0 votes)
19 views1 page

Ir 1 Stop Word Removed

Uploaded by

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

Ir 1 Stop Word Removed

Uploaded by

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

!

pip install nltk

import nltk

from nltk.corpus import stopwords

from nltk.tokenize import word_tokenize

from nltk.stem import PorterStemmer

nltk.download('punkt')

nltk.download('stopwords')

def preprocess_text(text):

ps = PorterStemmer()

words = word_tokenize(text)

stop_words = set(stopwords.words('english'))

filtered_words = [word for word in words if word.lower() not in stop_words]

stemmed_words = [ps.stem(word) for word in filtered_words]

return ' '.join(stemmed_words)

sample_text='''The ultimate objective of NLP is to enable computers to understand, interpret, and


generate human language in a valuable way. This technology has transformed the way we interact
with machines, making it possible for us to use everyday language to communicate with devices.'''

nltk.download('punkt_tab')

processed_text = preprocess_text(sample_text)

print("Original Text:\n", sample_text)

print("\nProcessed Text:\n", processed_text)

You might also like