斯坦福解析器的输出如下:
nicaragua president ends visit to finland .
nn(ends-3, nicaragua-1)
nn(ends-3, president-2)
nsubj(visit-4, ends-3)
xsubj(finland-6, ends-3)
root(ROOT-0, visit-4)
aux(finland-6, to-5)
xcomp(visit-4, finland-6)
guatemala president ends visit to tropos .
nn(ends-3, guatemala-1)
nn(ends-3, president-2)
nsubj(visit-4, ends-3)
xsubj(finland-6, ends-3)
root(ROOT-0, visit-4)
aux(tropos-6, to-5)
xcomp(visit-4, tropos-6)
[...]
我必须对这个输出进行分段,以便得到包含句子的元组和每个句子的所有依赖项列表(如(sentence,[list of dependencies])
)。有人能给我推荐一种用Python做这个的方法吗?谢谢!你知道吗
您可以这样做,尽管对于您正在解析的结构来说,这样做可能有些过头了。如果您还需要解析依赖项,那么扩展它应该相对容易。我还没有运行这个,甚至没有检查语法,所以不要杀了我,如果它不能马上工作。你知道吗
相关问题 更多 >
编程相关推荐