How To Add Nltk Corpora To A Google Cloud Function?
I am trying to run Google cloud function which involves the use of NLTK. I had added textblob == 0.15.3 nltk == 3.4.3 to the requirement.txt. But every time I run the script it cr
Solution 1:
This is how I get the nltk_data through my Travis Pipeline:
# To install the core NLTK package
pip install nltk
# Installs only the extra packages you need. You could also use 'all' instead.
python -m nltk.downloader punkt averaged_perceptron_tagger wordnet
Then you can copy the folder into your function folder, and zip it up:
mkdir -p function/nltk_data/
cp -a ~/nltk_data/. function/nltk_data/
cp -a path/to/your/code/. function/
Be sure to set the NLTK_DATA environment variable. As my folder structure was
- nltk_data/
- main.py
- requirements.txt
I just needed to set NLTK_DATA=nltk_data, and then python can find the files.
Hope this helps!
Post a Comment for "How To Add Nltk Corpora To A Google Cloud Function?"