【问题标题】:Sklearn CountVectorizer token_pattern that allows strings with any charactersSklearn CountVectorizer token_pattern 允许带有任何字符的字符串
【发布时间】:2019-12-16 14:36:24
【问题描述】:

我想为CountVectorizer (docs) 编写一个token_pattern=,它允许将任何字符串作为令牌传入。

默认排除很多,包括带有连字符的字符串...

我最接近的是:

vectorizer = CountVectorizer(token_patten=r"(?u)\b\w\w+\b|!|\?|\"|\'") 

来自this post

但我缺乏正则表达式的技能,所以我无法成功自定义它。

【问题讨论】:

    标签: python regex scikit-learn countvectorizer


    【解决方案1】:

    我想通了。

    这允许任何字符串。

    vectorizer = CountVectorizer(token_pattern=r'.*')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-30
      • 1970-01-01
      • 1970-01-01
      • 2012-06-07
      • 1970-01-01
      • 2018-01-04
      • 2023-03-06
      • 1970-01-01
      相关资源
      最近更新 更多