Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Initialize the spelling correction pipeline with max_new_tokens parameter
|
| 5 |
+
spelling_correction_pipe = pipeline("text2text-generation", model="Elalimy/english_spelling_correction", max_new_tokens=100)
|
| 6 |
+
|
| 7 |
+
# Define the spelling correction function
|
| 8 |
+
def correct_spelling(text):
|
| 9 |
+
# Perform spelling correction
|
| 10 |
+
corrected_text = spelling_correction_pipe(text)[0]['generated_text'].strip()
|
| 11 |
+
return corrected_text
|
| 12 |
+
|
| 13 |
+
# Create the Gradio interface
|
| 14 |
+
iface = gr.Interface(
|
| 15 |
+
fn=correct_spelling,
|
| 16 |
+
inputs="text",
|
| 17 |
+
outputs="text",
|
| 18 |
+
title="Spelling Correction",
|
| 19 |
+
description="Enter a text to get the corrected spelling."
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
# Launch the Gradio app
|
| 23 |
+
if __name__ == "__main__":
|
| 24 |
+
iface.launch()
|