Update app.py
Browse files
app.py
CHANGED
@@ -24,7 +24,7 @@ nltk.download('punkt_tab')
|
|
24 |
# Initialize stopwords
|
25 |
stop_words = set(stopwords.words("english"))
|
26 |
|
27 |
-
#
|
28 |
exclude_tags = {'PRP', 'PRP$', 'MD', 'VBZ', 'VBP', 'VBD', 'VBG', 'VBN', 'TO', 'IN', 'DT', 'CC'}
|
29 |
exclude_words = {'is', 'am', 'are', 'was', 'were', 'have', 'has', 'do', 'does', 'did', 'will', 'shall', 'should', 'would', 'could', 'can', 'may', 'might'}
|
30 |
|
@@ -34,7 +34,7 @@ pipeline_en = pipeline(task="text-classification", model="Hello-SimpleAI/chatgpt
|
|
34 |
# Initialize the spell checker
|
35 |
spell = SpellChecker()
|
36 |
|
37 |
-
#
|
38 |
try:
|
39 |
nlp = spacy.load("en_core_web_sm")
|
40 |
except OSError:
|
@@ -213,19 +213,18 @@ def paraphrase_and_correct(text):
|
|
213 |
|
214 |
# Gradio app setup
|
215 |
with gr.Blocks() as demo:
|
216 |
-
with gr.Tab("
|
217 |
-
|
218 |
-
|
219 |
-
|
|
|
220 |
|
221 |
-
|
222 |
|
223 |
-
with gr.Tab("
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
|
228 |
-
|
229 |
|
230 |
-
# Launch the Gradio app
|
231 |
-
demo.launch()
|
|
|
24 |
# Initialize stopwords
|
25 |
stop_words = set(stopwords.words("english"))
|
26 |
|
27 |
+
# Words we don't want to replace
|
28 |
exclude_tags = {'PRP', 'PRP$', 'MD', 'VBZ', 'VBP', 'VBD', 'VBG', 'VBN', 'TO', 'IN', 'DT', 'CC'}
|
29 |
exclude_words = {'is', 'am', 'are', 'was', 'were', 'have', 'has', 'do', 'does', 'did', 'will', 'shall', 'should', 'would', 'could', 'can', 'may', 'might'}
|
30 |
|
|
|
34 |
# Initialize the spell checker
|
35 |
spell = SpellChecker()
|
36 |
|
37 |
+
# Ensure the SpaCy model is installed
|
38 |
try:
|
39 |
nlp = spacy.load("en_core_web_sm")
|
40 |
except OSError:
|
|
|
213 |
|
214 |
# Gradio app setup
|
215 |
with gr.Blocks() as demo:
|
216 |
+
with gr.Tab("AI Detection"):
|
217 |
+
t1 = gr.Textbox(lines=5, label='Text')
|
218 |
+
button1 = gr.Button("π€ Predict!")
|
219 |
+
label1 = gr.Textbox(lines=1, label='Predicted Label π')
|
220 |
+
score1 = gr.Textbox(lines=1, label='Prob')
|
221 |
|
222 |
+
button1.click(fn=predict_en, inputs=t1, outputs=[label1, score1])
|
223 |
|
224 |
+
with gr.Tab("Paraphrasing & Grammar Correction"):
|
225 |
+
t2 = gr.Textbox(lines=5, label='Enter text for paraphrasing and grammar correction')
|
226 |
+
button2 = gr.Button("π Paraphrase and Correct")
|
227 |
+
result2 = gr.Textbox(lines=5, label='Corrected Text')
|
228 |
|
229 |
+
button2.click(fn=paraphrase_and_correct, inputs=t2, outputs=result2)
|
230 |
|
|
|
|