#!/bin/sh

echo "Starting script for counting classes and properties in deltas"
echo "Before executing this script, you should have calculated the deltas"

folder=deltas
for entry in "$folder"/*
do
  echo "Processing: $entry"
	echo "Calculating added classes and properties"
	prev="$entry"/added_filtered.tsv
  if ! [ -f "$prev" ]; then
		kgtk filter -i "$entry"/added.tsv -p " ; P31 ; " -o "$entry"/added_filtered.tsv
		kgtk unique -i "$entry"/added_filtered.tsv --column node2 -o "$entry"/added_class_count.tsv
		kgtk unique -i "$entry"/added.tsv --column label -o "$entry"/added_prop_count.tsv
		echo "Calculating deleted classes and properties"
  	kgtk filter -i "$entry"/deleted.tsv -p " ; P31 ; " -o "$entry"/deleted_filtered.tsv
  	kgtk unique -i "$entry"/deleted_filtered.tsv --column node2 -o "$entry"/deleted_class_count.tsv	
		kgtk unique -i "$entry"/deleted.tsv --column label -o "$entry"/deleted_prop_count.tsv
		echo "Calculating modified statements"
		kgtk unique -i "$entry"/modified_qual.tsv --column label -o "$entry"/modified_prop_count.tsv
	fi
done


