Pair2 v0.1.1 Pair2.Comparer View Source

Core functions for comparing two values or maps and returning a similarity value between 0.0 and 1.0.

Link to this section Summary

Functions

Based on argument types and values, selects one of the compare_* methods to use for comparing x and y

Compares the absolute difference between dates x and y and returns the similarity expressed as the difference in days divided by the max_days argument. Return value is between 0.0 and 1.0

Scores the similarity of two maps based on a list of rules. Returns score that is >= 0.0

Compares the absolute difference between numbers x and y and returns the similarity expressed as the difference divided by the larger of x or y. Return value is between 0.0 and 1.0

Compares x and y using the match criteria defined in the fun argument. Function should return value between 0.0 and 1.0

Link to this section Functions

Based on argument types and values, selects one of the compare_* methods to use for comparing x and y.

Link to this function compare_days(x, y, max_days) View Source

Compares the absolute difference between dates x and y and returns the similarity expressed as the difference in days divided by the max_days argument. Return value is between 0.0 and 1.0.

Link to this function compare_maps(map_l, map_r, rules) View Source

Scores the similarity of two maps based on a list of rules. Returns score that is >= 0.0.

Compares the absolute difference between numbers x and y and returns the similarity expressed as the difference divided by the larger of x or y. Return value is between 0.0 and 1.0.

Examples

iex> Compare.compare_nums(5, 10) 0.5

Link to this function compare_with_fun(x, y, fun) View Source

Compares x and y using the match criteria defined in the fun argument. Function should return value between 0.0 and 1.0