对于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", "."]}发布于 2020-12-27 01:17:08
在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://stackoverflow.com/questions/65393947
复制相似问题