1
0

pull_data.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  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 BSD-style license found in the
  7. # LICENSE file in the root directory of this source tree. An additional grant
  8. # of patent rights can be found in the PATENTS file in the same directory.
  9. #
  10. myshuf() {
  11. perl -MList::Util=shuffle -e 'print shuffle(<>);' "$@";
  12. }
  13. normalize_text() {
  14. tr '[:upper:]' '[:lower:]' | sed -e 's/^/__label__/g' | \
  15. sed -e "s/'/ ' /g" -e 's/"//g' -e 's/\./ \. /g' -e 's/<br \/>/ /g' \
  16. -e 's/,/ , /g' -e 's/(/ ( /g' -e 's/)/ ) /g' -e 's/\!/ \! /g' \
  17. -e 's/\?/ \? /g' -e 's/\;/ /g' -e 's/\:/ /g' | tr -s " " | myshuf
  18. }
  19. RESULTDIR=result
  20. DATADIR=data
  21. mkdir -p "${RESULTDIR}"
  22. mkdir -p "${DATADIR}"
  23. if [ ! -f "${DATADIR}/dbpedia.train" ]
  24. then
  25. wget -c "https://github.com/le-scientifique/torchDatasets/raw/master/dbpedia_csv.tar.gz" -O "${DATADIR}/dbpedia_csv.tar.gz"
  26. tar -xzvf "${DATADIR}/dbpedia_csv.tar.gz" -C "${DATADIR}"
  27. cat "${DATADIR}/dbpedia_csv/train.csv" | normalize_text > "${DATADIR}/dbpedia.train"
  28. cat "${DATADIR}/dbpedia_csv/test.csv" | normalize_text > "${DATADIR}/dbpedia.test"
  29. fi