Amazing technological breakthrough possible @S-Logix pro@slogix.in

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • pro@slogix.in
  • +91- 81240 01111

Social List

How to remove stopwords un the text data using nltk in python

Description

To write piece of python code to remove stopwords (Useless words) from the text data using python.

Input

Text data.

Output

Stop word removed sentence.

Process

  Import nltk library.

  Took sample text data.

  Do tokenize the words in the text data.

  Compare text data with stop words using loops.

  Print the filtered sentence.

Sample Code

#import libraries
import nltk
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
stopwords = list(stopwords.words(‘english’))

print(“Common stopwords are\n\n”,stopwords,”\n”)

text =’python is a scripting language it is as one of the general purpose language’
print(“Original text\n”,text)

filtered_sentence = []
word_tokens = word_tokenize(text)
print(“\n”)
print(“Tokinized sentence”)

for w in word_tokens:
if w not in stopwords:
filtered_sentence.append(w)

print(word_tokens)
print(“\n”)
print(“After removal of stopwords\n”,filtered_sentence)

Screenshots
remove stopwords un the text data using nltk in python
import libraries