Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,11 +11,19 @@ import random
|
|
11 |
import string
|
12 |
|
13 |
# Ensure necessary NLTK data is downloaded
|
14 |
-
|
15 |
-
|
16 |
-
nltk.download('
|
17 |
-
nltk.download('
|
18 |
-
nltk.download('
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
top_words = set(stopwords.words("english")) # More efficient as a set
|
21 |
|
@@ -207,27 +215,25 @@ def correct_spelling(text):
|
|
207 |
# Main function for paraphrasing and grammar correction
|
208 |
def paraphrase_and_correct(text):
|
209 |
cleaned_text = remove_redundant_words(text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
plag_removed = plagiarism_removal(cleaned_text)
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
paraphrased_text = correct_tense_errors(paraphrased_text)
|
215 |
-
paraphrased_text = ensure_subject_verb_agreement(paraphrased_text)
|
216 |
-
paraphrased_text = fix_possessives(paraphrased_text)
|
217 |
-
paraphrased_text = correct_spelling(paraphrased_text)
|
218 |
-
paraphrased_text = fix_punctuation_spacing(paraphrased_text)
|
219 |
-
|
220 |
-
return paraphrased_text
|
221 |
-
|
222 |
-
# Gradio app setup
|
223 |
with gr.Blocks() as demo:
|
|
|
224 |
with gr.Tab("AI Detection"):
|
225 |
-
t1 = gr.Textbox(lines=5, label='Text')
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
button1.click(fn=predict_en, inputs=t1, outputs=[label1, score1])
|
231 |
|
232 |
with gr.Tab("Paraphrasing and Grammar Correction"):
|
233 |
t2 = gr.Textbox(lines=5, label='Input Text')
|
|
|
11 |
import string
|
12 |
|
13 |
# Ensure necessary NLTK data is downloaded
|
14 |
+
def download_nltk_resources():
|
15 |
+
try:
|
16 |
+
nltk.download('punkt')
|
17 |
+
nltk.download('stopwords')
|
18 |
+
nltk.download('averaged_perceptron_tagger')
|
19 |
+
nltk.download('wordnet')
|
20 |
+
nltk.download('omw-1.4')
|
21 |
+
nltk.download('punkt_tab') # Added punkt_tab download
|
22 |
+
except Exception as e:
|
23 |
+
print(f"Error downloading NLTK resources: {e}")
|
24 |
+
|
25 |
+
# Call the download function
|
26 |
+
download_nltk_resources()
|
27 |
|
28 |
top_words = set(stopwords.words("english")) # More efficient as a set
|
29 |
|
|
|
215 |
# Main function for paraphrasing and grammar correction
|
216 |
def paraphrase_and_correct(text):
|
217 |
cleaned_text = remove_redundant_words(text)
|
218 |
+
cleaned_text = fix_punctuation_spacing(cleaned_text)
|
219 |
+
cleaned_text = fix_possessives(cleaned_text)
|
220 |
+
cleaned_text = capitalize_sentences_and_nouns(cleaned_text)
|
221 |
+
cleaned_text = force_first_letter_capital(cleaned_text)
|
222 |
+
cleaned_text = correct_tense_errors(cleaned_text)
|
223 |
+
cleaned_text = correct_article_errors(cleaned_text)
|
224 |
+
cleaned_text = ensure_subject_verb_agreement(cleaned_text)
|
225 |
+
cleaned_text = correct_spelling(cleaned_text)
|
226 |
plag_removed = plagiarism_removal(cleaned_text)
|
227 |
+
return plag_removed
|
228 |
+
|
229 |
+
# Create the Gradio interface
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
with gr.Blocks() as demo:
|
231 |
+
gr.Markdown("# AI Text Processor")
|
232 |
with gr.Tab("AI Detection"):
|
233 |
+
t1 = gr.Textbox(lines=5, label='Input Text')
|
234 |
+
output1 = gr.Label()
|
235 |
+
button1 = gr.Button("🚀 Process!")
|
236 |
+
button1.click(fn=predict_en, inputs=t1, outputs=output1)
|
|
|
|
|
237 |
|
238 |
with gr.Tab("Paraphrasing and Grammar Correction"):
|
239 |
t2 = gr.Textbox(lines=5, label='Input Text')
|