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) | |
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' | |