Commit 857a4f43 authored by Thomas Huetter's avatar Thomas Huetter

fixed bug in statistics; rename bolzano files to bracket

parent 5056dc25
...@@ -23,15 +23,15 @@ cd original_data ...@@ -23,15 +23,15 @@ cd original_data
# prepare data for file L.trees # prepare data for file L.trees
# convert file into UTF-8 format | remove header | remove IDs | sort by number of nodes (equivalent to number of "{") # convert file into UTF-8 format | remove header | remove IDs | sort by number of nodes (equivalent to number of "{")
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.txt 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
# prepare data for file R.trees # 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 "{") # convert file into UTF-8 format | remove header | remove IDs | sort by number of nodes (equivalent to number of "{")
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.txt 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
# prepare dataset with a single label # prepare dataset with a single label
# | remove non-bracket chars. | add single dummy label 'o' > save to file # | remove non-bracket chars. | add single dummy label 'o' > save to file
cat ../L_preprocessed.txt | sed 's/[^\{\}]//g' | sed 's/[\{]/\{o/g' > ../L_preprocessed_single_label.txt cat ../L_preprocessed.txt | sed 's/[^\{\}]//g' | sed 's/[\{]/\{o/g' > ../L_preprocessed_single_label.bracket
# go back to the folder # go back to the folder
cd .. cd ..
\ No newline at end of file
...@@ -65,8 +65,8 @@ max_tree_size = 0 ...@@ -65,8 +65,8 @@ max_tree_size = 0
with open(args.inputfile) as f: with open(args.inputfile) as f:
# for each tree in the inputfile # for each tree in the inputfile
for line in f: for line in f:
# split line by '{' and '}' and remove empty entries at the beginning and end # remove all '}', split line by '{' and remove empty entries at the beginning and end
nodes = re.split(r'[{}]+', line.strip())[1:-1] nodes = re.split(r'[{]', re.sub('[\}]', '', line))[1:-1]
# get tree size # get tree size
tree_size = len(nodes) tree_size = len(nodes)
# sum to compute average # sum to compute average
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment