rics.mapping.filter_functions#
Functions that remove candidates.
Module Attributes
Determines how where matches must be found during filtering operations. |
Functions
|
Prevent mapping if banned substrings are found. |
|
Require a regex match in name, context, and/or candidates. |
- WhereArg#
Determines how where matches must be found during filtering operations.
alias of
Union[Literal[‘name’, ‘context’, ‘candidate’],Iterable[Literal[‘name’, ‘context’, ‘candidate’]]]
- require_regex_match(name: str, candidates: Iterable[str], context: Optional[str], regex: Union[str, Pattern], where: Union[Literal['name', 'context', 'candidate'], Iterable[Literal['name', 'context', 'candidate']]], keep_if_match: bool = True) Set[str][source]#
Require a regex match in name, context, and/or candidates.
- Parameters
name – A name.
candidates – Potential matches for name.
context – Context in which the function is being called.
regex – A regex pattern to pass to
re.compile().where – Which of (‘name’, ‘candidate’, ‘context’) to match in.
keep_if_match – If
False, require that regex does _not_ match to keep candidates.
- Returns
Approved candidates.
- Raises
ValueError – If where contains ‘context’ when context is not given.
See also
The
banned_substring()method.
- banned_substring(name: str, candidates: Iterable[str], context: Optional[str], substrings: Collection[str], where: Union[Literal['name', 'context', 'candidate'], Iterable[Literal['name', 'context', 'candidate']]]) Set[str][source]#
Prevent mapping if banned substrings are found.
Matching on name or context halts all mapping. Matching candidates excludes only those candidates.
- Parameters
name – An element to find matches for.
candidates – Potential matches for name (not used).
context – Context in which the function is being called.
substrings – Substrings which may not be present in name.
where – Which of (‘name’, ‘candidate’, ‘context’) to match in. Empty=all.
- Returns
Approved candidates.
See also
The
require_regex_match()method, which performs the actual work.