我想从 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/