我对使用 spaCy 很陌生。我已经阅读了几个小时的文档,但我仍然很困惑是否可以做我的问题。反正...
正如标题所说,有没有一种方法可以使用包含它的标记来实际获取给定的名词块。例如,给定句子:
"Autonomous cars shift insurance liability toward manufacturers"
"autonomous cars"
当我只有"cars"
令牌时,是否有可能获得名词块?这是我正在尝试的场景的示例片段。
startingSentence = "Autonomous cars and magic wands shift insurance liability toward manufacturers"
doc = nlp(startingSentence)
noun_chunks = doc.noun_chunks
for token in doc:
if token.dep_ == "dobj":
print(child) # this will print "liability"
# Is it possible to do anything from here to actually get the "insurance liability" token?
任何帮助将不胜感激。谢谢!