id_translation.mapping.matrix#
Functions and classes used by the Mapper for handling score matrices.
Warning
This module is considered an implementation detail, and may change without notice.
Classes
|
Data concerning a match. |
|
Data concerning the rejection of a match. |
|
High-level selection operations. |
|
A matrix of match scores. |
- class Record(value, candidate, score)[source]#
Bases:
Generic[ValueType,CandidateType]Data concerning a match.
- score#
Likeness score computed by some scoring function.
- class Reject(record, superseding_value=None, superseding_candidate=None)[source]#
Bases:
Generic[ValueType,CandidateType]Data concerning the rejection of a match.
- class ScoreHelper(matrix, min_score, logger=None, *, task_id=None)[source]#
Bases:
Generic[ValueType,CandidateType]High-level selection operations.
- Parameters:
matrix – A
ScoreMatrixinstance.min_score – Minimum score to make a value -> candidate match.
logger – Explicit
Loggerinstance to use.task_id – Used for logging.
- 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 scoresat or abovethe minimum.- Returns:
A
DirectionalMapping.
- class ScoreMatrix(values, candidates, *, grid=None)[source]#
Bases:
Generic[ValueType,CandidateType]A matrix of match scores.
- Parameters:
values – Iterable of elements to match to candidates.
candidates – Iterable of candidates to match with value. Duplicate elements will be discarded.
grid – Initial score matrix. Default is to fill with
-inf.
- Raises:
ValueError – If a bad grid is given.
- property candidates#
Unique candidates in order.
- property size#
Total number of elements.
- to_pandas()[source]#
Convert to
pandas.DataFrame.
- property values#
Unique values in order.