Spaces:
Running
Running
Update core/init_nlp.py
Browse files- core/init_nlp.py +5 -1
core/init_nlp.py
CHANGED
@@ -5,6 +5,10 @@ from core.config import settings
|
|
5 |
|
6 |
def initialize_nlp():
|
7 |
print("Initializing NLP resources...")
|
|
|
|
|
|
|
|
|
8 |
|
9 |
# Download NLTK resources
|
10 |
nltk_resources = [
|
@@ -17,7 +21,7 @@ def initialize_nlp():
|
|
17 |
]
|
18 |
|
19 |
for resource in nltk_resources:
|
20 |
-
nltk.downloader.download(resource, quiet=True)
|
21 |
|
22 |
# Load spaCy model
|
23 |
spacy.load(settings.SPACY_MODEL)
|
|
|
5 |
|
6 |
def initialize_nlp():
|
7 |
print("Initializing NLP resources...")
|
8 |
+
|
9 |
+
nltk_data_path = Path("/tmp/nltk_data")
|
10 |
+
nltk_data_path.mkdir(parents=True, exist_ok=True)
|
11 |
+
nltk.data.path.append(str(nltk_data_path))
|
12 |
|
13 |
# Download NLTK resources
|
14 |
nltk_resources = [
|
|
|
21 |
]
|
22 |
|
23 |
for resource in nltk_resources:
|
24 |
+
nltk.downloader.download(resource, download_dir=str(nltk_data_path) ,quiet=True)
|
25 |
|
26 |
# Load spaCy model
|
27 |
spacy.load(settings.SPACY_MODEL)
|