【发布时间】:2020-08-18 09:54:20
【问题描述】:
我想将CountVectorizer 应用于包含单词和短语列表的列。换句话说,语料库不是一个字符串,而是一个列表。问题是CountVectorizer 或我遇到的任何其他相关函数都需要一个字符串作为输入。将列表加入一个字符串并进行标记是没有意义的,因为某些短语包含 2 个单词。有任何想法吗?
示例:
ID corpus
1 ["Harry Potter","Batman"]
2 ["Batman", "Superman", "Lord of the Rings"]
想要的结果:
ID Harry Potter Batman Superman Lord of the Rings
1 1 1 0 0
2 0 1 1 1
【问题讨论】:
标签: python scikit-learn nlp countvectorizer