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

时间:2018-02-23 18:53:53

标签: python nlp nltk textblob

我遵循了这个教程: 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

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

1 个答案:

答案 0 :(得分:0)

我一直在审查同样的事情。我很确定这是一个错字。它必须是 True ,因为字典指示最后一个单词是____。 False表示最后一个单词不是____,并且示例不是这样设置的。