AlirezaF138 commited on
Commit
ea34410
·
verified ·
1 Parent(s): c8b3835

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -21
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", visible=False, interactive=True),
48
- gr.Checkbox(value=True, label="Remove Diacritics", visible=False, interactive=True),
49
- gr.Checkbox(value=True, label="Remove Special Characters", visible=False, interactive=True),
50
- gr.Checkbox(value=True, label="Decrease Repeated Characters", visible=False, interactive=True),
51
- gr.Checkbox(value=True, label="Persian Style", visible=False, interactive=True),
52
- gr.Checkbox(value=True, label="Persian Numbers", visible=False, interactive=True),
53
- gr.Checkbox(value=True, label="Unicodes Replacement", visible=False, interactive=True),
54
- gr.Checkbox(value=True, label="Separate 'می'", visible=False, interactive=True)
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__":