Spaces:
Sleeping
Sleeping
File size: 1,003 Bytes
46627d5 84669bc d90e4dc 46627d5 116d721 |
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 |
import subprocess
import spacy
import gradio as gr
from gramformer import Gramformer
# Check if the 'en_core_web_sm' model is installed, if not, install it
try:
spacy.load("en_core_web_sm")
except OSError:
subprocess.run(["python", "-m", "spacy", "download", "en_core_web_sm"])
# Initialize the Gramformer model (using default settings for now)
gf = Gramformer(models=1, use_gpu=False)
def correct_grammar(text):
# Correct the input text using Gramformer
corrected_sentences = gf.correct(text)
return " ".join(corrected_sentences)
# Gradio Interface
def main():
interface = gr.Interface(
fn=correct_grammar,
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
outputs="text",
title="Grammar Correction App",
description="This app corrects grammar using the Gramformer model. Enter a sentence to correct its grammar.",
)
# Launch the Gradio interface
interface.launch()
if __name__ == "__main__":
main()
|