Pair2 v0.1.1 Pair2.Matcher View Source

Rules-based matcher for finding optimal 1:1 matches between two lists of maps.

Link to this section Summary

Functions

Add a right match to the list associated with the left map. Structure: { left1: [{right1, score1}, {right2, score2}, …], left2… }

For a given left map, find the highest-scoring right map that is available for matching. If a previously-existing matched pair has a lower score, replace it and add that previous left map back to the unresolved list

Performs 1:1 match of two lists of maps, list_l and list_r, by applying rules from a list of rule structs. For two maps to match, their match score must be >= min_score

Resolves conflicts between left and right sides. Conflicts occur when a single right map is the highest-scoring match to more than one left map

Link to this section Functions

Link to this function add_match(matches, left, right, score) View Source

Add a right match to the list associated with the left map. Structure: { left1: [{right1, score1}, {right2, score2}, …], left2… }

Link to this function best_match(left, list, matched_rights) View Source

For a given left map, find the highest-scoring right map that is available for matching. If a previously-existing matched pair has a lower score, replace it and add that previous left map back to the unresolved list.

Link to this function get_all_matches(list_l, indexed_attrs, rules, min_score) View Source
Link to this function get_indexed_rule_attrs(rules) View Source
Link to this function match(list_l, list_r, rules, min_score) View Source

Performs 1:1 match of two lists of maps, list_l and list_r, by applying rules from a list of rule structs. For two maps to match, their match score must be >= min_score.

Resolves conflicts between left and right sides. Conflicts occur when a single right map is the highest-scoring match to more than one left map.

Returns a list of finalized match tuples of form: {left, right, score}

For each left map: 1) Add all to an “unresolved” list. 2) For each left map in the unresolved list, choose the highest available match

if it hasn't already been assigned. If it has been assigned, award the match
to the pair with the highest score. Add the losing map back onto the unresolved list.

3) Continue until the unresolved list is empty.

Link to this function resolve(list, all, matched_rights) View Source