def compare_scores(model: Model, left: EntityProxy, right: EntityProxy) -> Scores: """Compare two entities and return a match score for each property.""" try: model.common_schema(left.schema, right.schema) except InvalidData: return {} scores: Scores = {} left_inv = left.get_type_inverted(matchable=True) right_inv = right.get_type_inverted(matchable=True) left_groups = set(left_inv.keys()) right_groups = set(right_inv.keys()) for group_name in left_groups.intersection(right_groups): group = registry.groups[group_name] try: if group == registry.name: score = compare_names(left, right) elif group == registry.country: score = compare_countries(left, right) else: score = compare_group(group, left_inv[group_name], right_inv[group_name]) scores[group] = score except ValueError: pass for group_name in left_groups.symmetric_difference(right_groups): group = registry.groups[group_name] scores[group] = None return scores
import os from followthemoney.model import Model from followthemoney.util import set_model_locale __version__ = '1.23.4' model_path = os.path.dirname(__file__) model_path = os.path.join(model_path, 'schema') model_path = os.environ.get('FTM_MODEL_PATH', model_path) # Data model singleton model = Model(model_path) __all__ = [model, set_model_locale]