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, error = "", ""
try:
subject, tobe, participle, agent, complement = self.apvoice.active2passive(sentence)
verb = f"""
"""
passive_sentece = f"""
{self.create_category(subject, 'subject','primary')}
{self.create_category(tobe,'to be','warning')}
{self.create_category(participle,'participle','danger')}
{self.create_category(agent,'agent','info')}
{self.create_category(complement,'compl.','dark')}
"""
out = self.__out_template.format(passive_sentece)
except Exception as e:
error = self.__error_template.format(str(e))
return error, out