PySport/kloppy

[Wyscout v2] Bug in deserializing Offensive Duel events which are also an interception

Opened this issue · 0 comments

When a duel is also an interception, the Wyscout v2 deserializer deletes the last event before the interception.

if event.event_type.name == "DUEL":
# when DuelEvent is interception, we need to overwrite this and the previous DuelEvent
events = events[:-1]
event = interception_event

I guess the reasoning is that a defensive duel is always paired with an offensive duel and this would delete the offensive duel. However, it seems that the "interception" tag (1401) can also be given to the offensive duel. In that case, the wrong event will be deleted. For example, in the sequence of events below, the current implementation would delete the pass event.

{
            "eventId": 8,
            "subEventName": "Simple pass",
            "tags": [
                {
                    "id": 1802
                }
            ],
            "playerId": 36,
            "positions": [
                {
                    "y": 74,
                    "x": 30
                },
                {
                    "y": 64,
                    "x": 30
                }
            ],
            "matchId": 2058007,
            "eventName": "Pass",
            "teamId": 5629,
            "matchPeriod": "2H",
            "eventSec": 1787.213756,
            "subEventId": 85,
            "id": 261447235
        },
        {
            "eventId": 1,
            "subEventName": "Ground attacking duel",
            "tags": [
                {
                    "id": 1401
                },
                {
                    "id": 501
                },
                {
                    "id": 703
                },
                {
                    "id": 1801
                }
            ],
            "playerId": 14816,
            "positions": [
                {
                    "y": 36,
                    "x": 70
                },
                {
                    "y": 42,
                    "x": 74
                }
            ],
            "matchId": 2058007,
            "eventName": "Duel",
            "teamId": 12913,
            "matchPeriod": "2H",
            "eventSec": 1789.1453259999998,
            "subEventId": 11,
            "id": 261446954
        },
        {
            "eventId": 1,
            "subEventName": "Ground defending duel",
            "tags": [
                {
                    "id": 502
                },
                {
                    "id": 701
                },
                {
                    "id": 1802
                }
            ],
            "playerId": 70123,
            "positions": [
                {
                    "y": 64,
                    "x": 30
                },
                {
                    "y": 58,
                    "x": 26
                }
            ],
            "matchId": 2058007,
            "eventName": "Duel",
            "teamId": 5629,
            "matchPeriod": "2H",
            "eventSec": 1789.5934159999997,
            "subEventId": 12,
            "id": 261447236
        }

You can see the corresponding video here: https://youtu.be/GrkiZjoyugA?t=4813. It's the ball touch by Alderweireld.

So, I think we should update the logic here to make sure the correct event gets deleted. Furthermore, I wonder whether it wouldn't be better to convert an Offensive Duel + interception to a Ball receipt (under pressure).