NAME
Sport::Analytics::NHL::Generator - generate derived data from the NHL reports, after normalization and population.
SYNOPSIS
Generates derived data from the NHL reports, after normalization and population.
use Sport::Analytics::NHL::Generator
# Let $opts have the parsed CLI options
# from Usage.pm
# Let $game be a game retrieved from the database
my $generated = generate_game($opts, $game);
# generates data, returns all things generated, updates the DB
# unless dry_run mode is specified.
#
# or
#
generate($opts, 201820001);
# just specify the options and the game ID.
Only the functions generate() and generate_game() are exported.
All the internal generate_* functions accept the second optional argument $dry_run which, when specified, prevents the database from being updated. Another way of controlling this behavior is by specifying HOCKEYDB_DRYRUN environment variable. This second argument is not mentioned below as well as the first one which is always the game structure.
FUNCTIONS
guess_pulled_goalie_through_en
-
Tries to guess if the goalie was pulled during the game through against/with EN goals.
Arguments: the game the structure holding the pulled goalies Returns: whether at least one team pulled the goalie
guess_pulled_goalie_on_ice
-
Tries to guess if the goalie was pulled during the game through on ice list of players in an event.
Arguments: the double array of players on ice the current score the structure holding the pulled goalies Returns: whether at least one team pulled the goalie
guess_pulled_goalie_through_events
-
Tries to guess if the goalie was pulled during the game through the game events containing on ice players information.
Arguments: the game the structure holding the pulled goalies Returns: whether at least one team pulled the goalie
guess_pulled_goalie_through_toi
-
Tries to guess if the goalie was pulled during the game through the time on ice spent by goalies during the game.
Arguments: the game the structure holding the pulled goalies Returns: whether at least one team pulled the goalie
guess_pulled_goalies
-
Tries to guess if the goalie was pulled during the game through one of the methods described above.
Arguments: the game Returns: the structure holding the pulled goalies
get_pulled_goalies
-
Gets goalie pulls from the list of player shifts in the game. Limited to period since 2007/08 season.
Arguments: the game Returns: the structure holding the pulled goalies
generate_pulled_goalie
-
Generates the information about the pulled goalies and updates the database with pull counts for each team in the field goalie_pull.
Returns: the goalie pull 2-member array ref.
generate_ne_goals
-
Generates goals that were scored with net empty. In general superseded by event processing during the merge process (see Sport::Analytics::NHL::Merger)
Returns: the list of goals that were scored with net empty.
get_icing_iterator
-
Gets an iterator of icings in the game.
Arguments: the game Returns: a MongoDB Cursor with the icings, or undef if there are no icings.
set_icing_properties
-
Sets some of the icing's properties: the ensuing faceoff, whether the icing team won that faceoff, the team that iced the puck as team1, and the other as team2.
Arguments: the icing event the ensuing faceoff event the zone codes Returns: the update hashref desribed above
adjudicate_icing_quality
-
Adjudicates the quality of the icing: $ICING_GOOD for icing without consequences, $ICING_NEUTRAL for an icing followed by another icing by the same team, $ICING_BAD if followed by a penalty and $ICING_DISASTER if followed by a goal.
Arguments: the ensuing event the faceoff after that event the team committing the icing the zone codes Returns: the quality of the icing.
generate_icings_info
-
Generates the information about the icing: the properties described above, the quality and the ensuing event.
Returns: the array or the arrayref of updates to the icing events
generate_fighting_majors
-
Generates obvious fighting majors opponents from the era predating indication of the player drawing the penalty. The opponent is assigned as player2 of the event.
Returns: the list of the updates to the fights in the game.
check_strikeback
-
Checks if the goal flow of the game indicates a strikeback (a comeback).
Arguments: the winner of the game array of the game goals, excluding shootout Returns: the biggest strikeback delta.
generate_strikebacks
-
Generates strikebacks (comebacks) in the NHL game. Only the full strikebacks (resulting in wins of a trailing team) are generated.
Returns: the strikeback team and size.
generate_lead_changing_goals
-
Generates lead changing and lead swinging goal indicators for goals in the game.
Returns: the list of lcg and lsg goals detected.
generate_icecount_mark
-
Generates a special icecount mark based on either given on-ice presence of players or known on-ice strengths (produced by Sport::Analytics::NHL::PenaltyAnalyzer) The icecount of 4150 means 4 skaters for away team, 1 goalie, 5 for home team, goalie pulled, derived from on-ice protocol. The icecount of 15151 means 5 skaters, one goalie for each team, derived from strengths.
Returns: hashref of icecounts per event id.
get_stops_and_challenges
-
Gets the CHL event and the STOP CHLG events associated with given game ID.
Arguments: Game ID Returns: array of such stops and challenges
check_missing_challenges
-
Checks if there are registered broken/missing challenges with an artificial ID and populates them in the DB.
Arguments: Game ID Returns: void
process_broken_challenge
-
Processes the challenge that has been identified as broken and populates it with data from Sport::Analytics::NHL::Config
Arguments: the event the hashref of the populated challenge the game Returns: 0 if the event is indeed broken and populated 0 if the event is marked as missing 1 if the event is whole
process_stop_challenge
-
Processes a STOP-based challenge, populating the challenge type and the description of the event.
Arguments: the event the hashref of the generated challenge Returns: 0 if the challenge has already been marked 1 otherwise
configure_nhl_offside_challenge
-
Configures the offside challenge initiated by the NHL. Winner and loser of the challenge are set.
Arguments: the challenge being populated the event the game the coordinates normalizer (1 or -1) Returns: void
configure_offside_challenge
-
Configures a generic offside challenge. Result (1/0) and winner and loser are set.
Arguments: the challenge being populated the event the game the coordinates normalizer (1 or -1) Returns: void
configure_goalie_challenge
-
Configures a goaltender interference challenge. Result (1/0) and winner and loser are set.
Arguments: the challenge being populated the event the game Returns: void
configure_league_challenge
-
Configures a generic NHL challenge (video review). Winner and loser are set.
Arguments: the challenge being populated the event the game the coordinates normalizer (1 or -1) Returns: void
configure_challenge
-
Dispatches the configuration of the challenge and fills the common fields: the timestamp, the coach, the type, the event id, the game id, the event type as the source and the challenging team (-1 in the case of the NHL).
Arguments: the challenge being populated the event the game the coordinates normalizer (1 or -1) Returns: void
generate_challenges
-
Generates the coach and the NHL challenges that happen during a game.
Returns: the aggregation of all challenges.
apply_leading_trailing
-
Applies the time elapsed since the last check to leading and trailing time counts of the game. Only leading and tied times are updated. The trailing is the inverse of the leading.
Arguments: the leading-trailing hashref the delta of the score (absolute) the elapsed time the game Returns: void
generate_leading_trailing
-
Generates the times the teams were leading, tied and trailing during a game.
Returns: the hashref with the leading/trailing information.
get_offsides_iterator
-
Gets an iterator over offside events in a game.
Arguments: the game Returns: the MongoDB Cursor ready to iterate, or undef if no offsides happened in a game.
get_offside_faceoff
-
Returns the faceoff following the offside
Arguments: the offside event the faceoffs of the game the zones Returns: the faceoff 0 if the faceoff is not on the right dots undef if there's no faceoff
generate_offsides_info
-
Generate the information about offsides: team committing the offside and the other one as team1 and team2.
Returns: array or arrayref of updated offside events.
generate_gamedays
-
Generate the length of a break before a game for each team.
Returns: the arrayref of the length of the break for each team. The break is set to 30 for the first game of the season.
generate_common_games
-
Generates the common game between pairs of players in a game.
Returns: the list of combination of ids of such players.
get_clutch_type
-
Gets a type of a clutch goal: GEG, GWG, GTG, L(ate)GWG, LGTG. The definition of the GWG differs from the NHL one.
Arguments: the goal [optional] the presumed type, default: gtg Returns: mapping goal_id to clutch type.
get_clutch_goals
-
Gets the clutch goals from all goals of the game and sets their types.
Arguments: the game the goals Returns: the hashref of mappings of clutch goals.
generate_clutch_goals
-
Generates clutch goal information in a game.
Returns: the mapping of clutch goals.
generate_game
-
Generates all of the above, or part of it if specified explicitly by options.
Arguments: the options hash the game Returns: all the generations by type.
generate
-
Generates all of the above, per given game id or a list of games.
Arguments: the options hash the array of games or game IDs Returns: void
AUTHOR
More Hockey Stats, <contact at morehockeystats.com>
BUGS
Please report any bugs or feature requests to contact at morehockeystats.com
, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Sport::Analytics::NHL::Generator. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Sport::Analytics::NHL::Generator
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
https://rt.cpan.org/NoAuth/Bugs.html?Dist=Sport::Analytics::NHL::Generator
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
https://cpanratings.perl.org/d/Sport::Analytics::NHL::Generator
Search CPAN
https://metacpan.org/release/Sport::Analytics::NHL::Generator