LTP / app.py
sashdev's picture
Update app.py
3b03846 verified
raw
history blame
824 Bytes
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()