File size: 824 Bytes
a3f6cfb
 
3b03846
 
 
 
 
a3f6cfb
 
 
 
 
 
 
 
 
 
 
 
 
3b03846
 
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
31
import os

# Install Java
os.system("apt-get update")
os.system("apt-get install -y openjdk-11-jdk")

# Install language_tool_python from the 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
import gradio as gr

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()