download_prepare.sh 927 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#!/bin/bash
# file: prepare_data.sh
#
# Program: Downloads and prepares data containing the sentiment dataset.
#
# Author: Thomas Huetter

# create target folder and change into it
mkdir sentiment
cd sentiment

# download the data files
wget https://nlp.stanford.edu/sentiment/trainDevTestTrees_PTB.zip

# unzip the data into folder original_data
unzip trainDevTestTrees_PTB.zip

# remove zip file
rm -rf trainDevTestTrees_PTB.zip

# change to unzipped folder
cd trees

# prepare data for file L.trees
25
# convert dev.txt and train.txt into UTF-8 format |  replace ( by {  |   replace ) by } |   remove whitespace before '{'   | sort by number of nodes (equivalent to number of "{")
26
iconv -f ISO-8859-1 -t "UTF-8" dev.txt train.txt  | sed -e 's/(/{/g' | sed -e 's/)/}/g' | sed -E 's/[[:space:]]([{])/\1/g' | awk '{print gsub("{","{"), $0}' | sort -n  | cut -d' ' -f2- > ../sentiment_sorted.bracket
27 28

# go back to the folder
29
cd ..