as I understand I am trying to split the text i.e. input that we will get not the list, where am I going wrong?
While running the below code I am getting the error
AttributeError: 'list' object has no attribute 'split'
def remove_stopwords(text):
x=[]
for i in text.split():
# checking if the splitted word is in above imported stopwords list, if not, we are appending the word in an empty list
if i not in stopwords.words('english'):
x.append(i)
# copying the content of x to y before clearing x and making iit ready for next iteration
y=x[:]
x.clear()
return y
the text variable you are providing to the function is of a type
listinstead ofstr. Either your text is a list of texts and you want to do splitting for each text. then you need to loop over each one and call the function.Or you want to call this line prior to call your function