sashdev commited on
Commit
e63bdfe
·
verified ·
1 Parent(s): f561fcc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -6
app.py CHANGED
@@ -1,16 +1,45 @@
1
  import os
2
- import random
3
- import re
4
- import string
5
  import spacy
6
- from nltk.corpus import wordnet
7
  import nltk
8
- import gradio as gr
 
 
 
 
 
 
9
 
10
- # Ensure that necessary NLTK resources are downloaded
11
  nltk.download('punkt')
 
12
  nltk.download('averaged_perceptron_tagger')
 
13
  nltk.download('wordnet')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  # Load SpaCy model
16
  nlp = spacy.load("en_core_web_sm")
 
1
  import os
2
+ import gradio as gr
3
+ from transformers import pipeline
 
4
  import spacy
5
+ import subprocess
6
  import nltk
7
+ from nltk.corpus import wordnet
8
+ from nltk.corpus import stopwords
9
+ from nltk.tokenize import word_tokenize
10
+ from spellchecker import SpellChecker
11
+ import re
12
+ import string
13
+ import random
14
 
15
+ # Download necessary NLTK data
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
+
31
+ # Initialize the English text classification pipeline for AI detection
32
+ pipeline_en = pipeline(task="text-classification", model="Hello-SimpleAI/chatgpt-detector-roberta")
33
+
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:
41
+ subprocess.run(["python", "-m", "spacy", "download", "en_core_web_sm"])
42
+ nlp = spacy.load("en_core_web_sm")
43
 
44
  # Load SpaCy model
45
  nlp = spacy.load("en_core_web_sm")