JulianFrattini/cira

Revise selection of first cause event

Closed this issue · 0 comments

In the get_junctors method of the eventconnector.py, the algorithm tries to determine the first cause event node by looking for the node associated with the event label, which has no predecessor and, hence, is the first.

# get the starting node (the cause event node which has no predecessor)
current_node: EventNode = [event for event in events if (event.labels[0].predecessor == None)][0]

This usually works, but if the first event label of a sentence is an effect and not a cause, then the algorithm will fail - as the first cause event node will have a predecessor (the effect event node). The list comprehension statement will yield an empty list, and trying to access the first element of it ([0]) will break the system. The following sentence illustrates the example:

grafik

This is not an uncommon case. Therefore, determining the first cause event node in a sentence should not rely on the absence of a predecessor, but should rather utilize the order of the labels through the begin attribute, which denotes the starting index of a label: the first cause event node will always be associated with the cause event label which has the lowest begin index, regardless of whether it has an effect predecessor or not.