【发布时间】:2019-03-13 12:49:59
【问题描述】:
我正在尝试将自定义 STOP_WORDS 添加到 spacy。 以下代码应将自定义 STOP_WORD“Bestellung”添加到标准 STOP_WORDS 集中。 我遇到的问题是,添加有效,即该集合在添加后包含“Bestellung”,但在使用 .is_stop 测试自定义停用词“Bestellung”时,python 返回 FALSE。
另一个具有默认 STOP_WORD 的测试(即它是 STOP_WORDS 中的标准)“darunter”返回 TRUE。我不明白,因为“Bestellung”和“darunter”这两个词都在同一组 STOP_WORDS 中。
有人知道它为什么会这样吗?
谢谢
import spacy
from spacy.lang.de.stop_words import STOP_WORDS
STOP_WORDS.add("Bestellung")
print(STOP_WORDS) #Printing STOP_WORDS proofs, that "Bestellung" is part of the Set "STOP_WORDS". Both tested words "darunter" and "Bestellung" are part of it.
nlp=spacy.load("de_core_news_sm")
print(nlp.vocab["Bestellung"].is_stop) # return: FALSE
print(nlp.vocab["darunter"].is_stop) # return: TRUE
谢谢
【问题讨论】:
标签: nlp spacy stop-words