Sephfox commited on
Commit
d8d4f16
·
verified ·
1 Parent(s): d3eaecf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -4
app.py CHANGED
@@ -17,12 +17,26 @@ from nltk.chunk import ne_chunk
17
  from textblob import TextBlob
18
  import matplotlib.pyplot as plt
19
  import seaborn as sns
 
20
 
21
- warnings.filterwarnings('ignore', category=FutureWarning, module='huggingface_hub.file_download')
 
 
 
 
 
 
22
 
23
- # Download necessary NLTK data (lazy loading)
24
- nltk.download('vader_lexicon', quiet=True, raise_on_error=True)
25
- nltk.data.path.append('/nltk_data') # Specify the path where NLTK data should be stored
 
 
 
 
 
 
 
26
 
27
  # Initialize Example Dataset (For Emotion Prediction)
28
  data = {
@@ -290,3 +304,5 @@ iface = gr.Interface(fn=interactive_interface, inputs="text", outputs=[
290
 
291
  # Launch the interface
292
  iface.launch()
 
 
 
17
  from textblob import TextBlob
18
  import matplotlib.pyplot as plt
19
  import seaborn as sns
20
+ import ssl
21
 
22
+ # NLTK data download
23
+ try:
24
+ _create_unverified_https_context = ssl._create_unverified_context
25
+ except AttributeError:
26
+ pass
27
+ else:
28
+ ssl._create_default_https_context = _create_unverified_https_context
29
 
30
+ nltk.download('words', quiet=True)
31
+ nltk.download('vader_lexicon', quiet=True)
32
+ nltk.download('punkt', quiet=True)
33
+ nltk.download('averaged_perceptron_tagger', quiet=True)
34
+ nltk.download('maxent_ne_chunker', quiet=True)
35
+
36
+ # Set NLTK data path
37
+ nltk.data.path.append('/home/user/nltk_data')
38
+
39
+ warnings.filterwarnings('ignore', category=FutureWarning, module='huggingface_hub.file_download')
40
 
41
  # Initialize Example Dataset (For Emotion Prediction)
42
  data = {
 
304
 
305
  # Launch the interface
306
  iface.launch()
307
+
308
+