from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
import nltk

nltk.download('punkt')
nltk.download('stopwords')

text = "This is a sample sentence showing stop words removal"

words = word_tokenize(text)
stop = set(stopwords.words('english'))

filtered = [w for w in words if w not in stop]

print(filtered)


for zex #stopword 

stop_words = { "a", "an", "the", "is", "are", "was", "were", "in", "on", "at", "of", "and", "or", "to", "for", "with", "as", "by", "this", "that", "it", "from", "be", "has", "have", "had"}
text = input("enter text")
words = text.lower().split()
filterword = [w for w in words if w not in stop_words]
processed_text = " ".join(filterword)
print(processed_text)




##PREPROCESSING BY FILE IMPORTING

from nltk.corpus import stopwords
import nltk

nltk.download('stopwords')

text = open("prac7.txt").read().lower().split()
stop = set(stopwords.words('english'))

filtered = [w for w in text if w not in stop]

open("outputdoc.txt", "w").write(" ".join(filtered))
print(filtered)

