allennlp.models.srl_util¶
Converts BIO formatted SRL tags to the format required for evaluation with the official CONLL 2005 perl script. Spans are represented by bracketed labels, with the labels of words inside spans being the same as those outside spans. Beginning spans always have a opening bracket and a closing asterisk (e.g. “(ARG-1*” ) and closing spans always have a closing bracket (e.g. “)” ). This applies even for length 1 spans, (e.g “(ARG-0)”).
A full example of the conversion performed:
[B-ARG-1, I-ARG-1, I-ARG-1, I-ARG-1, I-ARG-1, O] [ “(ARG-1*”, “*”, “*”, “*”, “)”, “”]
- Parameters
- labelsList[str], required.
A list of BIO tags to convert to the CONLL span based format.
- Returns
- A list of labels in the CONLL span based format.
Prints predicate argument predictions and gold labels for a single verbal predicate in a sentence to two provided file references.
The CoNLL SRL format is described in the shared task data README .
This function expects IOB2-formatted tags, where the B- tag is used in the beginning of every chunk (i.e. all chunks start with the B- tag).
- Parameters
- prediction_fileTextIO, required.
A file reference to print predictions to.
- gold_fileTextIO, required.
A file reference to print gold labels to.
- verb_indexOptional[int], required.
The index of the verbal predicate in the sentence which the gold labels are the arguments for, or None if the sentence contains no verbal predicate.
- sentenceList[str], required.
The word tokens.
- predictionList[str], required.
The predicted BIO labels.
- gold_labelsList[str], required.
The gold BIO labels.
Prints predicate argument predictions and gold labels for a single verbal predicate in a sentence to two provided file references.
The CoNLL SRL format is described in the shared task data README .
This function expects IOB2-formatted tags, where the B- tag is used in the beginning of every chunk (i.e. all chunks start with the B- tag).
- Parameters
- prediction_fileTextIO, required.
A file reference to print predictions to.
- gold_fileTextIO, required.
A file reference to print gold labels to.
- verb_indexOptional[int], required.
The index of the verbal predicate in the sentence which the gold labels are the arguments for, or None if the sentence contains no verbal predicate.
- sentenceList[str], required.
The word tokens.
- conll_formatted_predictionsList[str], required.
The predicted CoNLL-formatted labels.
- conll_formatted_gold_labelsList[str], required.
The gold CoNLL-formatted labels.