Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,37 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
# Function for the Minify interface
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# Function for the Should we translate? interface
|
8 |
-
def check_input(
|
9 |
-
if not
|
|
|
|
|
|
|
10 |
return "No words in the input."
|
11 |
-
words =
|
12 |
response = [f"'{word}' is a valid word." if word.isalpha() and ' ' not in word else f"'{word}' is not a valid word." for word in words]
|
13 |
return " ".join(response)
|
14 |
|
15 |
-
should_we_translate = gr.Interface(
|
|
|
|
|
|
|
|
|
16 |
|
17 |
-
# Creating a Tabbed Interface with updated
|
18 |
demo = gr.TabbedInterface([minify, should_we_translate], ["Minify", "Should we translate?"])
|
19 |
|
20 |
if __name__ == "__main__":
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
# Function for the Minify interface
|
4 |
+
def minify_function(input_text, uploaded_file):
|
5 |
+
if uploaded_file is not None:
|
6 |
+
content = uploaded_file.read().decode("utf-8")
|
7 |
+
else:
|
8 |
+
content = input_text
|
9 |
+
return "Hello " + content
|
10 |
+
|
11 |
+
minify = gr.Interface(
|
12 |
+
minify_function,
|
13 |
+
[gr.Textbox(label="Input Text"), gr.File(label="Upload File")],
|
14 |
+
"text"
|
15 |
+
)
|
16 |
|
17 |
# Function for the Should we translate? interface
|
18 |
+
def check_input(input_text, uploaded_file):
|
19 |
+
if uploaded_file is not None:
|
20 |
+
input_text = uploaded_file.read().decode("utf-8")
|
21 |
+
|
22 |
+
if not input_text.strip():
|
23 |
return "No words in the input."
|
24 |
+
words = input_text.split()
|
25 |
response = [f"'{word}' is a valid word." if word.isalpha() and ' ' not in word else f"'{word}' is not a valid word." for word in words]
|
26 |
return " ".join(response)
|
27 |
|
28 |
+
should_we_translate = gr.Interface(
|
29 |
+
check_input,
|
30 |
+
[gr.Textbox(label="Input Text"), gr.File(label="Upload File")],
|
31 |
+
"text"
|
32 |
+
)
|
33 |
|
34 |
+
# Creating a Tabbed Interface with updated functionalities
|
35 |
demo = gr.TabbedInterface([minify, should_we_translate], ["Minify", "Should we translate?"])
|
36 |
|
37 |
if __name__ == "__main__":
|