中文语料:
拆成单字的列表
荣 耀 内 幕 我 不 多
华 为 用 户 如 果 发 现 续 航 不 足 一 天 的 请 凭 余 总 微 博 进 行 合 理 维 权
便 宜 了 5 0 0 多 g
使用
CountVectorizer()
报错:
Sklearn ValueError: empty vocabulary; perhaps the documents only contain stop words
问题:
def __init__(self, input='content', encoding='utf-8', decode_error='strict', strip_accents=None, lowercase=True, preprocessor=None, tokenizer=None, stop_words=None, token_pattern=r"(?u)\b\w\w+\b", ngram_range=(1, 1), analyzer='word', max_df=1.0, min_df=1, max_features=None, vocabulary=None, binary=False, dtype=np.int64):
解决方案
CountVectorizer()默认analysis =“word”,改成CountVectorizer(analysis =“char”,lowercase=False)就好了