nanom commited on
Commit
8c97d69
1 Parent(s): 41a74dc
Files changed (3) hide show
  1. app.py +21 -7
  2. css/style.css +5 -0
  3. modules/m_connector.py +5 -2
app.py CHANGED
@@ -9,16 +9,20 @@ with iface:
9
  with gr.Row():
10
  with gr.Column():
11
  in_sentence = gr.Textbox(
12
- label = "Active sentence",
13
  max_lines=2,
14
  lines=1,
15
- placeholder = "Enter here the sentence without contractions...",
16
  )
17
  btn_act2pas = gr.Button(
18
- value = "Pass to passive!"
19
  )
20
- out = gr.HTML(
21
- label = "Out. Pasive sentences:",
 
 
 
 
22
  )
23
 
24
  with gr.Column(variant='panel'):
@@ -27,7 +31,7 @@ with iface:
27
  examples = [
28
  "The teacher corrected the exams in less than an hour",
29
  "Christopher Columbus discovered America in 1492",
30
- "Mchael Jackson sings Billy Jean",
31
  "They are painting the house" ,
32
  "My mom has prepared the dinner",
33
  "The man has not found the farm",
@@ -35,11 +39,21 @@ with iface:
35
  ],
36
  examples_per_page=10
37
  )
 
 
 
 
 
 
 
 
 
38
 
39
  btn_act2pas.click(
40
  fn = conn.active2passive,
41
  inputs = in_sentence,
42
- outputs = out
 
43
  )
44
 
45
  iface.launch(
 
9
  with gr.Row():
10
  with gr.Column():
11
  in_sentence = gr.Textbox(
12
+ label = "Enter an active sentence",
13
  max_lines=2,
14
  lines=1,
15
+ placeholder = "Write here the sentence without contractions...",
16
  )
17
  btn_act2pas = gr.Button(
18
+ value = "Convert to passive sentence!"
19
  )
20
+ str_out = gr.Markdown(
21
+ label = "Output in string format",
22
+ visible=False
23
+ )
24
+ html_out = gr.HTML(
25
+ label = "Output in HTML format",
26
  )
27
 
28
  with gr.Column(variant='panel'):
 
31
  examples = [
32
  "The teacher corrected the exams in less than an hour",
33
  "Christopher Columbus discovered America in 1492",
34
+ "Michael Jackson sings Billy Jean",
35
  "They are painting the house" ,
36
  "My mom has prepared the dinner",
37
  "The man has not found the farm",
 
39
  ],
40
  examples_per_page=10
41
  )
42
+
43
+ gr.HTML("""
44
+ <center>
45
+ <div class="alert alert-light" role="status">
46
+ DISCLAIMER: At the moment the application only works well with sentences in the following tense: Simple present, Simple past, Simple future, Present continuous, Past continuous and Present perfect.
47
+ </div>
48
+ </center>
49
+ """,
50
+ )
51
 
52
  btn_act2pas.click(
53
  fn = conn.active2passive,
54
  inputs = in_sentence,
55
+ outputs = [html_out, str_out],
56
+ api_name="active2passive"
57
  )
58
 
59
  iface.launch(
css/style.css CHANGED
@@ -1,3 +1,8 @@
 
 
 
 
 
1
  h1, h2, h3, h4, h5, h6 {
2
  margin-top: 0;
3
  margin-bottom: 0.5rem;
 
1
+ .container {
2
+ max-width: 85%;
3
+ margin: auto;
4
+ }
5
+
6
  h1, h2, h3, h4, h5, h6 {
7
  margin-top: 0;
8
  margin-bottom: 0.5rem;
modules/m_connector.py CHANGED
@@ -18,7 +18,7 @@ class Connector:
18
  try:
19
  data = self.avoice.to_pasive(sentence)
20
  except Exception as e:
21
- return self.html.error(str(e))
22
 
23
  subj = self.html.budget(data['subj'], 'subject', 'primary')
24
  tobe = self.html.budget(data['tobe'],'to be','warning')
@@ -26,4 +26,7 @@ class Connector:
26
  agent = self.html.budget(data['agent'],'agent','success')
27
  compl = self.html.budget(data['compl'],'compl.','dark')
28
 
29
- return self.html.output(f"{subj} {tobe} {participle} {agent} {compl}")
 
 
 
 
18
  try:
19
  data = self.avoice.to_pasive(sentence)
20
  except Exception as e:
21
+ return self.html.error(str(e)), str(e)
22
 
23
  subj = self.html.budget(data['subj'], 'subject', 'primary')
24
  tobe = self.html.budget(data['tobe'],'to be','warning')
 
26
  agent = self.html.budget(data['agent'],'agent','success')
27
  compl = self.html.budget(data['compl'],'compl.','dark')
28
 
29
+ string_format = f"{data['subj']} {data['tobe']} {data['participle']} {data['agent']} {data['compl']}"
30
+ html_format = self.html.output(f"{subj} {tobe} {participle} {agent} {compl}")
31
+
32
+ return html_format, string_format