Spaces:
Sleeping
Sleeping
File size: 1,218 Bytes
24351d4 900725b 14e9155 6b55655 14e9155 3a08ae3 24ba624 14e9155 f5bda22 24351d4 df60226 24351d4 180eda7 24351d4 df60226 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 33 34 35 36 37 38 |
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'<h1 style="text-align: center; margin-bottom: 1rem;">{title}</h1>')
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() |