Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,13 +4,20 @@ import spacy
|
|
4 |
import matplotlib.pyplot as plt
|
5 |
from transformers import pipeline
|
6 |
import random
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
# Load NLP models
|
9 |
nltk.download("vader_lexicon")
|
10 |
from nltk.sentiment import SentimentIntensityAnalyzer
|
11 |
sia = SentimentIntensityAnalyzer()
|
12 |
|
13 |
-
nlp = spacy.load("en_core_web_sm")
|
14 |
emotion_pipeline = pipeline("text-classification", model="j-hartmann/emotion-english-distilroberta-base", return_all_scores=True)
|
15 |
|
16 |
# Sample texts
|
|
|
4 |
import matplotlib.pyplot as plt
|
5 |
from transformers import pipeline
|
6 |
import random
|
7 |
+
import subprocess
|
8 |
+
|
9 |
+
# Ensure spaCy model is installed
|
10 |
+
try:
|
11 |
+
nlp = spacy.load("en_core_web_sm")
|
12 |
+
except OSError:
|
13 |
+
subprocess.run(["python", "-m", "spacy", "download", "en_core_web_sm"])
|
14 |
+
nlp = spacy.load("en_core_web_sm")
|
15 |
|
16 |
# Load NLP models
|
17 |
nltk.download("vader_lexicon")
|
18 |
from nltk.sentiment import SentimentIntensityAnalyzer
|
19 |
sia = SentimentIntensityAnalyzer()
|
20 |
|
|
|
21 |
emotion_pipeline = pipeline("text-classification", model="j-hartmann/emotion-english-distilroberta-base", return_all_scores=True)
|
22 |
|
23 |
# Sample texts
|