Spaces:
Sleeping
Sleeping
| # -*- coding: utf-8 -*- | |
| """app.ipynb | |
| Automatically generated by Colab. | |
| Original file is located at | |
| https://colab.research.google.com/drive/1lKXL4Cdum5DiSbczUsadXc0F8j46NM_m | |
| # in the name of **allah** | |
| """ | |
| import gradio as gr | |
| from model import process_sentence, process_file # ایمپورت توابع پردازش از model.py | |
| # تابع اصلی که ورودی متن و فایل را پردازش میکند | |
| def analyze_text_and_file(input_text, file): | |
| output_text = "" | |
| if input_text: | |
| output_text = process_sentence(input_text) # پردازش متن | |
| file_output = None | |
| if file: | |
| file_output = process_file(file) # پردازش فایل | |
| return output_text, file_output | |
| # رابط کاربری Gradio | |
| interface = gr.Interface( | |
| fn=analyze_text_and_file, | |
| inputs=[ | |
| gr.Textbox(lines=3, placeholder="Enter Persian text to process...", label="Text Input"), | |
| gr.File(label="Upload CSV File"), | |
| ], | |
| outputs=[ | |
| gr.Textbox(label="Processed Text"), | |
| gr.File(label="File Processing Result"), | |
| ], | |
| title="Persian Text Processor", | |
| description="Process Persian text or upload a CSV file with a 'Comment' column.", | |
| css=""" | |
| .gradio-container { | |
| background-color: #000000; | |
| color: #FFFFFF; | |
| } | |
| .gr-button { | |
| background-color: #FF5733; | |
| color: white; | |
| } | |
| .gr-textbox input { | |
| background-color: #333333; | |
| color: white; | |
| } | |
| .gr-button:hover { | |
| background-color: #FF4500; | |
| } | |
| """ | |
| ) | |
| interface.launch(share=True, debug=True, inline=False) |