diff options
| author | 2024-03-08 01:19:41 +0800 | |
|---|---|---|
| committer | 2024-03-08 01:19:41 +0800 | |
| commit | a9b7b0295dae63a2346c1556e1c2381ca4d25f9f (patch) | |
| tree | bbaf08eaf467bc8402a3b9c736f971834449c1d6 /tools/download.sh | |
| parent | e1f06bcc1638fbfe326039dfc5fa814e20fe7c62 (diff) | |
| download | ipm-server-a9b7b0295dae63a2346c1556e1c2381ca4d25f9f.tar.gz ipm-server-a9b7b0295dae63a2346c1556e1c2381ca4d25f9f.zip | |
feat(site): build the simple index demo
Diffstat (limited to 'tools/download.sh')
| -rw-r--r-- | tools/download.sh | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tools/download.sh b/tools/download.sh new file mode 100644 index 0000000..a87ab73 --- /dev/null +++ b/tools/download.sh @@ -0,0 +1,48 @@ +#!/bin/bash +function usage() { + echo + echo "Usage: $(basename $0) <collection name>" + echo + echo "Copies nltk data to proper locations from local copy of repository." + echo "Assumes script is in repo tools directory." + echo + echo "Clone the repo:" + printf '\t%s\n' 'git clone git@github.com:<owner>/ipm-server.git' + echo + echo "Now switch branches to the one with the data on it (and this script):" + printf '\t%s\n' 'git branch gh-pages remotes/origin/gh-pages' + printf '\t%s\n' 'git checkout gh-pages' + echo + echo "Remember to use sudo if installing to /usr/share (default)" + echo + echo set NLTK_DATA_DIR to target directory if different than /usr/share, e.g.: + printf '\t%s %s\n' 'NLTK_DATA_DIR=./local/dir' "$(basename $0) book" + echo +} + +[ $# -eq 0 ] && { usage; exit 1; } + +collection=$1 +data_dir=${NLTK_DATA_DIR:-/usr/share/nltk_data} +script_dir="$( cd "$( dirname "$0" )" && pwd )" +repo_dir=$(readlink -f "$script_dir/..") +package_dir=$repo_dir/packages +collections_dir=$repo_dir/collections + +mkdir -p $data_dir +pushd $data_dir + +python -c "import xml.etree.ElementTree as e +for item in e.parse('$collections_dir/$collection.xml').getroot().findall('item'): + print item.get('ref')" | +while read item +do + package=$(find $package_dir -name $item.zip -print) + target_dir=$(basename $(dirname $package)) + target_file=$target_dir/$item.zip + mkdir -p $target_dir + cp $package $target_file + unzip -u -d $target_dir $target_file +done + +popd
\ No newline at end of file |
