#!/usr/local/bin/perl


# ./make-entries.pl < POS-list.txt >! POS.trf

# Uncomment to create ADV lexical entries which are approximately correct, 

while (<>){
# @fields = (english spanish temporal(+/-) (time/type))
    @fields = split " ", $_;
    $fields[0] =~ tr/A-z/a-z/;
    print "ADV::ADV |: [$fields[0]] -> [$fields[1]]
(
(X1::Y1)
((x0 form) = $fields[0])
((x0 temporal) = $fields[2])\n";

   if ($fields[2] eq "+"){
   print "((x0 time) = $fields[3])\n)\n\n";
   } elsif ($fields[3] ne ""){
       print "((x0 type) = $fields[3])\n)\n\n";
    } else {
         print ")\n\n";
 }
}


# Uncomment to create DET/POSS lexical entries
while (<>){
    @fields = split " ", $_;
    $fields[0] =~ tr/A-z/a-z/;
    print "DET::DET |: [$fields[0]] -> [$fields[1]]
(
(X1::Y1)
((x0 form) = $fields[0])\n";

    $last_char = chop($fields[1]);
    if ($last_char eq "s") {
	print "((x0 agr num) = pl)\n";
	$plast_char = chop($fields[1]); # it now has one less character
	if ($plast_char eq "a") {
	    print "((x0 agr gen) = fem)\n";
	} else {
	    print "((x0 agr gen) = masc)\n";
	}
    }
    else {
        print "((x0 agr num) = sg)\n";
	if ($last_char eq "a") {
	    print "((x0 agr gen) = fem)\n";
	} else {
	    print "((x0 agr gen) = masc)\n";
	}
    }
    # if there is another field (semtype), output it
    if ($fields[2] ne ""){
	print "((x0 semtype) = $fields[2])\n)\n\n";
    } else {
	print "((x0 def) =  )\n)\n\n";
    }
}

# Uncomment to create PRON lexical entries

while (<>){
# @fields = (english spanish person number case)
    @fields = split " ", $_;
    $fields[0] =~ tr/A-z/a-z/;
    print "PRON::PRON |: [$fields[0]] -> [$fields[1]]
(
(X1::Y1)
((x0 form) = $fields[0])
((x0 agr pers) = $fields[2])
((x0 agr num) = $fields[3])
((x0 case) = $fields[4])\n)\n\n";
}

# Uncomment to create ADJ lexical entries which are approximately correct, 
# some will need revision, since gender and number will not always be correct
while (<>){
    @fields = split " ", $_;
    $fields[0] =~ tr/A-z/a-z/;
    print "ADJ::ADJ |: [$fields[0]] -> [$fields[1]]
(
(X1::Y1)
((x0 form) = $fields[0])\n";

    $last_char = chop($fields[1]);
    if ($last_char eq "s") {
	print "((x0 agr num) = pl)\n";
	$plast_char = chop($fields[1]); # it now has one less character
	if ($plast_char eq "a") {
	    print "((x0 agr gen) = fem)\n";
	} else {
	    print "((x0 agr gen) = masc)\n";
	}
    }
    else {
        print "((x0 agr num) = sg)\n";
	if ($last_char eq "a") {
	    print "((x0 agr gen) = fem)\n";
	} else {
	    print "((x0 agr gen) = masc)\n";
	}
    }
    # if there is another field (semtype), output it
    if ($fields[2] ne ""){
	print "((x0 semtype) = $fields[2])\n)\n\n";
    } else {
	print ")\n\n";
    }
}

# Uncomment to create AUX lexical entries which are approximately correct, 
while (<>){
# @fields = (english spanish tense person number)
    @fields = split " ", $_;
    $fields[0] =~ tr/A-z/a-z/;
    print "AUX::AUX |: [$fields[0]] -> [$fields[1]]
(
(X1::Y1)
((x0 form) = $fields[0])
((x0 actform) = $fields[0])
((x0 tense) = $fields[2])
((x0 agr pers) = $fields[3])
((x0 agr num) = $fields[4])
((x0 type) = aux)
)\n\n";
}

# Uncomment to create PREP lexical entries which are approximately correct, 
while (<>){
# @fields = (english spanish tense person number)
    @fields = split " ", $_;
    $fields[0] =~ tr/A-z/a-z/;
    print "PREP::PREP |: [$fields[0]] -> [$fields[1]]
(
(X1::Y1)
((x0 form) = $fields[0])\n";

    if ($fields[2] ne ""){
       print "((x0 type) = $fields[2])\n)\n\n";
    } else {
         print ")\n\n";
    }
}






