【发布时间】:2018-02-23 12:49:40
【问题描述】:
鉴于以下文件列表:
docs = [
'feature one`feature two`feature three',
'feature one`feature two`feature four',
'feature one'
]
我想使用 scikit 中的任何一个矢量化器类(CountVectorizer 或 TfidfVectorizer),'feature one'、'feature two'、'feature three' 和 'feature four' 应该是矩阵中表示的四个特征.
我试过了:
vec = CountVectorizer(token_pattern='(?u)\w+\s.\w.`')
但这只会返回这个:
['feature one`', 'feature two`']
【问题讨论】:
-
您能详细说明一下吗?目前还不清楚。反引号字符对您有特殊含义吗?
-
我使用反引号字符作为自定义分隔符。我猜这与使用逗号分隔 CSV 中的字段没有什么不同。
标签: python scikit-learn