HeshamHaroon commited on
Commit
fcbfd45
1 Parent(s): e845c55

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ # Assuming we have a function to load a tokenizer by name (you would need to replace this with actual implementation)
4
+ def load_tokenizer(tokenizer_name):
5
+ if tokenizer_name == "aranizer_sp32k":
6
+ tokenizer = aranizer_sp32k.get_tokenizer()
7
+ # Add conditions for other tokenizers
8
+
9
+ return tokenizer
10
+
11
+ def tokenize_and_encode(text, tokenizer_choice):
12
+ tokenizer = load_tokenizer(tokenizer_choice)
13
+ tokens = tokenizer.tokenize(text)
14
+ encoded_output = tokenizer.encode(text, add_special_tokens=True)
15
+ decoded_text = tokenizer.decode(encoded_output)
16
+ return tokens, encoded_output, decoded_text
17
+
18
+ iface = gr.Interface(
19
+ fn=tokenize_and_encode,
20
+ inputs=[gr.inputs.Textbox(lines=5, label="النص العربي"), gr.inputs.Dropdown(choices=["aranizer_bpe32k", "aranizer_bpe50k", "aranizer_bpe64k", "aranizer_bpe86k", "aranizer_sp32k", "aranizer_sp50k", "aranizer_sp64k", "aranizer_sp86k"], label="اختر المحلل اللفظي")],
21
+ outputs=[gr.outputs.Textbox(label="Tokens"), gr.outputs.Textbox(label="Encoded Output"), gr.outputs.Textbox(label="Decoded Text")],
22
+ title="مقارنة المحللات اللفظية للنص العربي",
23
+ description="حدد نوع المحلل اللفظي وأدخل نصًا لرؤية النتائج.",
24
+ language="ar",
25
+ )
26
+
27
+ iface.launch()