rics.mapping.score_functions#

Functions which return a likeness score.

See also

The HeuristicScore class.

Module Attributes

VERBOSE

If True enable optional DEBUG-level log messages on each score function invocation.

Functions

equality(value, candidates, context)

Return 1.0 if k == c_i, 0.0 otherwise.

modified_hamming(name, candidates, context)

Compute hamming distance modified by length ratio, from the back.

VERBOSE: bool = False#

If True enable optional DEBUG-level log messages on each score function invocation.

Notes

Not all functions have verbose messages.

modified_hamming(name: str, candidates: Iterable[str], context: Optional[ContextType], add_length_ratio_term: bool = True) Iterable[float][source]#

Compute hamming distance modified by length ratio, from the back. Score range is [0, 1].

Keyword Arguments

add_length_ratio_term – If True, score is divided by abs(len(name) - len(candidate)).

Examples

>>> from rics.mapping.score_functions import modified_hamming
>>> print(list(modified_hamming('aa', ['aa', 'a', 'ab'], context=None)))
[1.0, 0.5, 0.5]
>>> print(list(modified_hamming('face', ['face', 'FAce', 'race', 'place'], context=None)))
[1.0, 0.5, 0.75, 0.375]
equality(value: ValueType, candidates: Iterable[CandidateType], context: Optional[ContextType]) Iterable[float][source]#

Return 1.0 if k == c_i, 0.0 otherwise.

Examples

>>> from rics.mapping.score_functions import equality
>>> print(list(equality('a', 'aAb', context=None)))
[1.0, 0.0, 0.0]