pan*_*Box 25 python stop-words scikit-learn
Scikit-learn的CountVectorizer类允许您将字符串'english'传递给参数stop_words.我想在此预定义列表中添加一些内容.谁能告诉我怎么做?
jon*_*rpe 50
根据源代码为sklearn.feature_extraction.text,完整列表(实际上是frozenset,从stop_words)的ENGLISH_STOP_WORDS通过暴露__all__.因此,如果您想使用该列表加上一些项目,您可以执行以下操作:
from sklearn.feature_extraction import text
stop_words = text.ENGLISH_STOP_WORDS.union(my_additional_stop_words)
Run Code Online (Sandbox Code Playgroud)
(其中my_additional_stop_words是任何字符串序列)并使用结果作为stop_words参数.此输入将CountVectorizer.__init__被解析_check_stop_list,将frozenset直接传递新的输入.
| 归档时间: |
|
| 查看次数: |
14414 次 |
| 最近记录: |