File size: 940 Bytes
5d0a311
e5fc5ba
 
 
5d0a311
 
 
 
 
e5fc5ba
 
5d0a311
 
 
 
 
 
 
e5fc5ba
5d0a311
e5fc5ba
5d0a311
e5fc5ba
 
 
 
 
 
 
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
from typing import Tuple
from modules.m_active_voice import ActiveVoice
from modules.m_htmlrender import HtmlRender
        
class Connector:
    def __init__(
        self
    ) -> None:

        self.avoice = ActiveVoice()
        self.html = HtmlRender()

    def active2passive(
        self,
        sentence: str
    ) -> Tuple[str,str]:

        try:
            data = self.avoice.to_pasive(sentence)
        except Exception as e:
            return self.html.error(str(e))

        subj        = self.html.budget(data['subj'], 'subject', 'primary')
        tobe        = self.html.budget(data['tobe'],'to be','warning')
        participle  = self.html.budget(data['participle'],'participle','danger')
        agent       = self.html.budget(data['agent'],'agent','success')
        compl       = self.html.budget(data['compl'],'compl.','dark')
        
        return self.html.output(f"{subj} {tobe} {participle} {agent} {compl}")