download_prepare.sh 1.47 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#!/bin/bash
# file: prepare_data.sh
#
# Program: Downloads and prepares data containing the address trees of Bolzano.
#
# Author: Thomas Huetter

# create target folder and change into it
mkdir bolzano-address-trees
cd bolzano-address-trees

# download the data files
wget https://dbresearch.uni-salzburg.at/projects/pq-gram-ordered-labeled-trees/bolzano-address-trees.zip

# unzip the data into folder bolzano-address-trees
unzip bolzano-address-trees.zip -d original_data

# remove zip file
19
rm -rf bolzano-address-trees.zip
20 21 22 23 24

# change to unzipped folder
cd original_data

# prepare data for file L.trees
25
#     convert file into UTF-8 format   | remove header |  remove IDs   | sort by number of nodes (equivalent to number of "{")
26
iconv -f ISO-8859-1 -t "UTF-8" L.trees | tail -n +14   | sed 's/.*://' | awk '{print gsub("{","{"), $0}' | sort -n  | cut -d' ' -f2- > ../L_preprocessed.bracket
27 28 29

# prepare data for file R.trees
#     convert file into UTF-8 format   | remove header |  remove IDs   | sort by number of nodes (equivalent to number of "{")
30
iconv -f ISO-8859-1 -t "UTF-8" R.trees | tail -n +14   | sed 's/.*://' | awk '{print gsub("{","{"), $0}' | sort -n  | cut -d' ' -f2- > ../R_preprocessed.bracket
31

32 33
# prepare dataset with a single label
#                         | remove non-bracket chars. | add single dummy label 'o' > save to file
34
cat ../L_preprocessed.txt | sed 's/[^\{\}]//g'        | sed 's/[\{]/\{o/g'         > ../L_preprocessed_single_label.bracket
35

36 37
# go back to the folder
cd ..