Spaces:
Sleeping
Sleeping
AlirezaF138
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -45,7 +45,7 @@ def process_text(text, operation, correct_spacing, remove_diacritics, remove_spe
|
|
45 |
def toggle_normalization_options(operation):
|
46 |
# Show normalization options only if 'normalize' is selected
|
47 |
is_normalize = (operation == "normalize")
|
48 |
-
return [gr.update(visible=is_normalize)] *
|
49 |
|
50 |
# Define Gradio interface
|
51 |
with gr.Blocks() as demo:
|
@@ -53,25 +53,26 @@ with gr.Blocks() as demo:
|
|
53 |
gr.Markdown("Select an operation and, if applicable, adjust normalization parameters to process the input text using Hazm.")
|
54 |
|
55 |
with gr.Row():
|
56 |
-
input_text = gr.Textbox(lines=10, label="Input Text")
|
57 |
|
58 |
with gr.Row():
|
59 |
operation = gr.Radio(
|
60 |
choices=['normalize', 'tokenize', 'lemmatize', 'chunk', 'pos_tag'],
|
61 |
label="Select Operation",
|
62 |
-
value='normalize'
|
|
|
63 |
)
|
64 |
|
65 |
with gr.Column(visible=True) as normalization_options:
|
66 |
-
correct_spacing = gr.Checkbox(value=True, label="Correct Spacing")
|
67 |
-
remove_diacritics = gr.Checkbox(value=True, label="Remove Diacritics")
|
68 |
-
remove_specials_chars = gr.Checkbox(value=True, label="Remove Special Characters")
|
69 |
-
decrease_repeated_chars = gr.Checkbox(value=True, label="Decrease Repeated Characters")
|
70 |
-
persian_style = gr.Checkbox(value=True, label="Persian Style")
|
71 |
-
persian_numbers = gr.Checkbox(value=True, label="Persian Numbers")
|
72 |
-
unicodes_replacement = gr.Checkbox(value=True, label="Unicodes Replacement")
|
73 |
-
seperate_mi = gr.Checkbox(value=True, label="Separate 'می'")
|
74 |
-
|
75 |
operation.change(
|
76 |
fn=toggle_normalization_options,
|
77 |
inputs=operation,
|
|
|
45 |
def toggle_normalization_options(operation):
|
46 |
# Show normalization options only if 'normalize' is selected
|
47 |
is_normalize = (operation == "normalize")
|
48 |
+
return [gr.update(visible=is_normalize)] * 8 # Update visibility for all 8 checkboxes
|
49 |
|
50 |
# Define Gradio interface
|
51 |
with gr.Blocks() as demo:
|
|
|
53 |
gr.Markdown("Select an operation and, if applicable, adjust normalization parameters to process the input text using Hazm.")
|
54 |
|
55 |
with gr.Row():
|
56 |
+
input_text = gr.Textbox(lines=10, label="Input Text", placeholder="Enter Persian text here...")
|
57 |
|
58 |
with gr.Row():
|
59 |
operation = gr.Radio(
|
60 |
choices=['normalize', 'tokenize', 'lemmatize', 'chunk', 'pos_tag'],
|
61 |
label="Select Operation",
|
62 |
+
value='normalize',
|
63 |
+
info="Choose the type of text processing operation to perform."
|
64 |
)
|
65 |
|
66 |
with gr.Column(visible=True) as normalization_options:
|
67 |
+
correct_spacing = gr.Checkbox(value=True, label="Correct Spacing", info="Adjusts spaces between words for proper formatting.")
|
68 |
+
remove_diacritics = gr.Checkbox(value=True, label="Remove Diacritics", info="Eliminates diacritical marks from the text.")
|
69 |
+
remove_specials_chars = gr.Checkbox(value=True, label="Remove Special Characters", info="Removes non-alphanumeric characters.")
|
70 |
+
decrease_repeated_chars = gr.Checkbox(value=True, label="Decrease Repeated Characters", info="Reduces sequences of repeated characters to a single character.")
|
71 |
+
persian_style = gr.Checkbox(value=True, label="Persian Style", info="Applies standard Persian typography rules.")
|
72 |
+
persian_numbers = gr.Checkbox(value=True, label="Persian Numbers", info="Converts Arabic numbers to Persian numbers.")
|
73 |
+
unicodes_replacement = gr.Checkbox(value=True, label="Unicodes Replacement", info="Replaces characters with their standard Unicode equivalents.")
|
74 |
+
seperate_mi = gr.Checkbox(value=True, label="Separate 'می'", info="Separates the Persian prefix 'می' from verbs.")
|
75 |
+
|
76 |
operation.change(
|
77 |
fn=toggle_normalization_options,
|
78 |
inputs=operation,
|