import gradio as gr from symspellpy import SymSpell import autocorrect from autocorrect import Speller # def text_checker(inp_text): # updated_text = text_checker_pre(inp_text) # symsp = SymSpell() # symsp.load_dictionary('dictionay.txt',term_index=0, count_index=1, separator=' ') # sentence = updated_text # terms = symsp.lookup_compound(sentence,max_edit_distance=2) # return terms[0].term def text_checker(inp_text): check = Speller(lang='en') sentence = inp_text return check(sentence) title = "Misspell Correction" with gr.Blocks(title=title) as demo: gr.Markdown(f'

{title}

') with gr.Row(): with gr.Column(): inp_text = gr.Textbox(placeholder="Enter Text..", label="Input", lines=4) with gr.Row(): btn_clear = gr.ClearButton([inp_text]) btn_submit = gr.Button(value="Submit", variant="primary") with gr.Column(): text = gr.Textbox(label="Output", lines=4) btn_submit.click(text_checker, inputs=[inp_text], outputs=text) btn_clear.add(text) #gr.Markdown(article) if __name__ == '__main__': demo.launch()