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
Temporarily enable verbose DEBUG-level logger messages. |
Classes
|
High-level selection operations. |
- class MatchScores(scores, min_score, logger=None)[source]#
Bases:
objectHigh-level selection operations.
- Parameters:
scores – A score matrix, where
scores.indexare values andscore.columnsare treated as the candidates.min_score – Minimum score to consider make a value -> candidate match.
logger – Explicit
Loggerinstance 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
Trueshow full information about superseding matches.
- Returns:
An explanatory string.
- record#
- superseding_candidate = None#
- superseding_value = None#
- property logger#
Return the
Loggerthat is used by this instance.
- to_directional_mapping(cardinality=None)[source]#
Create a
DirectionalMappingwith a given targetCardinality.- Parameters:
cardinality – Explicit cardinality to set, see
cardinality. IfNone, use the actual cardinality when selecting all matches with scoresget_abovethe 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
withstatement does nothing.>>> from id_translation.mapping import Mapper, support >>> with support.enable_verbose_debug_messages(): ... Mapper().apply("ab", candidates="abc")