I have an issue with removing stopwords. When I execute my script:`
import nltk
from nltk.corpus import stopwords
file1=open('english.txt', 'r')
english=file1.read()
file1.close()
english_corpus_lowercase =([w.lower() for w in english])
english_without_punc=''.join([c for c in english_corpus_lowercase if c not in (",", "``", "`", "?", ".", ";", ":", "!", "''", "'", '"', "-", "(", ")")])
print(english_without_punc)
print(type(english_without_punc))
stopwords = nltk.corpus.stopwords.words('english')
print(stopwords)
english_corpus_sans_stopwords = set()
for w in english_without_punc:
if w not in stopwords:
english_corpus_sans_stopwords.add(w)
print(english_corpus_sans_stopwords)
It gives me the following. How could I fix it?
{'b', 'n', 'f', 'l', 'v', 'h', 'k', 'e', 'r', ' ', 'w', '“', 'g', 'u', 'p', 'c'}
{'b', 'n', 'f', 'l', 'v', 'h', 'k', 'e', 'r', ' ', 'w', '“', 'g', 'u', 'p', 'c'}
{'b', 'n', 'f', 'l', 'v', 'h', 'k', 'e', 'r', ' ', 'w', '“', 'g', 'u', 'p', 'c'}
{'b', 'n', 'f', 'l', 'v', 'h', 'k', 'e', 'r', ' ', 'w', '“', 'g', 'u', 'p', 'c'}
{'b', 'n', 'f', 'l', 'v', 'h', 'k', 'e', 'r', ' ', 'w', '“', 'g', 'u', 'p', 'c'}
{'b', 'n', 'f', 'l', 'v', 'h', 'k', 'e', 'r', ' ', 'w', '“', 'g', 'u', 'p', 'c'}
{'b', 'n', 'f', 'l', 'v', 'h', 'k', 'e', 'r', ' ', 'w', '“', 'g', 'u', 'p', 'c'}
{'b', 'n', 'f', 'l', 'v', 'h', 'k', 'e', 'r', ' ', 'w', '“', 'g', 'u', 'p', 'c'}
{'b', 'n', 'f', 'l', 'v', 'h', 'k', 'e', 'r', ' ', 'w', '“', 'g', 'u', 'p', 'c'}