Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
def convert_text(text):
|
| 4 |
+
upper_text = text.upper()
|
| 5 |
+
lower_text = text.lower()
|
| 6 |
+
|
| 7 |
+
# Proper sentence case (after every dot)
|
| 8 |
+
sentences = text.split(".")
|
| 9 |
+
sentence_text = ". ".join(
|
| 10 |
+
s.strip().capitalize() for s in sentences if s.strip()
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
return upper_text, lower_text, sentence_text
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
with gr.Blocks(title="Text Case Converter") as demo:
|
| 17 |
+
gr.Markdown(
|
| 18 |
+
"""
|
| 19 |
+
# 🔤 Text Case Converter
|
| 20 |
+
Converts text into **UPPERCASE**, **lowercase**, and **Sentence case**.
|
| 21 |
+
"""
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
input_text = gr.Textbox(label="Enter Text", lines=4)
|
| 25 |
+
convert_btn = gr.Button("Convert")
|
| 26 |
+
|
| 27 |
+
upper_output = gr.Textbox(label="UPPERCASE Output")
|
| 28 |
+
lower_output = gr.Textbox(label="lowercase Output")
|
| 29 |
+
sentence_output = gr.Textbox(label="Sentence case Output")
|
| 30 |
+
|
| 31 |
+
convert_btn.click(
|
| 32 |
+
fn=convert_text,
|
| 33 |
+
inputs=input_text,
|
| 34 |
+
outputs=[upper_output, lower_output, sentence_output]
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
demo.launch()
|