1
0

pull_data.sh 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env bash
  2. #
  3. # Copyright (c) 2016-present, Facebook, Inc.
  4. # All rights reserved.
  5. #
  6. # This source code is licensed under the MIT license found in the
  7. # LICENSE file in the root directory of this source tree.
  8. #
  9. myshuf() {
  10. perl -MList::Util=shuffle -e 'print shuffle(<>);' "$@";
  11. }
  12. normalize_text() {
  13. tr '[:upper:]' '[:lower:]' | sed -e 's/^/__label__/g' | \
  14. sed -e "s/'/ ' /g" -e 's/"//g' -e 's/\./ \. /g' -e 's/<br \/>/ /g' \
  15. -e 's/,/ , /g' -e 's/(/ ( /g' -e 's/)/ ) /g' -e 's/\!/ \! /g' \
  16. -e 's/\?/ \? /g' -e 's/\;/ /g' -e 's/\:/ /g' | tr -s " " | myshuf
  17. }
  18. RESULTDIR=result
  19. DATADIR=data
  20. mkdir -p "${RESULTDIR}"
  21. mkdir -p "${DATADIR}"
  22. if [ ! -f "${DATADIR}/dbpedia.train" ]
  23. then
  24. wget -c "https://github.com/le-scientifique/torchDatasets/raw/master/dbpedia_csv.tar.gz" -O "${DATADIR}/dbpedia_csv.tar.gz"
  25. tar -xzvf "${DATADIR}/dbpedia_csv.tar.gz" -C "${DATADIR}"
  26. cat "${DATADIR}/dbpedia_csv/train.csv" | normalize_text > "${DATADIR}/dbpedia.train"
  27. cat "${DATADIR}/dbpedia_csv/test.csv" | normalize_text > "${DATADIR}/dbpedia.test"
  28. fi