JRu*_*Run 5 python tokenize feature-extraction kwargs scikit-learn
我有一个带有一些关键字参数的自定义tokenizer函数:
def tokenizer(text, stem=True, lemmatize=False, char_lower_limit=2, char_upper_limit=30):
do things...
return tokens
Run Code Online (Sandbox Code Playgroud)
现在,我怎么能把这个带有所有参数的tokenizer传递给CountVectorizer?我没有尝试过任何作品; 这也不起作用:
from sklearn.feature_extraction.text import CountVectorizer
args = {"stem": False, "lemmatize": True}
count_vect = CountVectorizer(tokenizer=tokenizer(**args), stop_words='english', strip_accents='ascii', min_df=0, max_df=1., vocabulary=None)
Run Code Online (Sandbox Code Playgroud)
任何帮助深表感谢.提前致谢.
本tokenizer
应是一个可调用的或无.
(这是tokenizer=tokenize(**args)
一个拼写错误?上面的函数名称是tokenizer
.)
你可以试试这个:
count_vect = CountVectorizer(tokenizer=lambda text: tokenizer(text, **args), stop_words='english', strip_accents='ascii', min_df=0, max_df=1., vocabulary=None)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5032 次 |
最近记录: |