Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -61,7 +61,6 @@ def correct_tense_errors(text):
|
|
61 |
|
62 |
for token in doc:
|
63 |
if token.pos_ == "VERB":
|
64 |
-
# Check if verb is in its base form
|
65 |
if token.tag_ == "VB" and token.text.lower() not in ["be", "have", "do"]:
|
66 |
# Attempt to correct verb form based on sentence context
|
67 |
context = " ".join([t.text for t in doc if t.i != token.i])
|
@@ -114,12 +113,10 @@ def correct_article_errors(text):
|
|
114 |
for token in doc:
|
115 |
if token.text in ['a', 'an']:
|
116 |
next_token = token.nbor(1)
|
117 |
-
if
|
118 |
-
corrected_text.append("an")
|
119 |
-
elif token.text == "an" and next_token.text[0].lower() not in "aeiou":
|
120 |
-
corrected_text.append("a")
|
121 |
else:
|
122 |
-
corrected_text.append(token.text)
|
123 |
else:
|
124 |
corrected_text.append(token.text)
|
125 |
return ' '.join(corrected_text)
|
@@ -128,7 +125,7 @@ def correct_article_errors(text):
|
|
128 |
def paraphrase_with_spacy_nltk(text):
|
129 |
doc = nlp(text)
|
130 |
paraphrased_words = []
|
131 |
-
|
132 |
for token in doc:
|
133 |
# Map SpaCy POS tags to WordNet POS tags
|
134 |
pos = None
|
@@ -140,7 +137,7 @@ def paraphrase_with_spacy_nltk(text):
|
|
140 |
pos = wordnet.ADJ
|
141 |
elif token.pos_ == "ADV":
|
142 |
pos = wordnet.ADV
|
143 |
-
|
144 |
synonyms = get_synonyms_nltk(token.text.lower(), pos) if pos else []
|
145 |
|
146 |
# Replace with a synonym only if it makes sense
|
|
|
61 |
|
62 |
for token in doc:
|
63 |
if token.pos_ == "VERB":
|
|
|
64 |
if token.tag_ == "VB" and token.text.lower() not in ["be", "have", "do"]:
|
65 |
# Attempt to correct verb form based on sentence context
|
66 |
context = " ".join([t.text for t in doc if t.i != token.i])
|
|
|
113 |
for token in doc:
|
114 |
if token.text in ['a', 'an']:
|
115 |
next_token = token.nbor(1)
|
116 |
+
if next_token.text[0].lower() in "aeiou":
|
117 |
+
corrected_text.append("an" if token.text == "a" else token.text)
|
|
|
|
|
118 |
else:
|
119 |
+
corrected_text.append("a" if token.text == "an" else token.text)
|
120 |
else:
|
121 |
corrected_text.append(token.text)
|
122 |
return ' '.join(corrected_text)
|
|
|
125 |
def paraphrase_with_spacy_nltk(text):
|
126 |
doc = nlp(text)
|
127 |
paraphrased_words = []
|
128 |
+
|
129 |
for token in doc:
|
130 |
# Map SpaCy POS tags to WordNet POS tags
|
131 |
pos = None
|
|
|
137 |
pos = wordnet.ADJ
|
138 |
elif token.pos_ == "ADV":
|
139 |
pos = wordnet.ADV
|
140 |
+
|
141 |
synonyms = get_synonyms_nltk(token.text.lower(), pos) if pos else []
|
142 |
|
143 |
# Replace with a synonym only if it makes sense
|