sashdev commited on
Commit
2c49304
·
verified ·
1 Parent(s): ef561cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -22
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 the grammar corrector
13
- corrector = language_tool_python.LanguageTool('en-US')
14
 
15
- # Define the correction function
16
  def grammar_correction(text):
17
- corrected_text = corrector.correct(text)
 
18
  return corrected_text
19
 
20
- # Create Gradio UI
21
- import gradio as gr
22
-
23
- iface = gr.Interface(fn=grammar_correction,
24
- inputs="text",
25
- outputs="text",
26
- title="Grammar Correction Tool",
27
- description="Enter text to correct grammatical errors.")
 
 
28
 
29
  if __name__ == "__main__":
30
- iface.launch()
 
 
 
 
 
 
 
 
 
 
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()