Commit 51a2eb55 authored by Thomas Huetter's avatar Thomas Huetter
Browse files

statistics: added a script that outputs the min, max and average tree sizes of a given input file

parent 3113fb85
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
#!/bin/bash
# file: nodes_per_tree.sh
#
# usage: ./prepare_data.sh <inputfile>
#
# Program: Counts the number of nodes per line. Ouputs the maximal, 
#          minimal and average number of nodes per line of the given 
#          inputfile containing a tree in bracket notation per line.
#
# Author: Thomas Huetter

if [ -z "$1" ]
  then
    echo "Argument missing."
    echo "Usage: ./prepare_data.sh <inputfile>"
    exit 1
fi

awk -F '\{' '{print NF-1}' $1 | awk 'NR == 1 { max=$1; min=$1; sum=0 }
   { if ($1>max) max=$1; if ($1<min) min=$1; sum+=$1;}
   END {printf "Min: %d\tMax: %d\tAverage: %f\n", min, max, sum/NR}'