Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,11 @@
|
|
| 1 |
-
import
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
#
|
|
|
|
| 4 |
|
|
|
|
| 5 |
def translate_text(text):
|
| 6 |
# Clean the user's input: remove spaces, punctuation, and make it lowercase
|
| 7 |
def clean_phrase(phrase):
|
|
@@ -32,4 +36,16 @@ def translate_text(text):
|
|
| 32 |
return f"Did you mean: '{row['Phrase in your language']}'? Translation: {row['English translation']}"
|
| 33 |
|
| 34 |
# 3. If nothing is close enough
|
| 35 |
-
return "Translation not found. Try 'Kita kobor?' or 'Kita korde?'."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import difflib # For smart suggestions
|
| 4 |
|
| 5 |
+
# Load your CSV data
|
| 6 |
+
df = pd.read_csv("Babeli.csv")
|
| 7 |
|
| 8 |
+
# Function to translate using your CSV data
|
| 9 |
def translate_text(text):
|
| 10 |
# Clean the user's input: remove spaces, punctuation, and make it lowercase
|
| 11 |
def clean_phrase(phrase):
|
|
|
|
| 36 |
return f"Did you mean: '{row['Phrase in your language']}'? Translation: {row['English translation']}"
|
| 37 |
|
| 38 |
# 3. If nothing is close enough
|
| 39 |
+
return "Translation not found. Try 'Kita kobor?' or 'Kita korde?'."
|
| 40 |
+
|
| 41 |
+
# Create the app interface
|
| 42 |
+
demo = gr.Interface(
|
| 43 |
+
fn=translate_text,
|
| 44 |
+
inputs=gr.Textbox(label="Type phrase in our language"),
|
| 45 |
+
outputs=gr.Textbox(label="Translation"),
|
| 46 |
+
title="Our Language Translator",
|
| 47 |
+
description="This app uses our custom language data."
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
# Launch the app
|
| 51 |
+
demo.launch()
|