rics.mapping.heuristic_functions#
Functions which perform heuristics for score functions.
Functions
|
Return candidates formatted by fstring. |
|
Force lower-case in value and candidates. |
|
Try to make value look like the name of a database table. |
|
Short circuit candidates which match a given regex to a given to-candidate. |
|
Short circuit candidates which match a given regex a given to-value. |
|
Return a value formatted by fstring. |
- like_database_table(name: str, candidates: Iterable[str], context: Optional[ContextType]) Tuple[str, List[str]][source]#
Try to make value look like the name of a database table.
- short_circuit_to_value(value: str, candidates: Iterable[str], context: Optional[str], regex: Union[str, Pattern], target: str) Set[str][source]#
Short circuit candidates which match a given regex a given to-value.
- Parameters
value – A value to map.
candidates – Candidates for value.
context – Context in which the function is being called.
regex – A pattern in candidates which should trigger forced short-circuit matching.
target – The target value. If
value != to_value, an empty set is always returned.
- Returns
Candidates which match regex, or an empty set.
Notes
This is technically a filter function and may be used as such.
- short_circuit_to_candidate(value: str, candidates: Iterable[str], context: Optional[str], regex: Union[str, Pattern], target: str) Set[str][source]#
Short circuit candidates which match a given regex to a given to-candidate.
- Parameters
value – A value to map.
candidates – Candidates for value.
context – Context in which the function is being called.
regex – A pattern in candidates which should trigger forced short-circuit matching.
target – A target candidate. Must be present in candidates, or empty set is always returned.
- Returns
Candidates which match regex, or an empty set.
Notes
This is technically a filter function and may be used as such.
- force_lower_case(value: str, candidates: Iterable[str], context: Optional[ContextType]) Tuple[str, Iterable[str]][source]#
Force lower-case in value and candidates.
- value_fstring_alias(value: str, candidates: Iterable[str], context: Optional[ContextType], fstring: str, **kwargs: Any) Tuple[str, Iterable[str]][source]#
Return a value formatted by fstring.
- Parameters
value – Passed to fstring.format using the value placeholder key.
candidates – Not used (returned as given).
context – Context in which the function is being called.
fstring – The format string to use.
**kwargs – Additional keyword placeholders in fstring.
- Returns
A tuple (formatted_value, candidates).
- candidate_fstring_alias(value: str, candidates: Iterable[str], context: Optional[ContextType], fstring: str, **kwargs: Any) Tuple[str, Iterable[str]][source]#
Return candidates formatted by fstring.
- Parameters
value – Not used (returned as given).
candidates – Passed to fstring.format using the candidates placeholder key.
context – Context in which the function is being called.
fstring – The format string to use.
**kwargs – Additional keyword placeholders in fstring.
- Returns
A tuple (value, formatted_candidates).