Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,25 @@
|
|
1 |
-
import os
|
2 |
-
|
3 |
-
# Install Java
|
4 |
-
os.system("apt-get update")
|
5 |
-
os.system("apt-get install -y openjdk-11-jdk")
|
6 |
-
|
7 |
-
# Install language_tool_python from the local .whl file
|
8 |
-
os.system("pip install ./language_tool_python-2.7.1-py3-none-any.whl")
|
9 |
-
|
10 |
import language_tool_python
|
|
|
11 |
|
12 |
-
# Initialize
|
13 |
-
|
14 |
|
15 |
-
#
|
16 |
def grammar_correction(text):
|
17 |
-
|
|
|
18 |
return corrected_text
|
19 |
|
20 |
-
#
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
28 |
|
29 |
if __name__ == "__main__":
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import language_tool_python
|
2 |
+
import gradio as gr
|
3 |
|
4 |
+
# Initialize LanguageTool for English
|
5 |
+
tool = language_tool_python.LanguageTool('en-US')
|
6 |
|
7 |
+
# Function to correct grammar
|
8 |
def grammar_correction(text):
|
9 |
+
matches = tool.check(text)
|
10 |
+
corrected_text = language_tool_python.utils.correct(text, matches)
|
11 |
return corrected_text
|
12 |
|
13 |
+
# Gradio interface for testing the grammar correction
|
14 |
+
def main():
|
15 |
+
iface = gr.Interface(
|
16 |
+
fn=grammar_correction,
|
17 |
+
inputs="text",
|
18 |
+
outputs="text",
|
19 |
+
title="Grammar Correction Tool",
|
20 |
+
description="Enter text to correct grammar and spelling errors."
|
21 |
+
)
|
22 |
+
iface.launch()
|
23 |
|
24 |
if __name__ == "__main__":
|
25 |
+
main()
|