from camel_tools.utils.charmap import CharMapper
import os
import gradio as gr

ar2bw = CharMapper.builtin_mapper('ar2bw')
bw2ar = CharMapper.builtin_mapper('bw2ar')
Secret_token = os.getenv('token')

title = """# Transliterate using BuckWater Scheme"""
description = """
This app converts transliterated arabic text to Arabic using BuckWater Scheme. Use the following image to familiarize yourself with the conversion system.
"""
example = [["*hbt <lY Almktbp."]]

def getArabic(transliteration):
  return bw2ar(transliteration)

with gr.Blocks() as demo:
    
    gr.Markdown(title)
    gr.Markdown(description)
    with gr.Row():
        gr.Image('https://huggingface.co/spaces/FDSRashid/Camel_tools_Test/resolve/main/Buckwalter-transliteration-for-Arabic-language.jpg', width = 300, height = 900)
        with gr.Column():
            name = gr.Textbox(label="English Transliteration (Using Buckwater System )")
            output = gr.Textbox(label="Arabic Form of Text")
            greet_btn = gr.Button("Get Arabic")
            examples =  gr.Examples(examples = example, inputs = [name])
    greet_btn.click(fn=getArabic, inputs=name, outputs=output)
    

demo.launch()