AllenNLP 语义角色标注器 - 参数注释

问题描述

对于 AllenNLP 语义角色标签实现,如何像演示中显示的那样应用 Argument 注释?当我从本地实现运行代码时,我看到了动词和描述,但没有看到注释?我一定遗漏了需要应用来支持该部分输出的额外步骤或逻辑。

演示应用程序中显示的内容

Sentence: At noon,a man exited the park on the N side. 

exited: [ARGM-TMP: At noon],[ARG0: a man] [V: exited] [ARG1: the park] [ARGM-DIR: on the N side] .

我的代码:

from allennlp.predictors.predictor import Predictor

download = "https://storage.googleapis.com/allennlp-public-models/bert-base-srl-2020.09.03.tar.gz"
# predictor = Predictor.from_path("https://storage.googleapis.com/allennlp-public-models/bert-base-srl-2020.11.19.tar.gz")
predictor = Predictor.from_path(download)

text = "At noon,a man exited the park on the N side. "

tree = predictor.predict(sentence=text)
value = predictor.dump_line(tree)
value

我的同一句话代码的输出:

'{"verbs": [{"verb": "exited","description": "At noon,a man exited the park on the N side .","tags": ["O","O","O"]}],"words": ["At","noon",","a","man","exited","the","park","on","N","side","."]}

解决方法

在github上发帖后,从AllenNLP的人那里发现这是一个版本问题。我需要使用 allennlp=1.3.0 和最新型号。现在它按预期工作了。

This should be fixed in the latest allennlp 1.3 release. Also,the latest archive file is structured-prediction-srl-bert.2020.12.15.tar.gz.

https://github.com/allenai/allennlp/issues/4876

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...