#!/usr/bin/perl 
use locale;
#open (out,">totalres.dat")|| die "Couldn't open lpmax.dat: $!\n";
$fcount=1;$ts=0;$td=0;
#$evaltype=1;#0 ise wordbased modelin wordbased sonuclari 1 ise wordbased modelin igbased sonuçlari da verilecek. 2 ise igbased model için hem igbased hem wordbased sonuclar verilecek
$crv=1;
$guide="svm";
$numArgs = $#ARGV + 1;
$maltoptions="";
$numArgs--;
$dirname=$ARGV[0];
$i=1;
while($numArgs>0){
    $maltoptions.=$ARGV[$i]." ";
    $i++;
    $numArgs--;
}

$totalf1=0;
	$totalf2=0;
	$totalsnt=0;
	$meansnt=0;
	undef @snt;
	$snt=0;
	$snttotal=0;
	$meansig=0;
	$sig=0;
	undef @sig;
	$meansigwopunc=0;
	$sigwopunc=0;
	undef @sigwopunc[$fcount];
	$meanf1=0;
	$meanigf1=0;
	undef @igf1;
	$stdevsumf1=0;
	$stdevsumigf1=0;
	$stdevsumsnt=0;
	$stdevsumsig=0;
	$stdevsumsigwopunc=0;
system "rm overalltest.conll";

    system "rm overalloutput.conll";
open (out,">>totalres.dat")|| die "Couldn't open lpmax.dat: $!\n";
    printf out "\n\fcount\tsnt_accuracy\tunlabeled\tlabeled\t\tlabeledsnt\tunlabeledWord\n";
open (t,">prec_recall.dat")|| die "Couldn't open lpmax.dat: $!\n";
open (t,">eval.html")|| die "Couldn't open eval.html: $!\n";
close t;

while ($fcount<=$crv){    
    	
    close out;
    open (out,">>totalres.dat")|| die "Couldn't open lpmax.dat: $!\n";    
    system "rm *.ins";
    system "rm *.mod";
    system "rm train.conll";

#train with the projectives and test with the entire data
    for($j=0;$j<10;$j++){
	
	    system "cat  train.conll $dirname/orijinaltreebak_$j.conllnproj >temp.conll";
	    system "cp temp.conll train.conll";
	    print "cat  train.conll $dirname/orijinaltreebak_$j.conllnproj >train.conll\n";
	
    }    

    print "cv#$fcount: train.conll created";
        
   if($guide eq "svm"){
	    print "malt.exe -f svmoption2.txt $maltoptions\n";
	    system "malt.exe -f svmoption2.txt $maltoptions";	    
    }
    
    $fcount++;
    

}
	