text_check / app.py
Vihang28's picture
Update app.py
f5bda22 verified
raw
history blame
1.14 kB
import gradio as gr
from symspellpy import SymSpell
def ocr_model(inp_text):
symsp = SymSpell()
symsp.load_dictionary('freq_dictionay_symspellpy.txt',term_index=0, count_index=1, separator=' ')
sentence = inp_text
terms = symsp.lookup_compound(sentence,max_edit_distance=2)
return terms[0].term
title = "Text Correction"
#article = "<p style='text-align: center'><a href='https://github.com/PaddlePaddle/PaddleOCR' target='_blank'>Github Repo</a></p>"
with gr.Blocks(title=title) as demo:
gr.Markdown(f'<h1 style="text-align: center; margin-bottom: 1rem;">{title}</h1>')
gr.Markdown(description)
with gr.Row():
with gr.Column():
inp_text = gr.Textbox(placeholder="Enter Text..", label="Input")
with gr.Row():
btn_clear = gr.ClearButton([image])
btn_submit = gr.Button(value="Submit", variant="primary")
with gr.Column():
text = gr.Textbox(label="Output")
btn_submit.click(text_checker, inputs=[inp_text], outputs=text)
btn_clear.add(text)
#gr.Markdown(article)
if __name__ == '__main__':
demo.launch()