I would like to remove stop words from the arraylist named arrayList1, which is stored in the data variable. I try the below method but it does not work. Please help me check the below codes and improve the codes.Thanks.
import Retrieve_ED_Notes
from nltk.corpus import stopwords
data = Retrieve_ED_Notes.arrayList1
stop_words = set(stopwords.words('english'))
def remove_stopwords(data):
data = [word for word in data if word not in stop_words]
return data
for i in range(0, len(remove_stopwords(data))):
print(remove_stopwords(data[i]))
Console output of the arrayList1:
1|I really love writing journals
2|The mat is very comfortable and I will buy it again likes
3|The mousepad is smooth
1|I really love writing journals
4|This pen is very special to me.
4|This pencil is very special to me.
5|Meaningful novels
4|It brights up my day like a lighter and makes me higher.
6|School foolscap
7|As soft as my heart.lovey
convert the word to lower and check with stopwords.