sashdev commited on
Commit
a3f6cfb
·
verified ·
1 Parent(s): 3890693

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ import zipfile
4
+ from zipfile import ZipFile
5
+ import shutil
6
+ from pathlib import Path
7
+
8
+ # Install language_tool_python from local .whl file
9
+ os.system("pip install ./language_tool_python-2.7.1-py3-none-any.whl")
10
+
11
+ import language_tool_python
12
+
13
+ # Initialize the grammar corrector
14
+ corrector = language_tool_python.LanguageTool('en-US')
15
+
16
+ # Define the correction function
17
+ def grammar_correction(text):
18
+ corrected_text = corrector.correct(text)
19
+ return corrected_text
20
+
21
+ # Create Gradio UI
22
+ iface = gr.Interface(fn=grammar_correction,
23
+ inputs="text",
24
+ outputs="text",
25
+ title="Grammar Correction Tool",
26
+ description="Enter text to correct grammatical errors.")
27
+
28
+ if __name__ == "__main__":
29
+ iface.launch()