【发布时间】:2018-01-23 06:33:44
【问题描述】:
我需要从用户使用 python 给出的句子中提取主语、动词和宾语。请给我建议。
【问题讨论】:
我需要从用户使用 python 给出的句子中提取主语、动词和宾语。请给我建议。
【问题讨论】:
只需使用支持语法依赖的解析器来解析您的句子。例如,用 Stanford Parser 解析句子“The children play football”将返回以下一组语法依赖:
det(children-2, the-1)
nsubj(play-3, children-2)
root(ROOT-0, play-3)
dobj(play-3, football-4)
您要查找的依赖项是 nsubj 和 dobj。当然,如果您的句子包含多个及物动词,您将获得更多对 nsubj、dobj 依赖项。有一个 Python interface 可以从您的脚本中以编程方式调用斯坦福解析器。
【讨论】: