-
Notifications
You must be signed in to change notification settings - Fork 0
/
nltk
36 lines (28 loc) · 1.18 KB
/
nltk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash
# This script serves as the NLTK build step of the
# [**Python Buildpack**](https://github.com/heroku/heroku-buildpack-python)
# compiler.
#
# A [buildpack](https://devcenter.heroku.com/articles/buildpacks) is an
# adapter between a Python application and Heroku's runtime.
#
# This script is invoked by [`bin/compile`](/).
# Syntax sugar.
# shellcheck source=bin/utils
source "$BIN_DIR/utils"
# Check that nltk was installed by pip, otherwise obviously not needed
if sp-grep -s nltk; then
puts-step "Downloading NLTK corpora…"
nltk_packages_definition="$BUILD_DIR/nltk.txt"
if [ -f "$nltk_packages_definition" ]; then
readarray -t nltk_packages < "$nltk_packages_definition"
puts-step "Downloading NLTK packages: ${nltk_packages[*]}"
python -m nltk.downloader -d "$BUILD_DIR/.heroku/python/nltk_data" "${nltk_packages[@]}" | indent
set_env NLTK_DATA "/app/.heroku/python/nltk_data"
mcount "buildvar.NLTK_PACKAGES_DEFINITION"
mcount "steps.nltk"
else
puts-warn "'nltk.txt' not found, not downloading any corpora"
puts-warn "Learn more: https://devcenter.heroku.com/articles/python-nltk"
fi
fi