sinatools.relations.relation_extractor

sinatools.relations.relation_extractor.event_argument_relation_extraction(text)

This method processes a given text to identify and extract events and their corresponding arguments (agents, locations, and dates) within a sentence. In other words, this methods extracts the relationships (hasAgent, hasLocation, and hasDate) between each event and other named entities. Named entities are identified first then relations are extracted. Try demo online. (See article).

Parameters
  • text (str) – The Arabic text to be tagged.

Returns

A list of JSON objects, where each object could be contains:

TripleID (str) - A unique identifier for the extracted event-argument relation triple.
Subject (str) - The event that serves as the subject in the relation.

  • ID (int) - A unique identifierfor the subject entity.
  • Type (str) - Subject entity type (i.e. EVENT).
  • Label (str) - The surface text of the subject in the text.
Relation (str) - The type of relationship between the Subject and the Object.
Object (str) - The Named Entity that serves as the object in the relation.

  • ID (int) - A unique identifierfor the object entity.
  • Type (str) - Subject entity type.
  • Label (str) - The surface text of the object entity in the text.

Return type

list

Note

The relation BERT model should be installed using (download_files -f relation) command.

Example:

from sinatools.relations.relation_extractor import event_argument_relation_extraction
event_argument_relation_extraction('اندلعت انتفاضة الأقصى في 28 سبتمبر 2000')
#the output
[{
    "TripleID":"1",
    "Subject":{"ID": 1, "Type": "EVENT", "Label": "انتفاضة الأقصى"}
    "Relation":"location",
    "Object":{"ID": 2, "Type": "FAC", "Label": "الأقصى"}
},{
    "TripleID":"2",
    "Subject":{"ID": 1, "Type": "EVENT", "Label": "انتفاضة الأقصى"}
    "Relation":"happened at",
    "Object":{"ID": 3, "Type": "DATE", "Label": "28 سبتمبر 2000"}    
}]