Spaces:
Running
Running
musfiqdehan
commited on
Commit
•
065c1c6
1
Parent(s):
bbf1661
Add model selection dropdown for alignment mappers
Browse files
app.py
CHANGED
@@ -2,11 +2,12 @@ import gradio as gr
|
|
2 |
from gradio_rich_textbox import RichTextbox
|
3 |
|
4 |
from helper.text_preprocess import space_punc
|
|
|
5 |
from helper.pos_taggers import select_pos_tagger
|
6 |
from helper.translators import select_translator
|
7 |
|
8 |
|
9 |
-
def bn_postagger(src, translator, tagger):
|
10 |
"""
|
11 |
Bangla PoS Tagger
|
12 |
"""
|
@@ -15,7 +16,9 @@ def bn_postagger(src, translator, tagger):
|
|
15 |
|
16 |
tgt_base, tgt = select_translator(src, translator)
|
17 |
|
18 |
-
|
|
|
|
|
19 |
|
20 |
return tgt_base, result, pos_accuracy
|
21 |
|
@@ -61,6 +64,10 @@ with gr.Blocks(css="styles.css") as demo:
|
|
61 |
choices=["Google", "BanglaNMT", "MyMemory"],
|
62 |
label="Select a Translator"
|
63 |
),
|
|
|
|
|
|
|
|
|
64 |
gr.Dropdown(
|
65 |
choices=["spaCy", "NLTK", "Flair", "TextBlob"],
|
66 |
label="Select a PoS Tagger"
|
@@ -74,19 +81,54 @@ with gr.Blocks(css="styles.css") as demo:
|
|
74 |
outputs = [
|
75 |
gr.Textbox(label="English Translation"),
|
76 |
RichTextbox(label="PoS Tags"),
|
77 |
-
gr.Textbox(label="
|
78 |
]
|
79 |
|
80 |
btn.click(bn_postagger, inputs, outputs)
|
81 |
|
82 |
gr.Examples([
|
83 |
-
[
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
|
91 |
], inputs)
|
92 |
|
|
|
2 |
from gradio_rich_textbox import RichTextbox
|
3 |
|
4 |
from helper.text_preprocess import space_punc
|
5 |
+
from helper.alignment_mappers import select_model
|
6 |
from helper.pos_taggers import select_pos_tagger
|
7 |
from helper.translators import select_translator
|
8 |
|
9 |
|
10 |
+
def bn_postagger(src, translator, model_name, tagger):
|
11 |
"""
|
12 |
Bangla PoS Tagger
|
13 |
"""
|
|
|
16 |
|
17 |
tgt_base, tgt = select_translator(src, translator)
|
18 |
|
19 |
+
model_name = select_model(model_name)
|
20 |
+
|
21 |
+
result, pos_accuracy = select_pos_tagger(src, tgt, model_name, tagger)
|
22 |
|
23 |
return tgt_base, result, pos_accuracy
|
24 |
|
|
|
64 |
choices=["Google", "BanglaNMT", "MyMemory"],
|
65 |
label="Select a Translator"
|
66 |
),
|
67 |
+
gr.Dropdown(
|
68 |
+
choices=["Google-mBERT (Base-Multilingual)", "Neulab-AwesomeAlign (Bn-En-0.5M)"],
|
69 |
+
label="Select a Model"
|
70 |
+
),
|
71 |
gr.Dropdown(
|
72 |
choices=["spaCy", "NLTK", "Flair", "TextBlob"],
|
73 |
label="Select a PoS Tagger"
|
|
|
81 |
outputs = [
|
82 |
gr.Textbox(label="English Translation"),
|
83 |
RichTextbox(label="PoS Tags"),
|
84 |
+
gr.Textbox(label="PoS Tagging Accuracy (Based on Unknown(UNK) Tags)")
|
85 |
]
|
86 |
|
87 |
btn.click(bn_postagger, inputs, outputs)
|
88 |
|
89 |
gr.Examples([
|
90 |
+
[
|
91 |
+
"বাংলাদেশ দক্ষিণ এশিয়ার একটি সার্বভৌম রাষ্ট্র।",
|
92 |
+
"Google",
|
93 |
+
"Neulab-AwesomeAlign (Bn-En-0.5M)",
|
94 |
+
"NLTK"
|
95 |
+
],
|
96 |
+
[
|
97 |
+
"বাংলাদেশের সংবিধানিক নাম কি?",
|
98 |
+
"Google",
|
99 |
+
"Google-mBERT (Base-Multilingual)",
|
100 |
+
"spaCy"
|
101 |
+
],
|
102 |
+
[
|
103 |
+
"বাংলাদেশের সাংবিধানিক নাম গণপ্রজাতন্ত্রী বাংলাদেশ।",
|
104 |
+
"Google",
|
105 |
+
"Google-mBERT (Base-Multilingual)",
|
106 |
+
"TextBlob"
|
107 |
+
],
|
108 |
+
[
|
109 |
+
"তিনজনের কেউই বাবার পথ ধরে প্রযুক্তি দুনিয়ায় হাঁটেননি।",
|
110 |
+
"Google",
|
111 |
+
"Neulab-AwesomeAlign (Bn-En-0.5M)",
|
112 |
+
"spaCy"
|
113 |
+
],
|
114 |
+
[
|
115 |
+
"তিনজনের কেউই বাবার পথ ধরে প্রযুক্তি দুনিয়ায় হাঁটেননি।",
|
116 |
+
"BanglaNMT",
|
117 |
+
"Google-mBERT (Base-Multilingual)",
|
118 |
+
"spaCy"
|
119 |
+
],
|
120 |
+
[
|
121 |
+
"তিনজনের কেউই বাবার পথ ধরে প্রযুক্তি দুনিয়ায় হাঁটেননি।",
|
122 |
+
"MyMemory",
|
123 |
+
"Google-mBERT (Base-Multilingual)",
|
124 |
+
"spaCy"
|
125 |
+
],
|
126 |
+
[
|
127 |
+
"বিশ্বের আরও একটি সেরা ক্লাব।",
|
128 |
+
"Google",
|
129 |
+
"Neulab-AwesomeAlign (Bn-En-0.5M)",
|
130 |
+
"Flair"
|
131 |
+
]
|
132 |
|
133 |
], inputs)
|
134 |
|