首页 > 解决方案 > AllenNLP 语义角色标注器 - 参数注释

问题描述

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

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

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", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O"]}], "words": ["At", "noon", ",", "a", "man", "exited", "the", "park", "on", "the", "N", "side", "."]}

标签: pythonallennlp

解决方案


在 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


推荐阅读