作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 spaCy doc
,我想对其进行词形还原。
例如:
import spacy
nlp = spacy.load('en_core_web_lg')
my_str = 'Python is the greatest language in the world'
doc = nlp(my_str)
如何将 doc
中的每个标记转换为其引理?
最佳答案
每个 token 都有许多属性,您可以迭代文档来访问它们。
例如:[token.lemma_ for token in doc]
如果你想重构句子,你可以使用:' '.join([token.lemma_ for token in doc])
有关 token 属性的完整列表,请参阅:https://spacy.io/api/token#attributes
关于python - 用 spacy 对文档进行词形还原?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51658153/
我是一名优秀的程序员,十分优秀!