python - 从 AllenNLP Open IE 模型中提取后处理的三元组

标签 python triples allennlp

我想从 Allen NLP Open IE 预测器模型中以(主语、关系、宾语)元组形式提取干净的三元组。

目前我看到步骤如下

OIE_output = predictor_OIE.predict(sentence=sent)
for verb in OIE_output['verbs']:
    srl_output = predictor_OIE.make_srl_string(words,verb['tags'])

srl_output 在打印时会在句子中给出标签,例如:

[ARG0: Raytheon Technologies Corporation researches] , develops , and [V: manufactures] [ARG1: advanced technology products] [ARGM-LOC: in the aerospace and defense industry] , [C-ARG1: including aircraft engines , avionics , aerostructures , cybersecurity] [ARGM-ADV: , missiles , air defense systems , and drones] .

问题是,我找不到任何代码将这样的例句转换为(主语,关系,宾语)形式的多个元组。特别是ARGM-LOC、ARGM-ADV等特殊类型的标签,让事情变得更加困难。

我已经查看过时的 Github 存储库 https://github.com/gabrielStanovsky/supervised_oie_wrapper (它并不能完全生成这些类型的元组),我在 AllenNLP 中找到的最接近的函数是 make_srl_string 方法,但输出仍然需要进行后处理才能创建元组。

是否有任何代码可以从 AllenNLP Open IE 模型创建元组?如果没有,您可以将其添加为一项功能吗?

详细解释见github问题https://github.com/allenai/allennlp/issues/4857

最佳答案

AllenNLP 目前不具备此功能,但我认为将其添加到 SRLPredictor 类中并不困难。如果您这样做,请向我们发送拉取请求!

关于python - 从 AllenNLP Open IE 模型中提取后处理的三元组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65147947/

相关文章:

rdf - RDF中具体化的解释

rdf - 使 OWL 数据和对象属性成为同一属性的子属性

sparql - RDF 三元组到表

python - 文本二元分类训练期间的波动损失

pytorch - 在 AllenNLP 包中保存/加载模型

python - 值错误 : You must specify a period or x must be a pandas object with a DatetimeIndex with a freq not set to None

jquery - 如何使 javascript 响应稍后以 AJAX 方式添加的按钮

python - 如何设置多个单元测试共享的资源?

python - 使用Flask和Flask-WTF中的路径和可选参数重定向到新页面不起作用

python - AllenNLP 共指解析的多 GPU 训练