How can I use a list of lists, or a list of sets, for the TfidfVectorizer?

徘徊边缘 提交于 2019-12-06 06:26:56

Note that input1 works, but it considers each element of the list (string) as a different document to vectorize.

In the case of input2, I assume you want to vectorize each "sentence" (sublists). One solution is using the following list comprehension syntax:

input2_corrected = [" ".join(x) for x in input2]

which produces

['This is a test', 'It is raining today']

which does not yield the AttributeError anymore.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!