NAME

Sport::Analytics::NHL::Normalizer - normalize the merged boxscore, providing default values and erasing extra and redundant data.

SYNOPSYS

Normalizes the merged boxscore, providing default values and erasing extra and redundant data.

These functions first summarize the events in the boxscore to help to try to find incosistencies with the summary in the player stats and in the team stats. Then all data in the boxscore is normalized and standardized, the PSTR, PEND and GEND events are added where necessary, and events are sorted and _id-ed properly.

use Sport::Analytics::NHL::Normalizer;
my $event_summary = summarize($boxscore);
normalize($boxscore);

GLOBAL VARIABLES

The behaviour of the tests is controlled by several global variables:
* $PLAYER_IDS - hashref of all player ids encountered.

FUNCTIONS

assign_event_ids

Assigns flowing event ids to the boxscore events of the form:

* event_id : 1..@events
* _id: game_id*10000 + event_id

Arguments: the events array reference Returns: void. Sets the events in the boxscore.

insert_pend

Inserts a PEND (Period End) event into the group of events of a given period.

Arguments:

* The arrayref of the events of the period
* The number of the period
* The last event of the period
* The flag if the event ended the period (e.g. OT goal)

Returns: void. Modifies the period arrayref

insert_pstr

Inserts a PSTR (Period Start) event into the group of events of a given period.

Arguments:

* The arrayref of the events of the period
* The number of the period
* The first event of the period

Returns: void. Modifies the period arrayref

normalize_boxscore

Does the module's main purpose: normalizes the boxscore

Arguments:

* boxscore to normalize
* flag whether to skip summarizing

Returns: the $PLAYER_IDS hashref (q.v.) of all player ids encountered. Boxscore is modified.

normalize_event_by_type

Normalizes event according to its type.

Arguments: the event

Returns: void. The event is modified.

normalize_event_header

Normalizes event's "header" - the general data such as zone, game, strength, time data.

Arguments:

* The event
* The boxscore

Returns: void. The event is modified.

normalize_event_on_ice

Normalizes event's on ice player data - makes sure that only NHL player ids are there, and if a team's on ice data is not present, removes it completely.

Argument: the event

Returns: void. The event is modified.

normalize_event_players_teams

Normalizes the teams and the players actively participating in the event.

normalize_events

Normalizes the boxscore's event and calls the lesser functions according to the event's data.

Argument: the boxscore

Returns: void. The boxscore is modified.

normalize_goal_event

Normalizes the specifics of the GOAL event.

Argument: the event

Returns: void. The event is modified.

normalize_header

Normalizes the game's header: date, location, attendance etc.

Argument: the boxscore

Returns: void. The boxscore is modified.

normalize_penl_event

Normalizes the specifics of the PENL event.

Argument: the event

Returns: void. The event is modified.

normalize_players

Normalizes the players on the rosters of the boxscore, their stats and strings.

Argument: the roster from the boxscore.

Returns: void. The roster is modified.

normalize_result

Produces and normalizes an extra sub-structure of game result of one of the forms: [2,0], [0,2], [2,1], [1,2], [1,1] - points gained by each of the teams. First number indicates away, second indicates home team.

Argument: the boxscore

Returns: void. The result is set in the boxscore.

normalize_team

Normalizes the data of a team in the NHL boxscore - coach, score, name, etc.

Argument: the boxscore team

Returns: void. The team is modified.

normalize_teams

Normalizes the teams in the NHL boxscore. Calls normalize_team (q.v.) and normalize_roster (q.v.)

Argument: the boxscore

Returns: void. The boxscore is modified.

sort_events

Sorts the events of the boxscore, inserting the PSTR, PEND and GEND events if necessary. The events are sorted by:

* Period
* Timestamp
* Event precedence rank (from PSTR (highest) to GEND (lowest))
* Event type
* Event's active team

Argument: the boxscore

Returns: void. The boxscore is modified.

summarize

Generates a summary of events of a boxscore. Each playing event is converted into stats of the players and teams participating in it.

Argument: the boxscore

Returns: the summary of the events

summarize_goal

Summarizes the data of a GOAL event.

Arguments:

* the event summary
* the goal event
* the boxscore
* the positions cache generated with Sport::Analytics::NHL::Tools (q.v.)

Returns: void. The event summary is modified.

summarize_other_event

Summarizes an event that is not a GOAL or a PENL.

Arguments:

* the event summary
* the event

Returns: void. The event summary is modified.

summarize_penalty

Summarizes the data of a PENL event.

Arguments:

* the event summary
* the penalty event

Returns: void. The event summary is modified.

add_playoff_info

Adds information specific to playoff series to the game: the round, the series number and the game number in the series.

Arguments: the boxscore

Returns: void. The boxscore is modified.
set_roster_positions

Prepares a hash with positions of each player id in the boxscore for future caching and resolving purposes.

Arguments: the boxscore Returns: the positions hash.

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::Normalizer. 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::Normalizer

You can also look for information at: