The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Sport::Analytics::NHL::Merger - Merge the extra (HTML) reports into the master one (JSON).

SYNOPSYS

Merge the extra (HTML) reports into the master one (JSON).

These are methods that match the data in the extra reports to the master one and merge it, or complement it, where necessary.

    use Sport::Analytics::NHL::Merger;
    merge_report($boxscore, $html_report);

GLOBAL VARIABLES

 The behaviour of the tests is controlled by several global variables:
 * $CURRENT - the type of the report currently being merged.
 * $BOXSCORE - the boxscore currently being merged.
 * $PLAYER_RESOLVE_CACHE - the player roster resolution cache as described in Sport::Analytics::NHL::Report::BS (q.v.)

FUNCTIONS

check_player_names

When trying to resolve a player in the HTML report to his NHL id, look up by player's name in the names section of the resolve cache.

 Arguments: * event description
            * resolve cache
            * player's number
 Returns: the reference to the player in the boxscore roster
copy_events

Copy the events from a report when the original section of reports in the live boxscore is missing.

 Arguments: * the boxscore report
            * the extra report being merged
 Returns: void, sets $boxscore->{events}
expected_miss

Checks if the event in the merged report was expected to be missed (i.e. not matched) within the boxscore

 Arguments: * the type of the merged report
            * the event in question
            * the master boxscore
 Returns: 0|1
find_event

Finds the matching event from the extra report in the master boxscore.

 Arguments: * the event
            * the master boxscore event list
            * the type of the extra report
 Returns: the matched event or -1
find_player

Finds the matching player from the extra report in the master boxscore.

 Arguments: * the player data
            * the roster in the matching boxscore to look in
            * [optional] list of players on ice to look in
 Returns: the matched player or undef
find_player_by_id

Used by find_player to find the player by the NHL id.

 Arguments: * the player data
            * the roster in the matching boxscore to look in
 Returns: the matched player or undef
find_player_by_name

Used by find_player to find the player by the name.

 Arguments: * the player data
            * the roster in the matching boxscore to look in
            * [optional] list of players on ice to look in
 Returns: the matched player or undef
merge_events

Merges the matched events' data. Usually the data in the boxscore is considered correct, so only additional data is added.

 Arguments: * the boxscore report
            * the extra report being merged
 Returns: void, sets $boxscore->{events}
merge_me

Actually performs the merging of the item. Usually the data in the boxscore is considered correct, so only additional data is added.

 Arguments: * the boxscore item
            * the extra report item
            * [optional] list of fields to be merged
 Returns: void, sets the event's fields.
merge_report

The function to call to merge two reports.

 Arguments: * the boxscore report
            * the extra report being merged
 Returns: void, sets $boxscore and adds $boxscore->{sources}
merge_roster

Merges two rosters of a team, from the master boxscore and from the extra report.

 Arguments: * the boxscore roster
            * the report roster
 Returns: void, sets the roster.
merge_teams

Merges the teams of the game, from the master boxscore and from the extra report.

 Arguments: * the boxscore report
            * the extra report being merged
 Returns: void, sets $boxscore
push_event

Pushes the event that is found in the extra report but not in the master boxscore into the master boxscore's event list.

 Arguments: * the event
            * the master boxscore
            * the type of the extra report
 Returns: void, sets $boxscore->{events}
refine_candidates

In case find_event (q.v.) is matched with more than one event, refines the candidate list to ultimately find the event.

 Arguments: * the event
            * the list of candidates
 Returns: the refined list of candidates
resolve_report

Resolves the extra report players in the roster, in the events and on ice to their NHL ids.

 Arguments: * the boxscore report
            * the extra report being merged
 Returns: void. The extra report is modified.
resolve_report_event_fields

Resolves event fields such as player1, player2, assist1, assist2 and servedby to the NHL ids.

 Arguments: * the event
            * the master boxscore
 Returns: void. The event is modified.
resolve_report_event_teams

Resolves the extra report event teams to their NHL ids.

 Arguments: * the event
            * the master boxscore
 Returns: void. The event is modified.
resolve_report_on_ice

Resolves the players on the ice during the event to their NHL ids.

 Arguments: * the event
            * the master boxscore
 Returns: void. The event is modified.
resolve_report_roster

Resolves the players on the rosters of the extra report to their NHL ids.

 Arguments: * the roster
            * the master boxscore
            * the roster index (0 - away, 1 - home)
 Returns: void. The roster is modified.

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

You can also look for information at: