sashdev commited on
Commit
fd87ad7
Β·
verified Β·
1 Parent(s): 80ea21a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -15
app.py CHANGED
@@ -16,15 +16,13 @@ import random
16
  nltk.download('punkt')
17
  nltk.download('stopwords')
18
  nltk.download('averaged_perceptron_tagger')
19
- nltk.download('averaged_perceptron_tagger_eng')
20
  nltk.download('wordnet')
21
  nltk.download('omw-1.4')
22
- nltk.download('punkt_tab')
23
 
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,7 +32,7 @@ pipeline_en = pipeline(task="text-classification", model="Hello-SimpleAI/chatgpt
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,20 +211,19 @@ def paraphrase_and_correct(text):
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
 
231
  # Launch the Gradio app
232
  demo.launch()
 
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
 
22
  # Initialize stopwords
23
  stop_words = set(stopwords.words("english"))
24
 
25
+ # Exclusion lists
26
  exclude_tags = {'PRP', 'PRP$', 'MD', 'VBZ', 'VBP', 'VBD', 'VBG', 'VBN', 'TO', 'IN', 'DT', 'CC'}
27
  exclude_words = {'is', 'am', 'are', 'was', 'were', 'have', 'has', 'do', 'does', 'did', 'will', 'shall', 'should', 'would', 'could', 'can', 'may', 'might'}
28
 
 
32
  # Initialize the spell checker
33
  spell = SpellChecker()
34
 
35
+ # Load the SpaCy model
36
  try:
37
  nlp = spacy.load("en_core_web_sm")
38
  except OSError:
 
211
 
212
  # Gradio app setup
213
  with gr.Blocks() as demo:
214
+ with gr.Tab("Text Input"):
215
+ text_input = gr.TextArea(label="Input Text", placeholder="Enter text here...")
216
+ text_output = gr.TextArea(label="Output Text", interactive=False)
217
+ submit_btn = gr.Button("Submit")
 
218
 
219
+ submit_btn.click(paraphrase_and_correct, inputs=text_input, outputs=text_output)
220
 
221
+ with gr.Tab("AI Detection"):
222
+ ai_input = gr.TextArea(label="Input Text for AI Detection", placeholder="Enter text here...")
223
+ ai_output = gr.Textbox(label="AI Detection Result", interactive=False)
224
+ ai_submit_btn = gr.Button("Submit for AI Detection")
225
 
226
+ ai_submit_btn.click(predict_en, inputs=ai_input, outputs=ai_output)
227
 
228
  # Launch the Gradio app
229
  demo.launch()