File size: 697 Bytes
4e0f321 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
from src.rule_based_system.Rule import Rule
from src.rule_based_system.Verdict import Verdict
TEXT_SIZE_LIMIT = 500
class TextLengthRule(Rule):
def get_verdict(self, comment_text: str) -> Verdict:
allows = True \
and not self.is_empty(comment_text) \
and not self.is_too_long(comment_text, TEXT_SIZE_LIMIT)
return Verdict(allows, [])
@staticmethod
def is_empty(text):
return len(text) == 0
@staticmethod
def is_too_long(text, limit):
return len(text) > limit
def is_strict(self) -> bool:
return True
@staticmethod
def get_rule_description() -> str:
return 'Inappropriate text length'
|