python – Iterable over raw text documents expected, string object received

python – Iterable over raw text documents expected, string object received

The cause of this problem is that input is just a string, but what is needed is a list (or an iterable) containing a single element (which is nothing but the string itself).

The error can be removed by adding the following line:

input=[input]

before

X_new_counts = count_vect.transform(input.plot_movie)

Input should be in Square Brackets.

input = [input]

cv = CountVectorizer()

cv.fit(input)

python – Iterable over raw text documents expected, string object received

Leave a Reply

Your email address will not be published. Required fields are marked *