如何在TextBlob中指定我自己的特征提取器?

问题描述 投票:2回答:1

我遵循了本教程:http://textblob.readthedocs.io/en/dev/classifiers.html#feature-extractors我写了一个提取器:

def phrases_extractor(document):
    r.extract_keywords_from_text(document)
    words = r.get_ranked_phrases()
    feats = {}
    for w in words:
        feats["contains({0})".format(w)] = True
    return feats

但是我不知道为什么文档说应该包含“ contains ... = False”我怎样才能做到这一点?我是否应该首先收集所有可能的单词并将它们添加到具有False值的字典中?

python nlp nltk textblob
1个回答
0
投票

我一直在审查同一件事。我很确定这是一个错字。因为字典指示最后一个单词是____,所以它必须为True

© www.soinside.com 2019 - 2024. All rights reserved.