【问题标题】:nltk.corpus - 'getset_descriptor' object has no attribute 'setdefault'nltk.corpus - 'getset_descriptor' 对象没有属性 'setdefault'
【发布时间】:2021-04-21 09:25:02
【问题描述】:

我正在使用下面的代码并从 nltk 导入停用词

   #from nltk.corpus import words as word_corp
    from nltk.corpus import stopwords
    nlp = spacy.load('en_core_web_sm')
    phrase_matcher = PhraseMatcher(nlp.vocab)
    en_words = nltk.corpus.words.words('en')
    stop_words = stopwords.words('english')

但错误是AttributeError: 'getset_descriptor' object has no attribute 'setdefault' for ----> 3 nlp = spacy.load('en_core_web_sm')这一行。

【问题讨论】:

    标签: python-3.x nlp nltk corpus


    【解决方案1】:

    我也遇到了这个问题 - 你使用的是什么版本的 Python/spaCy?

    Python 3.9.1 + spaCy 2.2.4 发生在我身上。

    在将 spaCy 升级到 3.0.0 将 Python 降级到 3.6.8 后它对我有用(没有尝试其他版本)

    【讨论】:

    • 是的,我也是这样做的。
    • 感谢您提及这一点!我在 spaCy 2.2.4 和 Python 3.7 中遇到了这个错误。
    • Spacy 2.3.1 适用于 Python 3.8。
    猜你喜欢
    • 2022-11-20
    • 2013-05-14
    • 1970-01-01
    • 2021-04-13
    • 1970-01-01
    • 1970-01-01
    • 2012-12-01
    • 2021-08-03
    • 1970-01-01
    相关资源
    最近更新 更多