class RuleBasedSystem: rules = [] def __init__(self, rules: list): self.rules = rules def allows(self, comment_text: str) -> (bool, list): allows, reasons, highlights = True, [], [] for rule in self.rules: verdict = rule.get_verdict(comment_text) if not verdict.allowed: allows = False reasons.append(rule.get_rule_description()) highlights += verdict.highlights return allows, reasons, highlights