from typing import Tuple from modules.m_apvoice import APVoice class Connector: def __init__( self ) -> None: self.apvoice = APVoice() self.__out_template = """
{}
""" self.__error_template = "

{}

" def create_category( self, text: str, category: str, color: str ) -> str: html = f"""
{text}
{category}
""" return html if text != "" else "" def active2passive( self, sentence: str ) -> Tuple[str,str]: out = "" try: out = self.apvoice.active2passive(sentence) out = f""" {self.create_category(out['subject'], 'subject','primary')} {self.create_category(out['tobe'],'to be','warning')} {self.create_category(out['participle'],'participle','danger')} {self.create_category(out['agent'],'agent','info')} {self.create_category(out['complement'],'compl.','dark')} """ out = self.__out_template.format(out) except Exception as e: out = self.__error_template.format(str(e)) return out