#!/usr/bin/gawk -f BEGIN { TrainCenter2Inter="trainCenter2Inter.arff"; TrainCenter2Intra="trainCenter2Intra.arff"; TestCenter2="testCenter2.arff"; TrainCenter5Inter="trainCenter5Inter.arff"; TrainCenter5Intra="trainCenter5Intra.arff"; TestCenter5="testCenter5.arff"; TestSize = 5; Seed = 1; } /^[ \t]*$/ { next; } NR==1{ srand(Seed); print "" > TrainCenter2Inter; print "" > TrainCenter2Intra; print "" > TestCenter2; print "" > TrainCenter5Inter; print "" > TrainCenter5Intra; print "" > TestCenter5; } FILENAME==ARGV[3] && /@relation/,/@data/ { print $0 >> TrainCenter2Inter; print $0 >> TrainCenter2Intra; print $0 >> TestCenter2; print $0 >> TrainCenter5Inter; print $0 >> TrainCenter5Intra; print $0 >> TestCenter5; next; } FILENAME==ARGV[4] && /@relation/,/@data/ { next; } FILENAME==ARGV[3] { InstanceCenter2[rand()] = $0; } FILENAME==ARGV[4] { InstanceCenter5[rand()] = $0; } END { TestSizeCenter2 = TestSize; for (i in InstanceCenter2) { if (TestSizeCenter2 > 0) { print InstanceCenter2[i] >> TestCenter2; TestSizeCenter2--; } else print InstanceCenter2[i] >> TrainCenter2Intra; } for (i in InstanceCenter5) print InstanceCenter5[i] >> TrainCenter2Inter; TestSizeCenter5 = TestSize; for (i in InstanceCenter5) { if (TestSizeCenter5 > 0) { print InstanceCenter5[i] >> TestCenter5; TestSizeCenter5--; } else print InstanceCenter5[i] >> TrainCenter5Intra; } for (i in InstanceCenter2) print InstanceCenter2[i] >> TrainCenter5Inter; }