Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,8 @@ import torch
|
|
5 |
import nltk
|
6 |
from nltk.corpus import wordnet
|
7 |
import spacy
|
|
|
|
|
8 |
from gensim.models import KeyedVectors
|
9 |
from gensim import downloader as api
|
10 |
from nltk.tokenize import word_tokenize
|
@@ -12,10 +14,14 @@ from nltk.tokenize import word_tokenize
|
|
12 |
# Download NLTK data (if not already downloaded)
|
13 |
nltk.download('punkt')
|
14 |
nltk.download('stopwords')
|
15 |
-
nltk.download('wordnet') # Download WordNet
|
16 |
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
# Load a smaller Word2Vec model from Gensim's pre-trained models
|
21 |
word_vectors = api.load("glove-wiki-gigaword-50")
|
|
|
5 |
import nltk
|
6 |
from nltk.corpus import wordnet
|
7 |
import spacy
|
8 |
+
import subprocess
|
9 |
+
|
10 |
from gensim.models import KeyedVectors
|
11 |
from gensim import downloader as api
|
12 |
from nltk.tokenize import word_tokenize
|
|
|
14 |
# Download NLTK data (if not already downloaded)
|
15 |
nltk.download('punkt')
|
16 |
nltk.download('stopwords')
|
|
|
17 |
|
18 |
+
|
19 |
+
# Ensure the spaCy model is installed
|
20 |
+
try:
|
21 |
+
nlp = spacy.load("en_core_web_sm")
|
22 |
+
except OSError:
|
23 |
+
subprocess.run(["python", "-m", "spacy", "download", "en_core_web_sm"])
|
24 |
+
nlp = spacy.load("en_core_web_sm")
|
25 |
|
26 |
# Load a smaller Word2Vec model from Gensim's pre-trained models
|
27 |
word_vectors = api.load("glove-wiki-gigaword-50")
|