sashdev commited on
Commit
1b1b24d
Β·
verified Β·
1 Parent(s): f951a28

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -14
app.py CHANGED
@@ -24,7 +24,7 @@ nltk.download('punkt_tab')
24
  # Initialize stopwords
25
  stop_words = set(stopwords.words("english"))
26
 
27
- # Exclusion lists
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
- # Load the SpaCy model
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("Text Input"):
217
- text_input = gr.TextArea(label="Input Text", placeholder="Enter text here...")
218
- text_output = gr.TextArea(label="Output Text", interactive=False)
219
- submit_btn = gr.Button("Submit")
 
220
 
221
- submit_btn.click(paraphrase_and_correct, inputs=text_input, outputs=text_output)
222
 
223
- with gr.Tab("AI Detection"):
224
- ai_input = gr.TextArea(label="Input Text for AI Detection", placeholder="Enter text here...")
225
- ai_output = gr.Textbox(label="AI Detection Result", interactive=False)
226
- ai_submit_btn = gr.Button("Submit for AI Detection")
227
 
228
- ai_submit_btn.click(predict_en, inputs=ai_input, outputs=ai_output)
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