#!/usr/bin/perl
#v1-5.1.2016
use strict;
use warnings;
# kgb -9 |apt-get install kgb 

my $path="/home/onetipp/deeptest/onetipp_corpus/raw";
my $de_final = "/home/onetipp/deeptest/onetipp_corpus/final/de.txt";
my $en_final = "/home/onetipp/deeptest/onetipp_corpus/final/en.txt";
unlink $de_final;
unlink $en_final;
my $c1;
my $c2;

my @files = glob("$path/*");

foreach my $file (@files) {
	my $de_file;
	my $en_file;
	if ($file =~ /\.de$/ig){
		$de_file = $file;
		$en_file = $file;
		$en_file =~ s/\.de-en\.de$/\.de-en\.en/ig;
		print "DE: $de_file\n";
			system("cat $de_file >> $de_final");
		print "EN: $en_file\n";
			system("cat $en_file >> $en_final");
	}
	
}

sub addDE(){
	my $file = shift;
	
	$| = 1;
	open(R1,"<$file");
		$c1 = <R1>;
		
	open(W1,"+>>$de_final");
		print W1 $c1;
	close W1;
	return;
}

sub addEN(){
	my $file = shift;
	
	$| = 1;
	open(R2,"<$file");
		$c2 = <R2>;
		
	open(W2,"+>>$en_final");
		print W2 $c2;
	close W2;
	return;
}

exit 0;