espnet3.contract.normalizers.register_normalizer
Less than 1 minute
espnet3.contract.normalizers.register_normalizer
espnet3.contract.normalizers.register_normalizer(name: str, function: Callable[[Any], Any], , replace: bool = False) → None
Register a recipe transformation; the owning Kind checks its result.
- Parameters:
- name – The name config files use in
normalize. - function – A callable from a Kind’s checked value to a value of the same Kind.
- replace – Allow redefining a name already registered.
- name – The name config files use in
- Returns: None.
- Raises:
- TypeError – If
functionis not callable. - ValueError – If
nameis taken andreplaceis false.
- TypeError – If
Examples
>>> register_normalizer("shout", str.upper, replace=True)
>>> NORMALIZERS["shout"]("hi")
'HI'