File size: 810 Bytes
a3f6cfb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import os
import zipfile
from zipfile import ZipFile
import shutil
from pathlib import Path

# Install language_tool_python from local .whl file
os.system("pip install ./language_tool_python-2.7.1-py3-none-any.whl")

import language_tool_python

# Initialize the grammar corrector
corrector = language_tool_python.LanguageTool('en-US')

# Define the correction function
def grammar_correction(text):
    corrected_text = corrector.correct(text)
    return corrected_text

# Create Gradio UI
iface = gr.Interface(fn=grammar_correction, 
                     inputs="text", 
                     outputs="text", 
                     title="Grammar Correction Tool",
                     description="Enter text to correct grammatical errors.")

if __name__ == "__main__":
    iface.launch()