sentencepiece 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/bash
  2. set -e
  3. pushd $(cd $(dirname ${0})/..; pwd) > /dev/null
  4. case "${OSTYPE}" in
  5. msys*) python="winpty python";;
  6. *) python="python";;
  7. esac
  8. clean() {
  9. echo "sentencepiece clean"
  10. rm -rf "./third_party/source/sentencepiece"
  11. }
  12. sync() {
  13. echo "sentencepiece sync"
  14. mkdir -p "./third_party/source/sentencepiece/src"
  15. curl --silent --show-error --location --output "./third_party/source/sentencepiece/src/sentencepiece_model.proto" "https://github.com/google/sentencepiece/raw/master/src/sentencepiece_model.proto"
  16. curl --silent --show-error --location --output "./third_party/source/sentencepiece/src/sentencepiece.proto" "https://github.com/google/sentencepiece/raw/master/src/sentencepiece.proto"
  17. }
  18. schema() {
  19. echo "sentencepiece schema"
  20. [[ $(grep -U $'\x0D' ./source/sentencepiece-proto.js) ]] && crlf=1
  21. node ./tools/protoc.js --binary --text --root sentencepiece --out ./source/sentencepiece-proto.js --path ./third_party/source/sentencepiece src/sentencepiece_model.proto
  22. if [[ -n ${crlf} ]]; then
  23. unix2dos --quiet --newfile ./source/sentencepiece-proto.js ./source/sentencepiece-proto.js
  24. fi
  25. }
  26. while [ "$#" != 0 ]; do
  27. command="$1" && shift
  28. case "${command}" in
  29. "clean") clean;;
  30. "sync") sync;;
  31. "schema") schema;;
  32. esac
  33. done