fabricatio_rule.capabilities.censor
Module for censoring objects and strings based on provided rulesets.
This module includes the Censor class which inherits from both Correct and Check classes. It provides methods to censor objects and strings by first checking them against a ruleset and then correcting them if necessary.
Classes
Class to censor objects and strings based on provided rulesets. |
Module Contents
- class fabricatio_rule.capabilities.censor.Censor(/, **data: Any)
Bases:
fabricatio_improve.capabilities.correct.Correct,fabricatio_rule.capabilities.check.Check,abc.ABCClass to censor objects and strings based on provided rulesets.
Inherits from both Correct and Check classes. Provides methods to censor objects and strings by first checking them against a ruleset and then correcting them if necessary.
- async censor_obj[M: fabricatio_core.models.generic.SketchedAble](obj: M, ruleset: fabricatio_rule.models.rule.RuleSet, **kwargs: Unpack[fabricatio_capabilities.models.kwargs_types.ReferencedKwargs[M]]) M | None
Censors an object based on the provided ruleset.
- Parameters:
obj (M) – The object to be censored.
ruleset (RuleSet) – The ruleset to apply for censoring.
**kwargs – Additional keyword arguments to be passed to the check and correct methods.
- Returns:
The censored object if corrections were made, otherwise None.
- Return type:
Optional[M]
Note
This method first checks the object against the ruleset and then corrects it if necessary.
- async censor_string(input_text: str, ruleset: fabricatio_rule.models.rule.RuleSet, **kwargs: Unpack[fabricatio_capabilities.models.kwargs_types.ReferencedKwargs[str]]) str | None
Censors a string based on the provided ruleset.
- Parameters:
- Returns:
The censored string if corrections were made, otherwise None.
- Return type:
Optional[str]
Note
This method first checks the string against the ruleset and then corrects it if necessary.
- async censor_obj_inplace[M: fabricatio_capabilities.models.generic.ProposedUpdateAble](obj: M, ruleset: fabricatio_rule.models.rule.RuleSet, **kwargs: Unpack[fabricatio_capabilities.models.kwargs_types.ReferencedKwargs[M]]) M | None
Censors an object in-place based on the provided ruleset.
This method modifies the object directly if corrections are needed.
- Parameters:
obj (M) – The object to be censored.
ruleset (RuleSet) – The ruleset to apply for censoring.
**kwargs – Additional keyword arguments to be passed to the check and correct methods.
- Returns:
The censored object if corrections were made, otherwise None.
- Return type:
Optional[M]
Note
This method first checks the object against the ruleset and then corrects it in-place if necessary.