id_translation.mapping.support#

Functions and classes used by the Mapper for handling score matrices.

Warning

This module is considered an implementation detail, and may change without notice.

Functions

enable_verbose_debug_messages()

Temporarily enable verbose DEBUG-level logger messages.

Classes

MatchScores(scores, min_score[, logger])

High-level selection operations.

class MatchScores(scores, min_score, logger=None)[source]#

Bases: object

High-level selection operations.

Parameters:
  • scores – A score matrix, where scores.index are values and score.columns are treated as the candidates.

  • min_score – Minimum score to consider make a value -> candidate match.

  • logger – Explicit Logger instance to use.

class Record(value, candidate, score)[source]#

Bases: Generic[ValueType, CandidateType]

Data concerning a match.

candidate#

A hashable candidate.

score#

Likeness score computed by some scoring function.

value#

A hashable value.

class Reject(record, superseding_value=None, superseding_candidate=None)[source]#

Bases: Generic[ValueType, CandidateType]

Data concerning the rejection of a match.

explain(min_score, full=False)[source]#

Create a string which explains the rejection.

Parameters:
  • min_score – Minimum score to accept a match.

  • full – If True show full information about superseding matches.

Returns:

An explanatory string.

record#
superseding_candidate = None#
superseding_value = None#
get_above()[source]#

Get all records with scores above the threshold.

get_below()[source]#

Get all records with scores below the threshold.

property logger#

Return the Logger that is used by this instance.

to_directional_mapping(cardinality=None)[source]#

Create a DirectionalMapping with a given target Cardinality.

Parameters:

cardinality – Explicit cardinality to set, see cardinality. If None, use the actual cardinality when selecting all matches with scores get_above the minimum.

Returns:

A DirectionalMapping.

enable_verbose_debug_messages()[source]#

Temporarily enable verbose DEBUG-level logger messages.

Returns a context manager. Calling the function without the with statement does nothing.

>>> from id_translation.mapping import Mapper, support
>>> with support.enable_verbose_debug_messages():
...     Mapper().apply("ab", candidates="abc")