Skip to content

Commit

Permalink
fix(statsbomb): set throw-in body part to "other"
Browse files Browse the repository at this point in the history
  • Loading branch information
probberechts committed Dec 29, 2023
1 parent b03fa66 commit 81a2bcc
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions socceraction/spadl/statsbomb.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ def _parse_event_as_non_action(_extra: dict[str, Any]) -> tuple[str, str, str]:

def _parse_pass_event(extra: dict[str, Any]) -> tuple[str, str, str]: # noqa: C901
a = 'pass' # default
b = 'foot' # default
p = extra.get('pass', {})
ptype = p.get('type', {}).get('name')
height = p.get('height', {}).get('name')
Expand All @@ -262,6 +263,7 @@ def _parse_pass_event(extra: dict[str, Any]) -> tuple[str, str, str]: # noqa: C
a = 'goalkick'
elif ptype == 'Throw-in':
a = 'throw_in'
b = 'other'
elif cross:
a = 'cross'
else:
Expand All @@ -280,18 +282,17 @@ def _parse_pass_event(extra: dict[str, Any]) -> tuple[str, str, str]: # noqa: C
r = 'success'

bp = extra.get('pass', {}).get('body_part', {}).get('name')
if bp is None:
b = 'foot'
elif 'Head' in bp:
b = 'head'
elif bp == 'Left Foot':
b = 'foot_left'
elif bp == 'Right Foot':
b = 'foot_right'
elif 'Foot' in bp or bp == 'Drop Kick':
b = 'foot'
else:
b = 'other'
if bp is not None:
if 'Head' in bp:
b = 'head'
elif bp == 'Left Foot':
b = 'foot_left'
elif bp == 'Right Foot':
b = 'foot_right'
elif 'Foot' in bp or bp == 'Drop Kick':
b = 'foot'
else:
b = 'other'

return a, r, b

Expand Down Expand Up @@ -453,7 +454,7 @@ def _parse_clearance_event(extra: dict[str, Any]) -> tuple[str, str, str]:
r = 'success'
bp = extra.get('clearance', {}).get('body_part', {}).get('name')
if bp is None:
b = 'other'
b = 'foot'
elif 'Head' in bp:
b = 'head'
elif bp == 'Left Foot':
Expand Down

0 comments on commit 81a2bcc

Please sign in to comment.