Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add counter attack parsing in StatsBomb deserializer #284

Open
DriesDeprest opened this issue Jan 19, 2024 · 1 comment
Open

Add counter attack parsing in StatsBomb deserializer #284

DriesDeprest opened this issue Jan 19, 2024 · 1 comment

Comments

@DriesDeprest
Copy link
Contributor

I would like to recognize the "From Counter" play pattern in our StatsBomb deserializer and thus add CounterAttackQualifier s to events with this play pattern.

I'm not sure what would be an elegant way to implement this.

I could create a function _get_counter_attack_qualifiers(event_dict: Dict) -> List[CounterAttackQualifier] which recognizes the "From Counter" play pattern. And then add this function in all the _create_events() methods of the different event type classes. But it feels a bit repetitive to add it to almost all of these event classes - @probberechts thoughts?

@probberechts
Copy link
Contributor

Ah yes, that would indeed be repetitive.

You could add the qualifier after parsing the events:

    def deserialize(self, event_factory: EventFactory) -> List[Event]:
        """Deserialize the event.
        """
        generic_event_kwargs = self._parse_generic_kwargs()
        events = (
            self._create_aerial_won_event(
                event_factory, **generic_event_kwargs
            )
            + self._create_events(event_factory, **generic_event_kwargs)
            + self._create_ball_out_event(
                event_factory, **generic_event_kwargs
            )
        )
        for event in events:
            # add possession qualfiers
        return events

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants