Skip to content

Various utility and core functions

followthemoney.compare.compare(left, right, weights=COMPARE_WEIGHTS)

Compare two entities and return a match score.

Source code in followthemoney/compare.py
def compare(
    left: EntityProxy,
    right: EntityProxy,
    weights: Weights = COMPARE_WEIGHTS,
) -> float:
    """Compare two entities and return a match score."""
    if left.checksum == right.checksum:
        # Check if there is any data at all (ie any basis for making a decision),
        # if so, return a perfect match. This avoids marking two empty entities
        # as matching. Bit ambiguous, but practical.
        if len(left.properties) > 0 and len(right.properties) > 0:
            return 1.0
    scores = compare_scores(left, right)
    return _compare(scores, weights)