Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -35,35 +35,23 @@ def process_text(text, operations, correct_spacing, remove_diacritics, remove_sp
|
|
| 35 |
|
| 36 |
# Define Gradio interface
|
| 37 |
operations = ['normalize', 'tokenize', 'lemmatize', 'chunk']
|
| 38 |
-
|
| 39 |
-
def toggle_normalization_options(normalize_selected):
|
| 40 |
-
return gr.update(visible=normalize_selected)
|
| 41 |
-
|
| 42 |
iface = gr.Interface(
|
| 43 |
fn=process_text,
|
| 44 |
inputs=[
|
| 45 |
gr.Textbox(lines=10, label="Input Text"),
|
| 46 |
gr.CheckboxGroup(operations, label="Operations"),
|
| 47 |
-
gr.Checkbox(value=True, label="Correct Spacing",
|
| 48 |
-
gr.Checkbox(value=True, label="Remove Diacritics",
|
| 49 |
-
gr.Checkbox(value=True, label="Remove Special Characters",
|
| 50 |
-
gr.Checkbox(value=True, label="Decrease Repeated Characters",
|
| 51 |
-
gr.Checkbox(value=True, label="Persian Style",
|
| 52 |
-
gr.Checkbox(value=True, label="Persian Numbers",
|
| 53 |
-
gr.Checkbox(value=True, label="Unicodes Replacement",
|
| 54 |
-
gr.Checkbox(value=True, label="Separate 'می'",
|
| 55 |
],
|
| 56 |
outputs="json",
|
| 57 |
title="Persian Text Processor with Hazm",
|
| 58 |
-
description="Select operations and normalization parameters to perform on the input text using Hazm."
|
| 59 |
-
live=True
|
| 60 |
-
)
|
| 61 |
-
|
| 62 |
-
# Set the visibility of normalization options dynamically based on the 'normalize' operation checkbox
|
| 63 |
-
iface.inputs[1].change(
|
| 64 |
-
fn=toggle_normalization_options,
|
| 65 |
-
inputs=iface.inputs[1], # Operations checkbox group
|
| 66 |
-
outputs=iface.inputs[2:] # The normalization checkboxes
|
| 67 |
)
|
| 68 |
|
| 69 |
if __name__ == "__main__":
|
|
|
|
| 35 |
|
| 36 |
# Define Gradio interface
|
| 37 |
operations = ['normalize', 'tokenize', 'lemmatize', 'chunk']
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
iface = gr.Interface(
|
| 39 |
fn=process_text,
|
| 40 |
inputs=[
|
| 41 |
gr.Textbox(lines=10, label="Input Text"),
|
| 42 |
gr.CheckboxGroup(operations, label="Operations"),
|
| 43 |
+
gr.Checkbox(value=True, label="Correct Spacing", interactive=True),
|
| 44 |
+
gr.Checkbox(value=True, label="Remove Diacritics", interactive=True),
|
| 45 |
+
gr.Checkbox(value=True, label="Remove Special Characters", interactive=True),
|
| 46 |
+
gr.Checkbox(value=True, label="Decrease Repeated Characters", interactive=True),
|
| 47 |
+
gr.Checkbox(value=True, label="Persian Style", interactive=True),
|
| 48 |
+
gr.Checkbox(value=True, label="Persian Numbers", interactive=True),
|
| 49 |
+
gr.Checkbox(value=True, label="Unicodes Replacement", interactive=True),
|
| 50 |
+
gr.Checkbox(value=True, label="Separate 'می'", interactive=True)
|
| 51 |
],
|
| 52 |
outputs="json",
|
| 53 |
title="Persian Text Processor with Hazm",
|
| 54 |
+
description="Select operations and normalization parameters to perform on the input text using Hazm."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
)
|
| 56 |
|
| 57 |
if __name__ == "__main__":
|