sentiment-analysis-api / download_data.py
tlong-ds's picture
new files
b2e1431
raw
history blame contribute delete
384 Bytes
import nltk
import os
# Create a folder for NLTK data inside your repo
NLTK_DATA_DIR = "/tmp/nltk_data"
os.makedirs(NLTK_DATA_DIR, exist_ok=True)
# Download datasets to that folder
nltk.download("twitter_samples", download_dir=NLTK_DATA_DIR)
nltk.download("stopwords", download_dir=NLTK_DATA_DIR)
# Append the path so NLTK can find the datasets
nltk.data.path.append(NLTK_DATA_DIR)