#!/usr/bin/perl

use strict;
use warnings;

use Carp qw(cluck longmess shortmess croak confess);
use Data::Dumper;

use Ernad::Common;
use Ernad::Erimp;
use Ernad::Learn::Mocla;

my $impna='';
my $repcode='';
my $issuedate='';
my $file= $ARGV[0];
my $e;
if(not -f $file) {
  confess "I can't open the file $file";
}
$impna=&Ernad::Common::find_impna_from_file($file)
  or confess "I can't get the impna from the file $file";
$e=Ernad::Erimp->new({'impna'=> $impna, 'verbose'=>1});  
$repcode=$e->find_repcode_from_file($file,$impna)
  or confess "I can't get the repcode from the file $file";
$issuedate=&Ernad::Common::find_issuedate_from_file($file);
my $time=&Ernad::Common::find_time_from_file($file)
  or confess "I can't get the time from $file";
my $d=Ernad::Learn::Dokli->new({'impna' => $impna,
                                'report'=>$repcode,
                                'time'=> $time,
                                'verbose' => 10});
&Ernad::Learn::Common::set_basic($d,$time);

my $glob=$d->{'dokli_dir'}.'/*_'.$time.'.txt';
my @files=glob($glob);
## dokli per report --> redol
my $redol_file=$files[0];
#$d->set_dokli_for_model($redol_file);  
#$d->type_vemli_file($file);

my $m=Ernad::Learn::Mocla->new({'impna' => $impna,
                                'report'=>$repcode,
                                'time'=> $time,
                                'verbose' => 10});

$m->check_train_file($file);




exit;
