$dirname = shift;
$no = 0;
opendir ( DIR, $dirname ) || die "Error in opening dir $dirname\n";
while( ($filename = readdir(DIR))){
	if ($filename ne "." && $filename ne "..") {
		#print STDERR ++$no."\n";
		system("./text_cat ".$dirname."/".$filename." > lg1");
		open F, "lg1"; $line = <F>; close F;
		if ($line !~ /^portuguese/) {print STDERR "File ".$dirname."/".$filename." is ".$line;next;}
		open F, $dirname."/".$filename;
		while (<F>) {
			my $ligne = $_;
			my @t = split /[A-Z]/, $ligne;
			my $maj = @t - 1;			
			my $wc = 0;
			for (split /\s+/,$ligne) {$wc++;} 
			if ($maj < $wc/2) {
				print $ligne;;
			}
		}
		print "\nEND_FILE\n";
		close F;    		
	}
}
closedir(DIR);



