bkhmsi commited on
Commit
e5cfa50
ยท
1 Parent(s): 8cf7cb1

added queue

Browse files
Files changed (2) hide show
  1. PartialDD.png +0 -0
  2. app.py +15 -17
PartialDD.png CHANGED
app.py CHANGED
@@ -56,16 +56,20 @@ def diacritze_partial(text, mask_mode, threshold, model_name):
56
  return diacritized_lines
57
 
58
  with gr.Blocks(theme=gr.themes.Default(text_size="lg")) as demo:
 
59
  gr.Markdown(
60
  """
61
- # Partial Diacritization: A Context-Contrastive Inference Approach
62
- ### Authors: Muhammad ElNokrashy, Badr AlKhamissi
63
- ### Paper Link: TBD (abstract below)
 
 
 
 
 
 
64
  """)
65
 
66
- gr.HTML(
67
- "<img src='./PartialDD.png' style='float:right'/>"
68
- )
69
 
70
  model_choice = gr.Dropdown(
71
  choices=["D2", "TD2"],
@@ -94,13 +98,13 @@ with gr.Blocks(theme=gr.themes.Default(text_size="lg")) as demo:
94
  )
95
 
96
  full_btn = gr.Button(value="Shakkel")
97
- full_btn.click(diacritze_full, inputs=[full_input_txt, model_choice], outputs=[full_output_txt])
98
 
99
  gr.Examples(
100
  examples=[
101
- "ูˆู„ูˆ ุญู…ู„ ู…ู† ู…ุฌู„ุณ ุงู„ุฎูŠุงุฑ ุŒ ูˆู„ู… ูŠู…ู†ุน ู…ู† ุงู„ูƒู„ุงู…", "TD2"
102
  ],
103
- inputs=full_input_txt,
104
  outputs=full_output_txt,
105
  fn=diacritze_full,
106
  cache_examples=True,
@@ -130,7 +134,7 @@ with gr.Blocks(theme=gr.themes.Default(text_size="lg")) as demo:
130
  )
131
 
132
  partial_btn = gr.Button(value="Shakkel")
133
- partial_btn.click(diacritze_partial, inputs=[partial_input_txt, masking_mode, threshold_slider, model_choice], outputs=[partial_output_txt])
134
 
135
  gr.Examples(
136
  examples=[
@@ -138,18 +142,12 @@ with gr.Blocks(theme=gr.themes.Default(text_size="lg")) as demo:
138
  ["ูˆู„ูˆ ุญู…ู„ ู…ู† ู…ุฌู„ุณ ุงู„ุฎูŠุงุฑ ุŒ ูˆู„ู… ูŠู…ู†ุน ู…ู† ุงู„ูƒู„ุงู…", "Soft", 0.1, "TD2"],
139
  ["ูˆู„ูˆ ุญู…ู„ ู…ู† ู…ุฌู„ุณ ุงู„ุฎูŠุงุฑ ุŒ ูˆู„ู… ูŠู…ู†ุน ู…ู† ุงู„ูƒู„ุงู…", "Soft", 0.01, "TD2"],
140
  ],
141
- inputs=[partial_input_txt, masking_mode, threshold_slider],
142
  outputs=partial_output_txt,
143
  fn=diacritze_partial,
144
  cache_examples=True,
145
  )
146
 
147
- gr.Markdown(
148
- """
149
- ### Abstract
150
- > Diacritization plays a pivotal role in improving readability and disambiguating the meaning of Arabic texts. Efforts have so far focused on marking every eligible character (Full Diacritization). Comparatively overlooked, Partial Diacritzation (PD) is the selection of a subset of characters to be marked to aid comprehension where needed.Research has indicated that excessive diacritic marks can hinder skilled readers---reducing reading speed and accuracy. We conduct a behavioral experiment and show that partially marked text is often easier to read than fully marked text, and sometimes easier than plain text. In this light, we introduce Context-Contrastive Partial Diacritization (CCPD)---a novel approach to PD which integrates seamlessly with existing Arabic diacritization systems. CCPD processes each word twice, once with context and once without, and diacritizes only the characters with disparities between the two inferences. Further, we introduce novel indicators for measuring partial diacritization quality {SR, PDER, HDER, ERE}, essential for establishing this as a machine learning task. Lastly, we introduce TD2, a Transformer-variant of an established model which offers a markedly different performance profile on our proposed indicators compared to all other known systems.
151
- """)
152
-
153
  if __name__ == "__main__":
