Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,33 @@
|
|
1 |
import gradio as gr
|
2 |
-
import classla
|
3 |
-
classla.download('hr')
|
4 |
-
nlp = classla.Pipeline('hr')
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
iface.launch()
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
2 |
|
3 |
+
# Define a list of word and translation pairs
|
4 |
+
word_translations = [
|
5 |
+
{"word": "Hello", "translation": "Hola"},
|
6 |
+
{"word": "Goodbye", "translation": "Adiós"},
|
7 |
+
{"word": "Thank you", "translation": "Gracias"},
|
8 |
+
{"word": "Please", "translation": "Por favor"}
|
9 |
+
]
|
10 |
+
|
11 |
+
# Initialize an index to keep track of the current word
|
12 |
+
current_index = 0
|
13 |
+
|
14 |
+
# Function to display the current word and translation
|
15 |
+
def display_word():
|
16 |
+
global current_index
|
17 |
+
word_translation = word_translations[current_index]
|
18 |
+
current_index = (current_index + 1) % len(word_translations)
|
19 |
+
return f"Word: {word_translation['word']}<br>Translation: {word_translation['translation']}"
|
20 |
+
|
21 |
+
# Create a Gradio interface
|
22 |
+
iface = gr.Interface(
|
23 |
+
fn=display_word,
|
24 |
+
live=True,
|
25 |
+
title="Word Translation App",
|
26 |
+
description="Click 'Next' to view the next word and translation.",
|
27 |
+
inputs=[],
|
28 |
+
outputs=["html"],
|
29 |
+
layout="vertical"
|
30 |
+
)
|
31 |
+
|
32 |
+
# Start the Gradio interface
|
33 |
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|