allenai

allenai / semantic_role_labeling / 0.1.0

README.md

Overview

This algorithm provides state-of-the-art natural language reasoning, decomposing a sentence into a structured representation of the relationships it describes.

The central concept in this algorithm is a verb, and the entities involved in that verb are its arguments (like logical predicates). The arguments describe who/what does the action of this verb, to whom/what it is done, etc.

This algorithm is a wrapper around the Semantic Role Labeling put out by the AllenNLP team, which is itself a re-implementation of a deep BiLSTM model (He et al, 2017).

Applicable Scenarios and Problems

Usage

Input

The input JSON blob should have the following fields:

  • sentence: the text to be decomposed

Any additional fields will be passed through into the AllenNLP model.

Output

The following output field will always be present:

  • verbs: A list of verbs in the sentence. For each verb there is:
  • verb The word itself
  • description the original sentence, with the verb and its arguments replaced by semantic labels in brackets
  • tags A list of the argument type for all tokens in the sentence, with respect to this verb
  • words: Probability the hypothesis contradicts the premise

Examples

Example 1: Default Behavior

Input:

{
  "sentence": "The cat ate the dog with ketchup"
}

Output:

{
  'verbs': [
    {
      'verb': 'ate',
      'description': '[ARG0: The cat] [V: ate] [ARG1: the dog]',
      'tags': [
        'B-ARG0',
        'I-ARG0',
        'B-V',
        'B-ARG1',
        'I-ARG1'
      ]
    }
  ],
  'words': [
    'The',
    'cat',
    'ate',
    'the',
    'dog'
  ]
}

See Also