#!/bin/perl
# Perl script that parses a list of word+POS lines, and for each
# such line, calls make to generate the corresponding paradigm.

use File::Spec;

my $word_pos_list = @ARGV[0];
my $xsl_script = @ARGV[1];
my $jc = "java net.sf.saxon.Transform -it main ";

open FILE, $word_pos_list or die $!;

while ( <FILE> ) {
  chop;
  if (/^\s.*$/) {
    next;
  } else {
    my $word, $pos;
    ($word, $pos) = split;
    $wordpos = $word . "_" . $pos;
    #    print "word is $word\n" ;
    #    print "pos is $pos\n" ;^
    my $command = "make $pos-paradigm WORD\=$word make-dictindex" ;
    #    print "$command\n";
    system($command);
    my $xmlcommand = "perl paradigm2xml.pl $word.paradigm > $wordpos.xml";
    system($xmlcommand);
    
    $abs_path = File::Spec->rel2abs("$wordpos.xml");
    
    my $xslcommand = "$jc $xsl_script file=$abs_path";
    
    #     print "$xslcommand\n";
    
    system($xslcommand);
    
  }
  
}
