Skip to content

srl

allennlp_models.structured_prediction.predictors.srl

[SOURCE]


SemanticRoleLabelerPredictor#

@Predictor.register("semantic_role_labeling")
class SemanticRoleLabelerPredictor(Predictor):
 | def __init__(
 |     self,
 |     model: Model,
 |     dataset_reader: DatasetReader,
 |     language: str = "en_core_web_sm"
 | ) -> None

Predictor for the SemanticRoleLabeler model.

predict#

class SemanticRoleLabelerPredictor(Predictor):
 | ...
 | def predict(self, sentence: str) -> JsonDict

Predicts the semantic roles of the supplied sentence and returns a dictionary with the results.

{"words": [...],
 "verbs": [
    {"verb": "...", "description": "...", "tags": [...]},
    ...
    {"verb": "...", "description": "...", "tags": [...]},
]}

Parameters

sentence, str The sentence to parse via semantic role labeling.

Returns

  • A dictionary representation of the semantic roles in the sentence.

predict_tokenized#

class SemanticRoleLabelerPredictor(Predictor):
 | ...
 | def predict_tokenized(self, tokenized_sentence: List[str]) -> JsonDict

Predicts the semantic roles of the supplied sentence tokens and returns a dictionary with the results.

Parameters

tokenized_sentence, List[str] The sentence tokens to parse via semantic role labeling.

Returns

  • A dictionary representation of the semantic roles in the sentence.

make_srl_string#

class SemanticRoleLabelerPredictor(Predictor):
 | ...
 | @staticmethod
 | def make_srl_string(words: List[str], tags: List[str]) -> str

tokens_to_instances#

class SemanticRoleLabelerPredictor(Predictor):
 | ...
 | def tokens_to_instances(self, tokens)

predict_batch_json#

class SemanticRoleLabelerPredictor(Predictor):
 | ...
 | def predict_batch_json(self, inputs: List[JsonDict]) -> List[JsonDict]

Expects JSON that looks like [{"sentence": "..."}, {"sentence": "..."}, ...] and returns JSON that looks like

[
    {"words": [...],
     "verbs": [
        {"verb": "...", "description": "...", "tags": [...]},
        ...
        {"verb": "...", "description": "...", "tags": [...]},
    ]},
    {"words": [...],
     "verbs": [
        {"verb": "...", "description": "...", "tags": [...]},
        ...
        {"verb": "...", "description": "...", "tags": [...]},
    ]}
]

predict_instances#

class SemanticRoleLabelerPredictor(Predictor):
 | ...
 | def predict_instances(self, instances: List[Instance]) -> JsonDict

predict_json#

class SemanticRoleLabelerPredictor(Predictor):
 | ...
 | def predict_json(self, inputs: JsonDict) -> JsonDict

Expects JSON that looks like {"sentence": "..."} and returns JSON that looks like

{"words": [...],
 "verbs": [
    {"verb": "...", "description": "...", "tags": [...]},
    ...
    {"verb": "...", "description": "...", "tags": [...]},
]}