nosdigitalmedia's picture
Attempt to set up application
4e0f321
raw
history blame
743 Bytes
from bs4 import BeautifulSoup
from src.rule_based_system.Rule import Rule
from src.rule_based_system.Verdict import Verdict
class HTMLRule(Rule):
def get_verdict(self, comment_text: str) -> Verdict:
html = self.find_html(comment_text)
return Verdict(len(html) == 0, html)
@staticmethod
def find_html(text: str) -> list:
html = BeautifulSoup(text, "html.parser").find_all()
return [str(tag) for tag in html]
def is_strict(self) -> bool:
"""
This rule occasionally removes appropriate comments when names are enclosed in triangular brackets e.g. <name>
"""
return False
def get_rule_description(self) -> str:
return 'HTML used in comment text'