AttributeError: 'list' 对象没有属性 'similarity'

亚历克斯
ws = {}
nlp = spacy.load('de_core_news_sm')
data = 'Some long text'
train_corpus = nlp(data)
train_corpus = [token.text for token in train_corpus if not token.is_stop and len(token) > 4]
test_corpus = nlp('Some short sentence')   
ae = train_corpus.similarity(test_corpus)

我到AttributeError: 'list' object has no attribute 'similarity'ae = train_corpus.similarity(test_corpus)如果我删除train_corpus = [token.text for token in train_corpus if not token.is_stop and len(token) > 4],它可以工作,但带有停用词。

如何删除停用词以使其仍然有效?

编辑:ae = nlp(train_corpus).similarity(test_corpus)导致TypeError: Argument 'string' has incorrect type (expected str, got list).

彼得·马图斯卡

请注意,您对英语短语使用德语模型。在您的情况下,您需要粘回剩余的令牌并再次创建一个“spacy 对象”。在您的情况下,您无论如何都会通过此条件 len(token) > 4 删除所有令牌..

import spacy

nlp = spacy.load('en_core_web_sm')
# nlp = spacy.load('de_core_news_sm')
ws = {}
#data = 'Some long text'
data = 'Some long text Elephant'
train_corpus = nlp(data)
train_corpus = nlp(" ".join([token.text for token in train_corpus if not token.is_stop and len(token) > 4]))
test_corpus = nlp('Some short sentence')
ae = train_corpus.similarity(test_corpus)

print(ae)

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

“ AttributeError:'list'对象没有属性'ravel'”

来自分类Dev

“ AttributeError:'list'对象没有属性'ravel'”

来自分类Dev

AttributeError: 'list' 对象没有属性 'x'

来自分类Dev

AttributeError: 'list' 对象没有属性 'tk'

来自分类Dev

AttributeError: 'list' 对象没有属性 'id'

来自分类Dev

AttributeError: 'list' 对象没有属性 'host'

来自分类Dev

/ home /'list'对象上的AttributeError没有属性'resolve'

来自分类Dev

初学者Python:AttributeError:'list'对象没有属性

来自分类Dev

AttributeError:“ list”对象在Python上没有属性“ encode”

来自分类Dev

AttributeError:“客户”对象没有属性“ get_mailing_list”

来自分类Dev

/ home /'list'对象上的AttributeError没有属性'resolve'

来自分类Dev

python3 AttributeError: 'list' 对象没有属性 'dot'

来自分类Dev

面对 AttributeError: 'list' 对象没有属性 'lower'

来自分类Dev

python gensim:AttributeError:'list'对象没有属性

来自分类Dev

AttributeError: 'list' 对象没有属性 'reset_index'

来自分类Dev

AttributeError:对象没有属性

来自分类Dev

AttributeError: '' 对象没有属性 ''

来自分类Dev

Scipy:尝试写入wav文件,AttributeError:“ list”对象没有属性“ dtype”

来自分类Dev

尝试计算softmax值,得到AttributeError:'list'对象没有属性'T'

来自分类Dev

appendleft迭代双端队列函数,AttributeError:'list'对象没有属性'appendleft'

来自分类Dev

为什么Gensim doc2vec给出AttributeError:'list'对象没有属性'words'?

来自分类Dev

AttributeError:尝试从字典列表创建DataFrame时,“ list”对象没有属性“ keys”

来自分类Dev

AttributeError:在pytorch中进行预测时,“ list”对象没有属性“ dim”

来自分类Dev

discord.py在使用add_roles时等待“ AttributeError:'list'对象没有属性'id'”

来自分类Dev

discord.py在使用add_roles时等待“ AttributeError:'list'对象没有属性'id'”

来自分类Dev

body = body.encode('ascii','ignore')AttributeError:'list'对象没有属性'encode'

来自分类Dev

appendleft迭代双端队列函数,AttributeError:'list'对象没有属性'appendleft'

来自分类Dev

Scipy:尝试写入wav文件,AttributeError:'list'对象没有属性'dtype'

来自分类Dev

Python Selenium Webdriver:AttributeError'list'对象没有属性'tag_name'

Related 相关文章

  1. 1

    “ AttributeError:'list'对象没有属性'ravel'”

  2. 2

    “ AttributeError:'list'对象没有属性'ravel'”

  3. 3

    AttributeError: 'list' 对象没有属性 'x'

  4. 4

    AttributeError: 'list' 对象没有属性 'tk'

  5. 5

    AttributeError: 'list' 对象没有属性 'id'

  6. 6

    AttributeError: 'list' 对象没有属性 'host'

  7. 7

    / home /'list'对象上的AttributeError没有属性'resolve'

  8. 8

    初学者Python:AttributeError:'list'对象没有属性

  9. 9

    AttributeError:“ list”对象在Python上没有属性“ encode”

  10. 10

    AttributeError:“客户”对象没有属性“ get_mailing_list”

  11. 11

    / home /'list'对象上的AttributeError没有属性'resolve'

  12. 12

    python3 AttributeError: 'list' 对象没有属性 'dot'

  13. 13

    面对 AttributeError: 'list' 对象没有属性 'lower'

  14. 14

    python gensim:AttributeError:'list'对象没有属性

  15. 15

    AttributeError: 'list' 对象没有属性 'reset_index'

  16. 16

    AttributeError:对象没有属性

  17. 17

    AttributeError: '' 对象没有属性 ''

  18. 18

    Scipy:尝试写入wav文件,AttributeError:“ list”对象没有属性“ dtype”

  19. 19

    尝试计算softmax值,得到AttributeError:'list'对象没有属性'T'

  20. 20

    appendleft迭代双端队列函数,AttributeError:'list'对象没有属性'appendleft'

  21. 21

    为什么Gensim doc2vec给出AttributeError:'list'对象没有属性'words'?

  22. 22

    AttributeError:尝试从字典列表创建DataFrame时,“ list”对象没有属性“ keys”

  23. 23

    AttributeError:在pytorch中进行预测时,“ list”对象没有属性“ dim”

  24. 24

    discord.py在使用add_roles时等待“ AttributeError:'list'对象没有属性'id'”

  25. 25

    discord.py在使用add_roles时等待“ AttributeError:'list'对象没有属性'id'”

  26. 26

    body = body.encode('ascii','ignore')AttributeError:'list'对象没有属性'encode'

  27. 27

    appendleft迭代双端队列函数,AttributeError:'list'对象没有属性'appendleft'

  28. 28

    Scipy:尝试写入wav文件,AttributeError:'list'对象没有属性'dtype'

  29. 29

    Python Selenium Webdriver:AttributeError'list'对象没有属性'tag_name'

热门标签

归档