对于 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", "."]}