#!/usr/bin/perl

###########################
### Autor: Sebastian Enger / B.Sc. 
### Copyright: Sebastian Enger
### Licence: BSD
### Version: 1.1.b  - 20080716@19.Uhr
### Contact: sebastian.enger@gmail.com | icq: 135846444
### Latest Version: PENDRIVE:\Programming\Perl\IncrementalBackup
###########################

# http://www.rxnlp.com/rouge-2-0-usage-documentation/

use strict;
use File::Find;	# perl -MCPAN -e 'force install "File::Find"'
use File::Copy;	# perl -MCPAN -e 'force install "File::Copy"'
use File::Path;	# perl -MCPAN -e 'force install "File::Path"'
# use File::Remove qw(remove);
use Lingua::DE::Sentence;

mkdir "/home/Framework/Prototyp/eval_data/system";
mkdir "/home/Framework/Prototyp/eval_data/reference";

my $SourceFolder = '/home/dowsery-demo2/binary_data/myexperiment5000/decode_train_400maxenc_4beam_35mindec_100maxdec_ckpt-232508/reference/';

# prepare files from SourceFolder
find(\&SourceStructure1, $SourceFolder);


sub SourceStructure1(){

    # $_ is set to the current file name
    # $File::Find::dir is set to the current directory
    # $File::Find::name is set to "$File::Find::dir/$_"
    # you are chdir()'d to $File::Find::dir 

	my $SourceFilename		= $File::Find::name;
	my $SourceDirname		= $File::Find::dir;
	my $file 				= $_;
	
	my @w=split('/',$SourceFilename);
	my $l=pop(@w);
	my (undef,$cct)=split("-",$l);
	$cct=~s/^0+//g;
	#return if $cct > 138;
	#000019_decoded.txt
	my $ToCopyFolder="/home/Framework/Prototyp/eval_data/reference/news1_reference$cct.txt";
	print "COPY $SourceFilename NACH $ToCopyFolder\n";
	open my $fh, '<', $SourceFilename or die;
	$/ = undef;
	my $data = <$fh>;
	close R;
	open(W,">$ToCopyFolder");
	my $sentences = get_sentences($data);
    foreach my $sent (@$sentences) {
        chomp($sent);
		print W "$sent\n";
    }
	close W;
}; # sub SourceStructure(){

my $SourceFolder = '/home/dowsery-demo2/binary_data/myexperiment5000/decode_train_400maxenc_4beam_35mindec_100maxdec_ckpt-232508/decoded/';

# prepare files from SourceFolder
find(\&SourceStructure2, $SourceFolder);


sub SourceStructure2(){

    # $_ is set to the current file name
    # $File::Find::dir is set to the current directory
    # $File::Find::name is set to "$File::Find::dir/$_"
    # you are chdir()'d to $File::Find::dir 

	my $SourceFilename		= $File::Find::name;
	my $SourceDirname		= $File::Find::dir;
	my $file 				= $_;
	
	my @w=split('/',$SourceFilename);
	my $l=pop(@w);
	my ($cct,undef)=split("_",$l);
	$cct=~s/^0+//g;
	#000019_decoded.txt
	my $ToCopyFolder="/home/Framework/Prototyp/eval_data/system/news1_system$cct.txt";
	print "COPY $SourceFilename NACH $ToCopyFolder\n";
	open my $fh, '<', $SourceFilename or die;
	$/ = undef;
	my $data = <$fh>;
	close R;
	open(W,">$ToCopyFolder");
	my $sentences = get_sentences($data);
    foreach my $sent (@$sentences) {
        chomp($sent);
		print W "$sent\n";
    }
	close W;
	#copy ($SourceFilename,$ToCopyFolder);	
}; # sub SourceStructure(){