grammarcheck / app.py
jinggujiwoo7's picture
Update app.py
c9120bc verified
raw
history blame contribute delete
715 Bytes
import gradio as gr
from transformers import pipeline
# ๋ฌธ๋ฒ• ์ฒดํฌ๋ฅผ ์œ„ํ•œ 'fill-mask' ํŒŒ์ดํ”„๋ผ์ธ ๋กœ๋“œ
grammar_checker = pipeline('fill-mask', model='bert-base-uncased')
def check_grammar(sentence):
# ์ž…๋ ฅ ๋ฌธ์žฅ์—์„œ ๋ฌธ๋ฒ• ์ฒดํฌ
result = grammar_checker(sentence)
# ๋ฐ˜ํ™˜๋œ ๊ฒฐ๊ณผ ์ค‘ ๊ฐ€์žฅ ๊ฐ€๋Šฅ์„ฑ์ด ๋†’์€ ๋‹จ์–ด ์„ ํƒ
suggested_word = result[0]["token_str"]
return suggested_word
# Gradio ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ •์˜
gr.Interface(check_grammar,
inputs=gr.inputs.Textbox(lines=7, label="Enter a sentence to check grammar"),
outputs=gr.outputs.Textbox(label="Corrected sentence"),
title="Grammar Checker").launch()