Help: Mystery Friend project error

Hi all,

Seek your help to identify and eliminate error in the code.
Any help would be really appreciated. Thanks!

About the project: This code is an input to the Mystery Friend project, part of the Natural Language Processing, Bag of Words project.

There is an error in line 35, referred to other codes in the project as well, they seem to work with the same input.


Code error
Traceback (most recent call last):
File “”, line 35, in
File “/usr/local/lib/python3.6/dist-packages/sklearn/feature_extraction/”, line 860, in fit_transform
"Iterable over raw text documents expected, "
ValueError: Iterable over raw text documents expected, string object received.


Hi, @kabir_jain.

In this line, what type of object should be passed to the fit_transform method?:


See instruction 4.

Edited on August 9, 2020 to add the following:

Link to project: Learn Natural Language Processing: Mystery Friend

Hi @appylpye,

Thanks for the response.

I understand that it needs to be a vectorized form of the string i.e. mystery_postcard.
I tried this, mystery_vector=bow_vectorizer.transform(mystery_postcard) in the code. It gives an error in line 35.

Am I missing anything in the code? :sweat_smile:

You need to pass a list of one or more strings to the bow_vectorizer.transform() method. Enclose mystery_postcard in square brackets, as follows:


Thanks so much! The code worked.

1 Like