我想从一个句子中提取“所有”的名词短语。我想知道如何做到这一点。我有以下代码:
doc2 = nlp("what is the capital of Bangladesh?")
for chunk in doc2.noun_chunks:
print(chunk)
输出:
1. what
2. the capital
3. bangladesh
预期结果:
孟加拉国的首都
我已经尝试过spacy文档和StackOverflow的答案,但都没有成功。似乎只有cTakes和Stanford core NLP
可以提供这种复杂的名词短语。
非常感谢您的帮助。