By Rodrigo Alarcón, Computational Linguist
The complete list of modules we offer can be found in our documentation:
As usual, the first step is to declare an instance of the NLP API client and use it to send a text along with a pipeline variable indicating the name of the Semantic Roles annotator. The output is a Document object that contains a list of analyzed Sentences. A quick look of the output can be found with the method document.pretty_print().
The goal of this module is to identify the main events and participants in sentences and classify the different types of relations between them. In the extraction of Semantic Roles, events are called predicates, while the participants are known as the arguments of a given predicate. Arguments can denote specific types of relations, for example they can be an Agent, a Patient or a Location in relation to the predicate.
More details about the Semantic Role Labeler and an example of its application can be found here:
- KEY: semantic_roles
- ATTR: sentence.semantic_roles
From the output above we can observe the following:
- All semantic roles contain a predicate and, if present, a list of arguments for that predicate.
- Predicates include the token, lemma (inflected form) and position in the sentence.
- Each argument will contain the type (see Output labels above), the tokens of that argument and the position of the tokens in the sentence.
- All token positions in the sentence start from 1 (instead of 0, as lists in Python).
In this tutorial we described how to use the Semantic Role Labeler of the Codeq NLP API. The code below summarizes how to iterate over its output:
Take a look at our documentation to learn more about the NLP tools we provide.
Do you need inspiration? Go to our use case demos and see how you can integrate different tools.
In our NLP demos section you can also try our tools and find examples of the output of each module.