154
  demo.queue().launch(
155
  # share=False,
 
56
  return diacritized_lines
57
 
58
  with gr.Blocks(theme=gr.themes.Default(text_size="lg")) as demo:
59
+
60
  gr.Markdown(
61
  """
62
+ <img src='https://huggingface.co/spaces/bkhmsi/Partial-Arabic-Diacritization/resolve/main/PartialDD.png' style='float:right; margin: 0 0 10px 10px;'/>
63
+
64
+ <h1> Partial Diacritization: A Context-Contrastive Inference Approach </h1>
65
+ <h2> Authors: Muhammad ElNokrashy, Badr AlKhamissi </h2>
66
+ <h3> Paper Link: TBD </h3>
67
+ <details>
68
+ <summary>Abstract</summary>
69
+ <p>Diacritization plays a pivotal role in improving readability and disambiguating the meaning of Arabic texts. Efforts have so far focused on marking every eligible character (Full Diacritization). Comparatively overlooked, Partial Diacritzation (PD) is the selection of a subset of characters to be marked to aid comprehension where needed.Research has indicated that excessive diacritic marks can hinder skilled readers---reducing reading speed and accuracy. We conduct a behavioral experiment and show that partially marked text is often easier to read than fully marked text, and sometimes easier than plain text. In this light, we introduce Context-Contrastive Partial Diacritization (CCPD)---a novel approach to PD which integrates seamlessly with existing Arabic diacritization systems. CCPD processes each word twice, once with context and once without, and diacritizes only the characters with disparities between the two inferences. Further, we introduce novel indicators for measuring partial diacritization quality {SR, PDER, HDER, ERE}, essential for establishing this as a machine learning task. Lastly, we introduce TD2, a Transformer-variant of an established model which offers a markedly different performance profile on our proposed indicators compared to all other known systems.</p>
70
+ </details>
71
  """)
72
 
 
 
 
73
 
74
  model_choice = gr.Dropdown(
75
  choices=["D2", "TD2"],
 
98
  )
99
 
100
  full_btn = gr.Button(value="Shakkel")
101
+ full_btn.click(diacritze_full, inputs=[full_input_txt, model_choice], outputs=[full_output_txt], queue=True)
102
 
103
  gr.Examples(
104
  examples=[
105
+ ["ูˆู„ูˆ ุญู…ู„ ู…ู† ู…ุฌู„ุณ ุงู„ุฎูŠุงุฑ ุŒ ูˆู„ู… ูŠู…ู†ุน ู…ู† ุงู„ูƒู„ุงู…", "TD2"],
106
  ],
107
+ inputs=[full_input_txt, model_choice],
108
  outputs=full_output_txt,
109
  fn=diacritze_full,
110
  cache_examples=True,
 
134
  )
135
 
136
  partial_btn = gr.Button(value="Shakkel")
137
+ partial_btn.click(diacritze_partial, inputs=[partial_input_txt, masking_mode, threshold_slider, model_choice], outputs=[partial_output_txt], queue=True)
138
 
139
  gr.Examples(
140
  examples=[
 
142
  ["ูˆู„ูˆ ุญู…ู„ ู…ู† ู…ุฌู„ุณ ุงู„ุฎูŠุงุฑ ุŒ ูˆู„ู… ูŠู…ู†ุน ู…ู† ุงู„ูƒู„ุงู…", "Soft", 0.1, "TD2"],
143
  ["ูˆู„ูˆ ุญู…ู„ ู…ู† ู…ุฌู„ุณ ุงู„ุฎูŠุงุฑ ุŒ ูˆู„ู… ูŠู…ู†ุน ู…ู† ุงู„ูƒู„ุงู…", "Soft", 0.01, "TD2"],
144
  ],
145
+ inputs=[partial_input_txt, masking_mode, threshold_slider, model_choice],
146
  outputs=partial_output_txt,
147
  fn=diacritze_partial,
148
  cache_examples=True,
149
  )
150
 
 
 
 
 
 
 
151
  if __name__ == "__main__":
152
  demo.queue().launch(
153
  # share=False,