nanom commited on
Commit
d316e6d
·
1 Parent(s): 83f081c

Updated interface

Browse files
Files changed (2) hide show
  1. app.py +3 -20
  2. modules/m_parser.py +21 -5
app.py CHANGED
@@ -20,29 +20,12 @@ with iface:
20
  error = gr.HTML()
21
 
22
  with gr.Row(variant='panel'):
23
- with gr.Column():
24
- out_infinitive = gr.Textbox(
25
- label="Infinitive",
26
- max_lines=1,
27
- placeholder="The verb in the 'infinitive' will be shown here..."
28
- )
29
- with gr.Column():
30
- out_simple_past = gr.Textbox(
31
- label="Simple Past",
32
- max_lines=1,
33
- placeholder="The verb in the 'past' will be shown here..."
34
- )
35
- with gr.Column():
36
- out_past_participle = gr.Textbox(
37
- label="Past Participle",
38
- max_lines=1,
39
- placeholder="The verb in the 'participle' will be shown here..."
40
- )
41
 
42
  btn_get.click(
43
- fn = execute.get_verbs,
44
  inputs = input_verb,
45
- outputs = [error, out_infinitive, out_simple_past, out_past_participle],
46
  api_name="get"
47
  )
48
 
 
20
  error = gr.HTML()
21
 
22
  with gr.Row(variant='panel'):
23
+ output = gr.Markdown()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  btn_get.click(
26
+ fn = execute.get_verbsv2,
27
  inputs = input_verb,
28
+ outputs = [error, output],
29
  api_name="get"
30
  )
31
 
modules/m_parser.py CHANGED
@@ -58,6 +58,20 @@ class Parser:
58
 
59
  return self.parser(verb)[0]
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  def ___format_error(
62
  self,
63
  error: str
@@ -75,16 +89,16 @@ class Parser:
75
  def get_verbs(
76
  self,
77
  verb: str
78
- ) -> Tuple[str,str,str]:
79
 
80
  verb = verb.strip().lower()
81
- error, infinitive, past, participle = "", "", "", ""
82
 
83
  if verb == "":
84
  error = self.___format_error(
85
  f"Error: The Verb field can not be empty!"
86
  )
87
- return error, infinitive, past, participle
88
 
89
  tk_verb = self.__tokenizer(verb)
90
  infinitive = self.__v2infinitive(tk_verb)
@@ -95,6 +109,8 @@ class Parser:
95
  error = self.___format_error(
96
  f"Error: The verb '<b>{verb}</b>' has not been found or not spelled correctly!"
97
  )
98
- return error, infinitive, past, participle
 
 
99
 
100
- return error, infinitive, past, participle
 
58
 
59
  return self.parser(verb)[0]
60
 
61
+ def ___format_output(
62
+ self,
63
+ infiniteve: str,
64
+ past: str,
65
+ participle: str
66
+ ) -> str:
67
+ template = """
68
+ |infinitive| Simple Past | Past Participle |
69
+ | :----: | :----: | :----: |
70
+ |{} | {}| {}|
71
+ """
72
+ return template.format(infiniteve, past, participle)
73
+
74
+
75
  def ___format_error(
76
  self,
77
  error: str
 
89
  def get_verbs(
90
  self,
91
  verb: str
92
+ ) -> Tuple[str,str]:
93
 
94
  verb = verb.strip().lower()
95
+ error, output = "", ""
96
 
97
  if verb == "":
98
  error = self.___format_error(
99
  f"Error: The Verb field can not be empty!"
100
  )
101
+ return error, output
102
 
103
  tk_verb = self.__tokenizer(verb)
104
  infinitive = self.__v2infinitive(tk_verb)
 
109
  error = self.___format_error(
110
  f"Error: The verb '<b>{verb}</b>' has not been found or not spelled correctly!"
111
  )
112
+ return error, output
113
+
114
+ output = self.___format_output(infinitive, past, participle)
115
 
116
+ return error, output