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

fixed bug in statistics; rename bolzano files to bracket

parent 5056dc25
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -23,15 +23,15 @@ cd original_data

# 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 "{")
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
#     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
#                         | 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
cd ..
 No newline at end of file
+2 −2
Original line number Diff line number Diff line
@@ -65,8 +65,8 @@ max_tree_size = 0
with open(args.inputfile) as f:
  # for each tree in the inputfile
  for line in f:
    # split line by '{' and '}' and remove empty entries at the beginning and end
    nodes = re.split(r'[{}]+', line.strip())[1:-1]
    # remove all '}', split line by '{' and remove empty entries at the beginning and end
    nodes = re.split(r'[{]', re.sub('[\}]', '', line))[1:-1]
    # get tree size
    tree_size = len(nodes)
    # sum to compute average