从斯坦福·科伦普(Stanford Corenlp)提取多个关系三元



我正在尝试从斯坦福·科伦普(Stanford Corenlp(提取关系三元,并且在句子中的单个关系三元组中非常有效,但似乎对同一句子中的多个想法不起作用。

例如:我喝水,他吃了蛋糕。

我希望有两个三元组。(我,喝水,水(,(他,吃饭,蛋糕(,但只有一个会出现。

这是我目前与之合作的:

with corenlp.CoreNLPClient(annotators="tokenize ssplit lemma pos ner depparse natlog openie".split()) as client:
      ann = client.annotate(text)
sentence = ann.sentence[0].openieTriple
for x in ann.sentence:
    print(x.openieTriple)

我假设我在这里做错了什么。更改max_entailments不能解决问题。

您必须做:

for x in ann.sentence:
   for triple in x.openieTriple
     print(triple)`

今天发现了这一点,这要归功于您的问题,谢谢!

最新更新