Spaces:
Runtime error
Runtime error
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() | |