Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,15 +6,7 @@ import subprocess
|
|
6 |
import nltk
|
7 |
from nltk.corpus import wordnet
|
8 |
from gensim import downloader as api
|
9 |
-
import
|
10 |
-
|
11 |
-
# Function to install Java
|
12 |
-
def install_java():
|
13 |
-
subprocess.run(["apt-get", "update"])
|
14 |
-
subprocess.run(["apt-get", "install", "-y", "openjdk-11-jre-headless"]) # Install headless version of Java
|
15 |
-
|
16 |
-
# Ensure Java is installed
|
17 |
-
install_java()
|
18 |
|
19 |
# Ensure necessary NLTK data is downloaded
|
20 |
nltk.download('wordnet')
|
@@ -84,11 +76,10 @@ def paraphrase_with_spacy_nltk(text):
|
|
84 |
|
85 |
return paraphrased_sentence
|
86 |
|
87 |
-
# Grammar correction function using
|
88 |
def correct_grammar(text):
|
89 |
-
|
90 |
-
|
91 |
-
corrected_text = language_tool_python.utils.correct(text, matches)
|
92 |
return corrected_text
|
93 |
|
94 |
# Combined function: Paraphrase -> Grammar Check
|
|
|
6 |
import nltk
|
7 |
from nltk.corpus import wordnet
|
8 |
from gensim import downloader as api
|
9 |
+
from textblob import TextBlob # Import TextBlob for simple grammar correction
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
# Ensure necessary NLTK data is downloaded
|
12 |
nltk.download('wordnet')
|
|
|
76 |
|
77 |
return paraphrased_sentence
|
78 |
|
79 |
+
# Grammar correction function using TextBlob
|
80 |
def correct_grammar(text):
|
81 |
+
blob = TextBlob(text)
|
82 |
+
corrected_text = str(blob.correct())
|
|
|
83 |
return corrected_text
|
84 |
|
85 |
# Combined function: Paraphrase -> Grammar Check
|