musfiqdehan commited on
Commit
c4a0750
1 Parent(s): 75aab4f

Add get_better_translation function and update UI text

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -3,7 +3,7 @@ from gradio_rich_textbox import RichTextbox
3
 
4
  from helper.text_preprocess import space_punc
5
  from helper.alignment_mappers import select_model, get_alignments_table
6
- from helper.translators import select_target_lang_code, google_translation
7
 
8
 
9
  def process_alignments(src, language_name, model_name):
@@ -12,13 +12,18 @@ def process_alignments(src, language_name, model_name):
12
  """
13
 
14
  tgt = None
 
15
  html_table = None
16
 
17
  src = space_punc(src)
18
 
19
  tgt = select_target_lang_code(language_name)
20
 
21
- tgt = google_translation(src, tgt)
 
 
 
 
22
 
23
  model_name = select_model(model_name)
24
 
@@ -28,12 +33,12 @@ def process_alignments(src, language_name, model_name):
28
  model_name=model_name
29
  )
30
 
31
- return tgt, html_table, alignment_accuracy
32
 
33
 
34
  with gr.Blocks(css="styles.css") as demo:
35
- gr.HTML("<h1>Bangla PoS Taggers</h1>")
36
- gr.HTML("<p>Parts of Speech (PoS) Tagging of Bangla Sentence using Bangla-English <strong>Word Alignment</strong></p>")
37
 
38
  with gr.Row():
39
  with gr.Column():
@@ -164,7 +169,7 @@ with gr.Blocks(css="styles.css") as demo:
164
  outputs = [
165
  gr.Textbox(label="English Translation"),
166
  RichTextbox(label="Alignments Mapping (Source to Target)"),
167
- gr.Textbox(label="Alignment Accuracy (Based on Unknown(UNK) Tags)")
168
  ]
169
 
170
  btn.click(process_alignments, inputs, outputs)
 
3
 
4
  from helper.text_preprocess import space_punc
5
  from helper.alignment_mappers import select_model, get_alignments_table
6
+ from helper.translators import select_target_lang_code, google_translation, get_better_translation
7
 
8
 
9
  def process_alignments(src, language_name, model_name):
 
12
  """
13
 
14
  tgt = None
15
+ tgt_base = None
16
  html_table = None
17
 
18
  src = space_punc(src)
19
 
20
  tgt = select_target_lang_code(language_name)
21
 
22
+ tgt = get_better_translation(src)
23
+
24
+ tgt = space_punc(tgt)
25
+
26
+ tgt_base = google_translation(src, tgt)
27
 
28
  model_name = select_model(model_name)
29
 
 
33
  model_name=model_name
34
  )
35
 
36
+ return tgt_base, html_table, alignment_accuracy
37
 
38
 
39
  with gr.Blocks(css="styles.css") as demo:
40
+ gr.HTML("<h1>Multilingual Sentence Alignments</h1>")
41
+ gr.HTML("<p>Align Parallel Sentences using mBERT</p>")
42
 
43
  with gr.Row():
44
  with gr.Column():
 
169
  outputs = [
170
  gr.Textbox(label="English Translation"),
171
  RichTextbox(label="Alignments Mapping (Source to Target)"),
172
+ gr.Textbox(label="Alignment Accuracy")
173
  ]
174
 
175
  btn.click(process_alignments, inputs, outputs)