File size: 1,140 Bytes
24351d4
 
 
24ba624
 
 
 
 
 
 
f5bda22
 
 
24351d4
 
 
 
 
24ba624
24351d4
 
 
 
 
 
24ba624
24351d4
 
f5bda22
24351d4
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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()