#!/usr/bin/perl

use Getopt::Long;
use sylseg_sk::Trans_sylseg;


my $ifile;
my @stack;
my (%g1_tp, %g1_bp, %g1_mp);
my @syl;
local *INPUT,*OUTPUT;
$prior=1;
$colour=0;
my %optctl = (help => \$help, dl => \$prior, best => \$best, colour => \$colour);
&GetOptions(\%optctl,"best","dl=i","help","colour");

set_debug_level($prior,$colour);
printhelp() if($help==1);
process_arguments();

mess("Processing ...",1);
open (INPUT,"<$ifile") or
    die ("Can not open input file  $ifile !!!\n");
while(<INPUT>)
{
 my $slovko;
 my @finlist;
 chomp; 
 s/\r//g;
 s/ //g; $slovko=$_; s/^/-/; 
 next if(/-$/);
 mess("Cating $slovko ...",2);
 mess("Cating $_ ...",3);
 @stack=gen_pos_sylabels($_);
 my $flist=join(" :: ",@stack);
 mess("Cat: $flist",2);
 @finlist=calc_probs(@stack);
 foreach $k (@finlist)
  {
   ($prob,$hyp)=split("::",$k);
   mess("$hyp \t\t$prob",1);
   last if($best==1);
  }
  mess("---------------",1);
}
close INPUT;
warn "\n(c) Dodo 2003,2004,2005\n\n";
exit(0);

sub process_arguments
  {
    if(@ARGV==0)
      {
	$ifile="-";
	mess("Reading from standard input ...",1);
      }
    else
      {
	$ifile=$ARGV[0];
	($ofile = $ifile) =~ s/\.[^.]+$//;
      }
    $ofile .= ".sylabels" if($ifile ne "-");

    mess("Input:\t $ifile",1);
    mess("Output:\t $ofile",1);
  }

sub printhelp
{    
  print "\
sylseg_sk [--best] [--colour] [--dl debug level] [--help] [<input file>]
\t<input file>\t- list of the words for the segmentation
\t\-\-best\t - Print the best result only.
\t\-\-colour - Enable colour output.
\t\-\-dl\t - Set the debug level. Control the amount of displayed information
\t\t\t  The debug level 0 displays nothing. The maximum level 5 displays full
\t\t\t  debugging report. The default debug level is 1.
\t\-\-help\t - display a short help text and exit\n";
exit(0);
}



