rics.mapping.filter_functions#

Functions that remove candidates.

Module Attributes

WhereArg

Determines how where matches must be found during filtering operations.

VERBOSE

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

Functions

banned_substring(name, candidates, context, ...)

Prevent mapping if banned substrings are found.

require_regex_match(name, candidates, ...[, ...])

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’]]]

VERBOSE: bool = False#

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

Notes

Not all functions have verbose messages.

require_regex_match(name: str, candidates: Iterable[str], context: Optional[str], regex: Union[str, Pattern[str]], where: Union[Literal['name', 'context', 'candidate'], Iterable[Literal['name', 'context', 'candidate']]], keep_if_match: bool = True, purpose: str = 'matching') 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.

  • purpose – A purpose-string used for logging.

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.