# ########################################################################## Otakar Smrz, 2003/04/05
#
# MorphoMap ############################################################################# 2004/02/29

# $Id: MorphoMap.pm,v 1.5 2004/10/06 21:21:27 smrz Exp $

package MorphoMap;

use 5.008;

use strict;
use warnings;

our $VERSION = do { my @r = q$Revision: 1.5 $ =~ /\d+/g; sprintf "%d." . "%02d" x $#r, @r };


our ($AraMorph_POSVector, %AraMorph_POSVector_missing);


#   check_consistency();    # use this when verifying consistency

sub check_consistency {

    verify_POSVector();

    initialize_AraMorph_POSVector();

    my @keys = keys %{$AraMorph_POSVector};

    print scalar @keys . " nonexpanded items\n";

    @keys = ();

    foreach (keys %{$AraMorph_POSVector}) {

        push @keys, &distinguish_POSVector($AraMorph_POSVector->{$_});
    }

    print scalar @keys . " expanded items\n";
}


sub AraMorph_POSVector ($) {

    my $morpho = shift @_;

    &initialize_AraMorph_POSVector unless defined $AraMorph_POSVector;

    if (exists $AraMorph_POSVector->{$morpho}) {

        return $AraMorph_POSVector->{$morpho};
    }
    else {

        $AraMorph_POSVector_missing{$morpho}++;

        return $morpho;
    }
}


sub distinguish_POSVector (@) {

    my (@vectors) = map { [ split //, $_ ] } @_;

    return unless @_;

    # the 3rd case (oblique) is either the 2nd (genitive), or the 4th (accusative)

    @vectors = map { $_->[-2] eq '3' ? (

                        [ @{$_}[-10..-3], '2', $_->[-1] ],
                        [ @{$_}[-10..-3], '4', $_->[-1] ],

                    ) : $_ } @vectors;

    # the X-definiteness is the illurosy-definite-article + illusory-singular's ambiguity for either D, or C (very rarely)

    @vectors = map { $_->[-1] eq 'X' ? (

                        [ @{$_}[-10..-2], 'D' ],
                        [ @{$_}[-10..-2], 'C' ],

                    ) : $_ } @vectors;

    # map the case of the former 'PRON' to 1, 2 and 4

    @vectors = map { $_->[-10] eq 'S' && $_->[-9] eq '-' && $_->[-2] eq '-' ? (

                        [ @{$_}[-10..-3], '1', $_->[-1] ],
                        [ @{$_}[-10..-3], '2', $_->[-1] ],
                        [ @{$_}[-10..-3], '4', $_->[-1] ],

                    ) : $_ } @vectors;

    return map { join '', @{$_} } @vectors;
}


sub verify_POSVector () {

    my (@vectors);

    &initialize_AraMorph_POSVector unless defined $AraMorph_POSVector;

    foreach (keys %{$AraMorph_POSVector}) {

        if (/DET\+/) {

            if (/_DU|MASC_PL/) {

                warn $AraMorph_POSVector->{$_}, " D <- ", $_, "\t" unless $AraMorph_POSVector->{$_} =~ /.........D/;
            }
            else {

                warn $AraMorph_POSVector->{$_}, " X <- ", $_, "\t" unless $AraMorph_POSVector->{$_} =~ /.........X/;
            }
        }
        else {

            if (/_INDEF|_DU|MASC_PL/ and not /POSS/) {

                warn $AraMorph_POSVector->{$_}, " I <- ", $_, "\t" unless $AraMorph_POSVector->{$_} =~ /.........I/;
            }
            elsif (/NOUN|ADJ/) {

                warn $AraMorph_POSVector->{$_}, " R <- ", $_, "\t" unless $AraMorph_POSVector->{$_} =~ /.........R/;
            }
        }
    }
}


sub initialize_AraMorph_POSVector () {

    $AraMorph_POSVector = {

        ''                      =>      '----------',

        'NUMERICAL'             =>      'Q---------',
        'NUM'                   =>      'Q---------',

        'PUNCTUATION'           =>      'G---------',
        'PUNC'                  =>      'G---------',

        'NON_ALPHABETIC_DATA'   =>      'X---------',

        'ABBREV'                =>      'Y---------',

        'DET'                   =>      '---------X',

        'TYPO'                  =>      'T---------',

        # ################################################################################
        #
        # PROPER NOUNS ###################################################################

        'NOUN_PROP'                             =>  'Z---------',

        'NOUN_PROP+NSUFF_MASC_SG_ACC_INDEF'     =>  'Z-----MS4I',
        'NOUN_PROP+NSUFF_FEM_SG'                =>  'Z-----FS--',
        'NOUN_PROP+NSUFF_FEM_SG+CASE_DEF_NOM'   =>  'Z-----FS1R',
        'NOUN_PROP+NSUFF_FEM_SG+CASE_DEF_GEN'   =>  'Z-----FS2R',
        'NOUN_PROP+NSUFF_FEM_SG+CASE_DEF_ACC'   =>  'Z-----FS4R',
        'NOUN_PROP+NSUFF_MASC_PL_NOM'           =>  'Z-----MP1I',
        'NOUN_PROP+NSUFF_MASC_PL_ACCGEN'        =>  'Z-----MP3I',
        'NOUN_PROP+NSUFF_MASC_PL_ACCGEN_POSS'   =>  'Z-----MP3R',
        'NOUN_PROP+NSUFF_FEM_PL'                =>  'Z-----FP--',
        'NOUN_PROP+NSUFF_FEM_SG+CASE_INDEF_NOM' =>  'Z-----FP1I',
        'NOUN_PROP+NSUFF_FEM_SG+CASE_INDEF_GEN' =>  'Z-----FP2I',
        'NOUN_PROP+NSUFF_FEM_SG+CASE_INDEF_ACC' =>  'Z-----FP4I',
        'NOUN_PROP+NSUFF_MASC_DU_NOM_POSS'      =>  'Z-----MD1R',
        'NOUN_PROP+NSUFF_FEM_DU_NOM_POSS'       =>  'Z-----FD1R',
        'NOUN_PROP+NSUFF_MASC_DU_NOM'           =>  'Z-----MD1I',
        'NOUN_PROP+NSUFF_MASC_DU_ACCGEN'        =>  'Z-----MD3I',
        'NOUN_PROP+NSUFF_MASC_DU_ACCGEN_POSS'   =>  'Z-----MD3R',

        'DET+NOUN_PROP'                         =>  'Z--------X',
        'DET+NOUN_PROP+NSUFF_FEM_SG'            =>  'Z-----FS-X',
        'DET+NOUN_PROP+NSUFF_MASC_PL_NOM'       =>  'Z-----MP1D',
        'DET+NOUN_PROP+NSUFF_MASC_PL_ACCGEN'    =>  'Z-----MP3D',
        'DET+NOUN_PROP+NSUFF_FEM_PL'            =>  'Z-----FP-X',
        'DET+NOUN_PROP+NSUFF_MASC_DU_NOM'       =>  'Z-----MD1D',
        'DET+NOUN_PROP+NSUFF_MASC_DU_ACCGEN'    =>  'Z-----MD3D',

        'NOUN_PROP+CASE_INDEF_NOM'      =>      'Z-------1I',
        'NOUN_PROP+CASE_INDEF_GEN'      =>      'Z-------2I',

        'NOUN_PROP+CASE_DEF_NOM'        =>      'Z-------1R',
        'NOUN_PROP+CASE_DEF_GEN'        =>      'Z-------2R',
        'NOUN_PROP+CASE_DEF_ACC'        =>      'Z-------4R',

        'NOUN_PROP+NSUFF_FEM_SG+CASE_DEF_GEN'   =>      'Z-----FS2R',
        'NOUN_PROP+NSUFF_FEM_SG+CASE_INDEF_GEN' =>      'Z-----FS2I',

        'NOUN_PROP+NSUFF_FEM_PL+CASE_DEF_NOM'       =>  'Z-----FP1R',
        'NOUN_PROP+NSUFF_FEM_PL+CASE_DEF_ACCGEN'    =>  'Z-----FP3R',
        'NOUN_PROP+NSUFF_FEM_PL+CASE_INDEF_NOM'     =>  'Z-----FP1I',
        'NOUN_PROP+NSUFF_FEM_PL+CASE_INDEF_ACCGEN'  =>  'Z-----FP3I',

        'DET+NOUN_PROP+CASE_DEF_NOM'    =>      'Z-------1X',
        'DET+NOUN_PROP+CASE_DEF_GEN'    =>      'Z-------2X',
        'DET+NOUN_PROP+CASE_DEF_ACC'    =>      'Z-------4X',

        'DET+NOUN_PROP+NSUFF_FEM_SG+CASE_DEF_NOM'       =>      'Z-----FS1X',
        'DET+NOUN_PROP+NSUFF_FEM_SG+CASE_DEF_GEN'       =>      'Z-----FS2X',
        'DET+NOUN_PROP+NSUFF_FEM_SG+CASE_DEF_ACC'       =>      'Z-----FS4X',

        'DET+NOUN_PROP+NSUFF_FEM_PL+CASE_DEF_NOM'       =>  'Z-----FP1X',
        'DET+NOUN_PROP+NSUFF_FEM_PL+CASE_DEF_ACCGEN'    =>  'Z-----FP3X',

        # ################################################################################
        #
        # GENERAL NOUNS ##################################################################

        'NOUN'                              =>      'N---------',
        'NOUN+CASE_DEF_NOM'                 =>      'N-------1R',
        'NOUN+CASE_DEF_GEN'                 =>      'N-------2R',
        'NOUN+CASE_DEF_ACC'                 =>      'N-------4R',
        'NOUN+NSUFF_MASC_SG_ACC_INDEF'      =>      'N-----MS4I',
        'NOUN+NSUFF_FEM_SG'                 =>      'N-----FS--',
        'NOUN+NSUFF_MASC_PL_NOM'            =>      'N-----MP1I',
        'NOUN+NSUFF_MASC_PL_NOM_POSS'       =>      'N-----MP1R',
        'NOUN+NSUFF_MASC_PL_ACCGEN'         =>      'N-----MP3I',
        'NOUN+NSUFF_MASC_PL_ACCGEN_POSS'    =>      'N-----MP3R',
        'NOUN+NSUFF_FEM_PL'                 =>      'N-----FP--',
        'NOUN+NSUFF_MASC_DU_NOM'            =>      'N-----MD1I',
        'NOUN+NSUFF_MASC_DU_NOM_POSS'       =>      'N-----MD1R',
        'NOUN+NSUFF_MASC_DU_ACCGEN'         =>      'N-----MD3I',
        'NOUN+NSUFF_MASC_DU_ACCGEN_POSS'    =>      'N-----MD3R',
        'NOUN+NSUFF_FEM_DU_NOM'             =>      'N-----FD1I',
        'NOUN+NSUFF_FEM_DU_NOM_POSS'        =>      'N-----FD1R',
        'NOUN+NSUFF_FEM_DU_ACCGEN'          =>      'N-----FD3I',
        'NOUN+NSUFF_FEM_DU_ACCGEN_POSS'     =>      'N-----FD3R',

        'DEM+NOUN'                          =>      'N--------X',   # Tim's typo

        'DET+NOUN'                          =>      'N--------X',
        'DET+NOUN+NSUFF_FEM_SG'             =>      'N-----FS-X',
        'DET+NOUN+NSUFF_MASC_PL_NOM'        =>      'N-----MP1D',
        'DET+NOUN+NSUFF_MASC_PL_ACCGEN'     =>      'N-----MP3D',
        'DET+NOUN+NSUFF_FEM_PL'             =>      'N-----FP-X',
        'DET+NOUN+NSUFF_MASC_DU_NOM'        =>      'N-----MD1D',
        'DET+NOUN+NSUFF_MASC_DU_ACCGEN'     =>      'N-----MD3D',
        'DET+NOUN+NSUFF_FEM_DU_NOM'         =>      'N-----FD1D',
        'DET+NOUN+NSUFF_FEM_DU_ACCGEN'      =>      'N-----FD3D',

        'NOUN+CASE_INDEF_NOM'   =>      'N-------1I',
        'NOUN+CASE_INDEF_GEN'   =>      'N-------2I',
        'NOUN+CASE_INDEF_ACC'   =>      'N-------4I',

        'NOUN+NSUFF_FEM_SG+CASE_INDEF_NOM'      =>      'N-----FS1I',
        'NOUN+NSUFF_FEM_SG+CASE_INDEF_GEN'      =>      'N-----FS2I',
        'NOUN+NSUFF_FEM_SG+CASE_INDEF_ACC'      =>      'N-----FS4I',

        'NOUN+NSUFF_FEM_SG+CASE_DEF_NOM'        =>      'N-----FS1R',
        'NOUN+NSUFF_FEM_SG+CASE_DEF_GEN'        =>      'N-----FS2R',
        'NOUN+NSUFF_FEM_SG+CASE_DEF_ACC'        =>      'N-----FS4R',

        'NOUN+NSUFF_FEM_PL+CASE_INDEF_NOM'      =>      'N-----FP1I',
        'NOUN+NSUFF_FEM_PL+CASE_INDEF_ACCGEN'   =>      'N-----FP3I',

        'NOUN+NSUFF_FEM_PL+CASE_DEF_NOM'        =>      'N-----FP1R',
        'NOUN+NSUFF_FEM_PL+CASE_DEF_GEN'        =>      'N-----FP2R',
        'NOUN+NSUFF_FEM_PL+CASE_DEF_ACC'        =>      'N-----FP4R',
        'NOUN+NSUFF_FEM_PL+CASE_DEF_ACCGEN'     =>      'N-----FP3R',
        'NOUN+NSUFF_FEM_PL+CASE_INDEF_GEN'      =>      'N-----FP2I',
        'NOUN+NSUFF_FEM_PL+CASE_INDEF_ACC'      =>      'N-----FP4I',

        'DET+NOUN+CASE_DEF_NOM' =>      'N-------1X',
        'DET+NOUN+CASE_DEF_GEN' =>      'N-------2X',
        'DET+NOUN+CASE_DEF_ACC' =>      'N-------4X',

        'DET+NOUN+NSUFF_FEM_SG+CASE_DEF_NOM'    =>      'N-----FS1X',
        'DET+NOUN+NSUFF_FEM_SG+CASE_DEF_GEN'    =>      'N-----FS2X',
        'DET+NOUN+NSUFF_FEM_SG+CASE_DEF_ACC'    =>      'N-----FS4X',

        'DET+NOUN+NSUFF_FEM_PL+CASE_DEF_NOM'    =>      'N-----FP1X',
        'DET+NOUN+NSUFF_FEM_PL+CASE_DEF_GEN'    =>      'N-----FP2X',
        'DET+NOUN+NSUFF_FEM_PL+CASE_DEF_ACC'    =>      'N-----FP4X',
        'DET+NOUN+NSUFF_FEM_PL+CASE_DEF_ACCGEN' =>      'N-----FP3X',

        # ################################################################################
        #
        # ADJECTIVES #####################################################################

        'ADJ'                               =>      'A---------',
        'ADJ+NSUFF_MASC_SG_ACC_INDEF'       =>      'A-----MS4I',
        'ADJ+NSUFF_FEM_SG'                  =>      'A-----FS--',
        'ADJ+NSUFF_MASC_PL_NOM'             =>      'A-----MP1I',
        'ADJ+NSUFF_MASC_PL_ACCGEN'          =>      'A-----MP3I',
        'ADJ+NSUFF_MASC_PL_ACCGEN_POSS'     =>      'A-----MP3R',
        'ADJ+NSUFF_FEM_PL'                  =>      'A-----FP--',
        'ADJ+NSUFF_MASC_DU_NOM'             =>      'A-----MD1I',
        'ADJ+NSUFF_MASC_DU_NOM_POSS'        =>      'A-----MD1R',
        'ADJ+NSUFF_MASC_DU_ACCGEN'          =>      'A-----MD3I',
        'ADJ+NSUFF_MASC_DU_ACCGEN_POSS'     =>      'A-----MD3R',
        'ADJ+NSUFF_FEM_DU_NOM'              =>      'A-----FD1I',
        'ADJ+NSUFF_FEM_DU_NOM_POSS'         =>      'A-----FD1R',
        'ADJ+NSUFF_FEM_DU_ACCGEN'           =>      'A-----FD3I',
        'ADJ+NSUFF_FEM_DU_ACCGEN_POSS'      =>      'A-----FD3R',

        'DET+ADJ'                           =>      'A--------X',
        'DET+ADJ+NSUFF_FEM_SG'              =>      'A-----FS-X',
        'DET+ADJ+NSUFF_MASC_PL_NOM'         =>      'A-----MP1D',
        'DET+ADJ+NSUFF_MASC_PL_ACCGEN'      =>      'A-----MP3D',
        'DET+ADJ+NSUFF_FEM_PL'              =>      'A-----FP-X',
        'DET+ADJ+NSUFF_MASC_DU_NOM'         =>      'A-----MD1D',
        'DET+ADJ+NSUFF_MASC_DU_ACCGEN'      =>      'A-----MD3D',
        'DET+ADJ+NSUFF_FEM_DU_NOM'          =>      'A-----FD1D',
        'DET+ADJ+NSUFF_FEM_DU_ACCGEN'       =>      'A-----FD3D',

        'ADJ+CASE_INDEF_NOM'    =>      'A-------1I',
        'ADJ+CASE_INDEF_GEN'    =>      'A-------2I',
        'ADJ+CASE_INDEF_ACC'    =>      'A-------4I',
        'ADJ+CASE_DEF_NOM'      =>      'A-------1R',
        'ADJ+CASE_DEF_GEN'      =>      'A-------2R',
        'ADJ+CASE_DEF_ACC'      =>      'A-------4R',

        'ADJ+NSUFF_FEM_SG+CASE_DEF_NOM'         =>      'A-----FS1R',
        'ADJ+NSUFF_FEM_SG+CASE_DEF_GEN'         =>      'A-----FS2R',
        'ADJ+NSUFF_FEM_SG+CASE_DEF_ACC'         =>      'A-----FS4R',
        'ADJ+NSUFF_FEM_SG+CASE_INDEF_NOM'       =>      'A-----FS1I',
        'ADJ+NSUFF_FEM_SG+CASE_INDEF_GEN'       =>      'A-----FS2I',
        'ADJ+NSUFF_FEM_SG+CASE_INDEF_ACC'       =>      'A-----FS4I',

        'ADJ+NSUFF_MASC_PL_NOM_POSS'            =>      'A-----MP1R',

        'ADJ+NSUFF_FEM_PL+CASE_DEF_NOM'         =>      'A-----FP1R',
        'ADJ+NSUFF_FEM_PL+CASE_DEF_ACCGEN'      =>      'A-----FP3R',
        'ADJ+NSUFF_FEM_PL+CASE_INDEF_NOM'       =>      'A-----FP1I',
        'ADJ+NSUFF_FEM_PL+CASE_INDEF_ACCGEN'    =>      'A-----FP3I',

        'DET+ADJ+CASE_DEF_NOM'  =>      'A-------1X',
        'DET+ADJ+CASE_DEF_GEN'  =>      'A-------2X',
        'DET+ADJ+CASE_DEF_ACC'  =>      'A-------4X',

        'DET+ADJ+NSUFF_FEM_SG+CASE_DEF_NOM'     =>      'A-----FS1X',
        'DET+ADJ+NSUFF_FEM_SG+CASE_DEF_GEN'     =>      'A-----FS2X',
        'DET+ADJ+NSUFF_FEM_SG+CASE_DEF_ACC'     =>      'A-----FS4X',

        'DET+ADJ+NSUFF_FEM_PL+CASE_DEF_NOM'     =>      'A-----FP1X',
        'DET+ADJ+NSUFF_FEM_PL+CASE_DEF_ACCGEN'  =>      'A-----FP3X',

        # ################################################################################
        #
        # PRONOUNS #######################################################################

        'PRON_1S'       =>      'S----1-S--',
        'PRON_2MS'      =>      'S----2MS--',
        'PRON_2FS'      =>      'S----2FS--',
        'PRON_3MS'      =>      'S----3MS--',
        'PRON_3FS'      =>      'S----3FS--',
        'PRON_1P'       =>      'S----1-P--',
        'PRON_2MP'      =>      'S----2MP--',
        'PRON_2FP'      =>      'S----2FP--',
        'PRON_3MP'      =>      'S----3MP--',
        'PRON_3FP'      =>      'S----3FP--',
        'PRON_3D'       =>      'S----3-D--',

        'POSS_PRON_1S'  =>      'S----1-S2-',
        'POSS_PRON_2MS' =>      'S----2MS2-',
        'POSS_PRON_2FS' =>      'S----2FS2-',
        'POSS_PRON_3MS' =>      'S----3MS2-',
        'POSS_PRON_3FS' =>      'S----3FS2-',
        'POSS_PRON_1P'  =>      'S----1-P2-',
        'POSS_PRON_2MP' =>      'S----2MP2-',
        'POSS_PRON_2FP' =>      'S----2FP2-',
        'POSS_PRON_3MP' =>      'S----3MP2-',
        'POSS_PRON_3FP' =>      'S----3FP2-',
        'POSS_PRON_3D'  =>      'S----3-D2-',

        'PVSUFF_DO:1S'  =>      'S----1-S4-',
        'PVSUFF_DO:2MS' =>      'S----2MS4-',
        'PVSUFF_DO:2FS' =>      'S----2FS4-',
        'PVSUFF_DO:3MS' =>      'S----3MS4-',
        'PVSUFF_DO:3FS' =>      'S----3FS4-',
        'PVSUFF_DO:1P'  =>      'S----1-P4-',
        'PVSUFF_DO:2MP' =>      'S----2MP4-',
        'PVSUFF_DO:2FP' =>      'S----2FP4-',
        'PVSUFF_DO:3MP' =>      'S----3MP4-',
        'PVSUFF_DO:3FP' =>      'S----3FP4-',
        'PVSUFF_DO:3D'  =>      'S----3-D4-',

        'IVSUFF_DO:1S'  =>      'S----1-S4-',
        'IVSUFF_DO:2MS' =>      'S----2MS4-',
        'IVSUFF_DO:2FS' =>      'S----2FS4-',
        'IVSUFF_DO:3MS' =>      'S----3MS4-',
        'IVSUFF_DO:3FS' =>      'S----3FS4-',
        'IVSUFF_DO:1P'  =>      'S----1-P4-',
        'IVSUFF_DO:2MP' =>      'S----2MP4-',
        'IVSUFF_DO:2FP' =>      'S----2FP4-',
        'IVSUFF_DO:3MP' =>      'S----3MP4-',
        'IVSUFF_DO:3FP' =>      'S----3FP4-',
        'IVSUFF_DO:3D'  =>      'S----3-D4-',

        'CVSUFF_DO:1S'  =>      'S----1-S4-',
        'CVSUFF_DO:3MS' =>      'S----3MS4-',
        'CVSUFF_DO:3FS' =>      'S----3FS4-',
        'CVSUFF_DO:1P'  =>      'S----1-P4-',
        'CVSUFF_DO:3MP' =>      'S----3MP4-',

        'REL_PRON'      =>      'SR--------',
        'REL_PRON+NSUFF_MASC_SG_ACC_INDEF'      =>      'SR----MS4I',

        'DEM_PRON_MS'   =>      'SD----MS--',
        'DEM_PRON_F'    =>      'SD----F---',
        'DEM_PRON_FS'   =>      'SD----FS--',
        'DEM_PRON_MP'   =>      'SD----MP--',
        'DEM_PRON_MD'   =>      'SD----MD--',
        'DEM_PRON_FD'   =>      'SD----FD--',

        # seems like over-generating for <*awiy> or <*away>

        'DEM_PRON_MP+CASE_DEF_ACC'      =>  'SD----MP4R',
        'DEM_PRON_MP+CASE_DEF_GEN'      =>  'SD----MP2R',
        'DEM_PRON_MP+CASE_DEF_NOM'      =>  'SD----MP1R',
        'DEM_PRON_MP+CASE_INDEF_ACC'    =>  'SD----MP4I',
        'DEM_PRON_MP+CASE_INDEF_GEN'    =>  'SD----MP2I',
        'DEM_PRON_MP+CASE_INDEF_NOM'    =>  'SD----MP1I',

        'DEM_PRON_MD+CASE_DEF_ACC'      =>  'SD----MD4R',
        'DEM_PRON_MD+CASE_DEF_GEN'      =>  'SD----MD2R',
        'DEM_PRON_MD+CASE_DEF_NOM'      =>  'SD----MD1R',
        'DEM_PRON_MD+CASE_INDEF_ACC'    =>  'SD----MD4I',
        'DEM_PRON_MD+CASE_INDEF_GEN'    =>  'SD----MD2I',
        'DEM_PRON_MD+CASE_INDEF_NOM'    =>  'SD----MD1I',

        # ################################################################################
        #
        # VERBS ##########################################################################

        'VERB'                          =>      'V---------',
        'VERB_PERFECT'                  =>      'VP--------',

        'VERB_PERFECT+PVSUFF_SUBJ:1S'   =>      'VP---1-S--',
        'VERB_PERFECT+PVSUFF_SUBJ:2MS'  =>      'VP---2MS--',
        'VERB_PERFECT+PVSUFF_SUBJ:2FS'  =>      'VP---2FS--',
        'VERB_PERFECT+PVSUFF_SUBJ:3MS'  =>      'VP---3MS--',
        'VERB_PERFECT+PVSUFF_SUBJ:3FS'  =>      'VP---3FS--',
        'VERB_PERFECT+PVSUFF_SUBJ:1P'   =>      'VP---1-P--',
        'VERB_PERFECT+PVSUFF_SUBJ:2MP'  =>      'VP---2MP--',
        'VERB_PERFECT+PVSUFF_SUBJ:2FP'  =>      'VP---2FP--',
        'VERB_PERFECT+PVSUFF_SUBJ:3MP'  =>      'VP---3MP--',
        'VERB_PERFECT+PVSUFF_SUBJ:3FP'  =>      'VP---3FP--',
        'VERB_PERFECT+PVSUFF_SUBJ:3MD'  =>      'VP---3MD--',
        'VERB_PERFECT+PVSUFF_SUBJ:3FD'  =>      'VP---3FD--',

        'VERB_PERFECT_PASSIVE+PVSUFF_SUBJ:1S'   =>      'VP-P-1-S--',
        'VERB_PERFECT_PASSIVE+PVSUFF_SUBJ:2MS'  =>      'VP-P-2MS--',
        'VERB_PERFECT_PASSIVE+PVSUFF_SUBJ:2FS'  =>      'VP-P-2FS--',
        'VERB_PERFECT_PASSIVE+PVSUFF_SUBJ:3MS'  =>      'VP-P-3MS--',
        'VERB_PERFECT_PASSIVE+PVSUFF_SUBJ:3FS'  =>      'VP-P-3FS--',
        'VERB_PERFECT_PASSIVE+PVSUFF_SUBJ:1P'   =>      'VP-P-1-P--',
        'VERB_PERFECT_PASSIVE+PVSUFF_SUBJ:3MP'  =>      'VP-P-3MP--',
        'VERB_PERFECT_PASSIVE+PVSUFF_SUBJ:3FP'  =>      'VP-P-3FP--',
        'VERB_PERFECT_PASSIVE+PVSUFF_SUBJ:3MD'  =>      'VP-P-3MD--',
        'VERB_PERFECT_PASSIVE+PVSUFF_SUBJ:3FD'  =>      'VP-P-3FD--',

        'IV1S+VERB_IMPERFECT'                           =>  'VI---1-S--',
        'IV1S+VERB_IMPERFECT+IVSUFF_MOOD:I'             =>  'VII--1-S--',
        'IV1S+VERB_IMPERFECT+IVSUFF_MOOD:S'             =>  'VIS--1-S--',
        'IV2MS+VERB_IMPERFECT'                          =>  'VI---2MS--',
        'IV2MS+VERB_IMPERFECT+IVSUFF_MOOD:I'            =>  'VII--2MS--',
        'IV2MS+VERB_IMPERFECT+IVSUFF_MOOD:S'            =>  'VIS--2MS--',
        'IV2FS+VERB_IMPERFECT+IVSUFF_SUBJ:2FS_MOOD:I'   =>  'VII--2FS--',
        'IV2FS+VERB_IMPERFECT+IVSUFF_SUBJ:2FS_MOOD:SJ'  =>  'VID--2FS--',
        'IV3MS+VERB_IMPERFECT'                          =>  'VI---3MS--',
        'IV3MS+VERB_IMPERFECT+IVSUFF_MOOD:I'            =>  'VII--3MS--',
        'IV3MS+VERB_IMPERFECT+IVSUFF_MOOD:S'            =>  'VIS--3MS--',
        'IV3FS+VERB_IMPERFECT'                          =>  'VI---3FS--',
        'IV3FS+VERB_IMPERFECT+IVSUFF_MOOD:I'            =>  'VII--3FS--',
        'IV3FS+VERB_IMPERFECT+IVSUFF_MOOD:S'            =>  'VIS--3FS--',
        'IV1P+VERB_IMPERFECT'                           =>  'VI---1-P--',
        'IV1P+VERB_IMPERFECT+IVSUFF_MOOD:I'             =>  'VII--1-P--',
        'IV1P+VERB_IMPERFECT+IVSUFF_MOOD:S'             =>  'VIS--1-P--',
        'IV2MP+VERB_IMPERFECT+IVSUFF_SUBJ:MP_MOOD:I'    =>  'VII--2MP--',
        'IV2MP+VERB_IMPERFECT+IVSUFF_SUBJ:MP_MOOD:SJ'   =>  'VID--2MP--',
        'IV2FP+VERB_IMPERFECT+IVSUFF_SUBJ:FP'           =>  'VI---2FP--',
        'IV3MP+VERB_IMPERFECT+IVSUFF_SUBJ:MP_MOOD:I'    =>  'VII--3MP--',
        'IV3MP+VERB_IMPERFECT+IVSUFF_SUBJ:MP_MOOD:SJ'   =>  'VID--3MP--',
        'IV3FP+VERB_IMPERFECT+IVSUFF_SUBJ:FP'           =>  'VI---3FP--',
        'IV2D+VERB_IMPERFECT+IVSUFF_SUBJ:D_MOOD:I'      =>  'VII--2-D--',
        'IV2D+VERB_IMPERFECT+IVSUFF_SUBJ:D_MOOD:SJ'     =>  'VID--2-D--',
        'IV3MD+VERB_IMPERFECT+IVSUFF_SUBJ:D_MOOD:I'     =>  'VII--3MD--',
        'IV3MD+VERB_IMPERFECT+IVSUFF_SUBJ:D_MOOD:SJ'    =>  'VID--3MD--',
        'IV3FD+VERB_IMPERFECT+IVSUFF_SUBJ:D_MOOD:I'     =>  'VII--3FD--',
        'IV3FD+VERB_IMPERFECT+IVSUFF_SUBJ:D_MOOD:SJ'    =>  'VID--3FD--',
        'IV3FD+VERB_IMPERFECT+IVSUFF_SUBJ:3D'           =>  'VI---3FD--',

        'IV1S+VERB_IMPERFECT_PASSIVE'                   =>      'VI-P-1-S--',
        'IV1S+VERB_IMPERFECT_PASSIVE+IVSUFF_MOOD:I'     =>      'VIIP-1-S--',
        'IV1S+VERB_IMPERFECT_PASSIVE+IVSUFF_MOOD:S'     =>      'VISP-1-S--',
        'IV2MS+VERB_IMPERFECT_PASSIVE'                  =>      'VI-P-2MS--',
        'IV2MS+VERB_IMPERFECT_PASSIVE+IVSUFF_MOOD:I'    =>      'VIIP-2MS--',
        'IV2MS+VERB_IMPERFECT_PASSIVE+IVSUFF_MOOD:S'    =>      'VISP-2MS--',
        'IV2FS+VERB_IMPERFECT_PASSIVE+IVSUFF_SUBJ:2FS_MOOD:I'   =>  'VIIP-2FS--',
        'IV2FS+VERB_IMPERFECT_PASSIVE+IVSUFF_SUBJ:2FS_MOOD:SJ'  =>  'VIDP-2FS--',
        'IV3MS+VERB_IMPERFECT_PASSIVE'                  =>      'VI-P-3MS--',
        'IV3MS+VERB_IMPERFECT_PASSIVE+IVSUFF_MOOD:I'    =>      'VIIP-3MS--',
        'IV3MS+VERB_IMPERFECT_PASSIVE+IVSUFF_MOOD:S'    =>      'VISP-3MS--',
        'IV3FS+VERB_IMPERFECT_PASSIVE'                  =>      'VI-P-3FS--',
        'IV3FS+VERB_IMPERFECT_PASSIVE+IVSUFF_MOOD:I'    =>      'VIIP-3FS--',
        'IV3FS+VERB_IMPERFECT_PASSIVE+IVSUFF_MOOD:S'    =>      'VISP-3FS--',
        'IV1P+VERB_IMPERFECT_PASSIVE'                   =>      'VI-P-1-P--',
        'IV1P+VERB_IMPERFECT_PASSIVE+IVSUFF_MOOD:I'     =>      'VIIP-1-P--',
        'IV1P+VERB_IMPERFECT_PASSIVE+IVSUFF_MOOD:S'     =>      'VISP-1-P--',
        'IV2MP+VERB_IMPERFECT_PASSIVE+IVSUFF_SUBJ:MP_MOOD:I'    =>  'VIIP-2MP--',
        'IV2MP+VERB_IMPERFECT_PASSIVE+IVSUFF_SUBJ:MP_MOOD:SJ'   =>  'VIDP-2MP--',
        'IV2FP+VERB_IMPERFECT_PASSIVE+IVSUFF_SUBJ:FP'           =>  'VI-P-2FP--',
        'IV3MP+VERB_IMPERFECT_PASSIVE+IVSUFF_SUBJ:MP_MOOD:I'    =>  'VIIP-3MP--',
        'IV3MP+VERB_IMPERFECT_PASSIVE+IVSUFF_SUBJ:MP_MOOD:SJ'   =>  'VIDP-3MP--',
        'IV3FP+VERB_IMPERFECT_PASSIVE+IVSUFF_SUBJ:FP'           =>  'VI-P-3FP--',
        'IV2D+VERB_IMPERFECT_PASSIVE+IVSUFF_SUBJ:D_MOOD:I'      =>  'VIIP-2-D--',
        'IV2D+VERB_IMPERFECT_PASSIVE+IVSUFF_SUBJ:D_MOOD:SJ'     =>  'VIDP-2-D--',
        'IV3MD+VERB_IMPERFECT_PASSIVE+IVSUFF_SUBJ:D_MOOD:I'     =>  'VIIP-3MD--',
        'IV3MD+VERB_IMPERFECT_PASSIVE+IVSUFF_SUBJ:D_MOOD:SJ'    =>  'VIDP-3MD--',
        'IV3FD+VERB_IMPERFECT_PASSIVE+IVSUFF_SUBJ:D_MOOD:I'     =>  'VIIP-3FD--',
        'IV3FD+VERB_IMPERFECT_PASSIVE+IVSUFF_SUBJ:D_MOOD:SJ'    =>  'VIDP-3FD--',

        'VERB_IMPERATIVE+CVSUFF_SUBJ:2MS'           =>  'VC---2MS--',
        'VERB_IMPERATIVE+CVSUFF_SUBJ:2FS'           =>  'VC---2FS--',
        'VERB_IMPERATIVE+CVSUFF_SUBJ:2MP'           =>  'VC---2MP--',

        # <layosa> and derivatives!

        'NEG_PART+PVSUFF_SUBJ:3MS'      =>      'VP---3MS--',
        'NEG_PART+PVSUFF_SUBJ:3FS'      =>      'VP---3FS--',
        'NEG_PART+PVSUFF_SUBJ:1P'       =>      'VP---1-P--',
        'NEG_PART+PVSUFF_SUBJ:3MP'      =>      'VP---3MP--',
        'NEG_PART+PVSUFF_SUBJ:3FP'      =>      'VP---3FP--',

        # ################################################################################
        #
        # ADVERBS, PREPOSITIONS, CONJUNCTIONS, PARTICLES, INTERJECTION ###################

        'ADV'                           =>      'D---------',
        'ADV+CASE_DEF_ACC'              =>      'D-------4R',
        'ADV+NSUFF_MASC_SG_ACC_INDEF'   =>      'D-----MS4I',
        'ADV+NSUFF_MASC_DU_NOM_POSS'    =>      'D-----MD1R',

        'REL_ADV'                       =>      'D---------',

        'PREP'          =>      'P---------',
        'PREP+CASE_GEN' =>      'P-------2-',
        'PREP+CASE_ACC' =>      'P-------4-',

        'PREP+CASE_DEF_NOM'     =>  'P-------1R',
        'PREP+CASE_DEF_GEN'     =>  'P-------2R',
        'PREP+CASE_DEF_ACC'     =>  'P-------4R',
        'PREP+CASE_INDEF_NOM'   =>  'P-------1I',
        'PREP+CASE_INDEF_GEN'   =>  'P-------2I',

        # 'PREP+REL_PRON'   =>  '----------',

        'CONJ'          =>      'C---------',
        'SUB_CONJ'      =>      'C---------',
        'SUBJUNC'       =>      'C---------',

        'PART'                      =>      'F---------',
        'VERB_PART'                 =>      'F---------',
        'EXCEPT_PART'               =>      'F---------',
        'RESULT_CLAUSE_PARTICLE'    =>      'F---------',

        # these are <&gt;ay~> or <&gt;ay~+ap> or <&gt;ay~+at+...>

        'INTERROG_PART'                                 =>  'FI--------',
        'INTERROG_PART+CASE_INDEF_NOM'                  =>  'FI------1I',
        'INTERROG_PART+CASE_INDEF_GEN'                  =>  'FI------2I',
        'INTERROG_PART+CASE_DEF_NOM'                    =>  'FI------1R',
        'INTERROG_PART+CASE_DEF_GEN'                    =>  'FI------2R',
        'INTERROG_PART+CASE_DEF_ACC'                    =>  'FI------4R',

        'INTERROG_PART+NSUFF_FEM_SG+CASE_DEF_ACC'       =>  'FI----FS4R',
        'INTERROG_PART+NSUFF_FEM_SG+CASE_DEF_GEN'       =>  'FI----FS2R',
        'INTERROG_PART+NSUFF_FEM_SG+CASE_DEF_NOM'       =>  'FI----FS1R',
        'INTERROG_PART+NSUFF_FEM_SG+CASE_INDEF_ACC'     =>  'FI----FS4I',
        'INTERROG_PART+NSUFF_FEM_SG+CASE_INDEF_GEN'     =>  'FI----FS2I',
        'INTERROG_PART+NSUFF_FEM_SG+CASE_INDEF_NOM'     =>  'FI----FS1I',

        # some relics for <&gt;ay~>

        'INTERROG_PART+NSUFF_MASC_SG_ACC_INDEF'         =>  'FI----MS4I',

        'NEG_PART'                      =>      'FN--------',
        'NEG_PART+CASE_INDEF_NOM'       =>      'FN------1I',
        'NEG_PART+CASE_INDEF_GEN'       =>      'FN------2I',
        'NEG_PART+CASE_DEF_NOM'         =>      'FN------1R',
        'NEG_PART+CASE_DEF_GEN'         =>      'FN------2R',
        'NEG_PART+CASE_DEF_ACC'         =>      'FN------4R',

        'FUT'               =>      'F---------',
        'FUNC_WORD'         =>      'F---------',
        'FUT_PART'          =>      'F---------',
        'EMPHATIC_PARTICLE' =>      'F---------',
        'EMPHATIC_PART'     =>      'F---------',

        # <SaHiyH> with cases, normally <&lt;in~a>

        'INTERJ'                    =>  'I---------',
        'INTERJ+CASE_DEF_ACC'       =>  'I-------4R',
        'INTERJ+CASE_DEF_GEN'       =>  'I-------2R',
        'INTERJ+CASE_DEF_NOM'       =>  'I-------1R',
        'INTERJ+CASE_INDEF_GEN'     =>  'I-------2I',
        'INTERJ+CASE_INDEF_NOM'     =>  'I-------1I',

        # <SaHiyHAF>, <$ukorAF>, <TaboEAF>, <&gt;aholAF> ...

        'INTERJ+NSUFF_MASC_SG_ACC_INDEF'    =>  'I-----MS4I',

        'DET+INTERJ'                =>  'I--------X',
        'DET+INTERJ+CASE_DEF_ACC'   =>  'I-------4X',
        'DET+INTERJ+CASE_DEF_GEN'   =>  'I-------2X',
        'DET+INTERJ+CASE_DEF_NOM'   =>  'I-------1X',

        # ################################################################################
        #
        # ################################################################################

        'ADJ_SHOULD_BE_NOUN'            =>  'N---------',
        'AlsAbAqt NOT FOUND; TYPO'      =>  '----------',
        'A_NAME'                        =>  'Z---------',

        'nA$TwA NOT FOUND; TYPO'        =>  '----------',

        'NO_MATCH'                      =>  '----------',
        'NO_MATCH; ADJ_SHOULD_BE_NOUN'  =>  'N---------',
        'NO_MATCH; PASSIVE_FORM'        =>  'V--P------',

        ' NOT FOUND'                    =>  '----------',

        'TYPO (should be "llvwAbt")'    =>  '----------',
        'TYPO; TYPO'                    =>  '----------',

        'NIL'                           =>  '----------',

               };
}


1;

__END__


=head1 NAME

MorphoMap - Approximation of Tim Buckwalter's Morphology into the Functional Morphology

=head1 REVISION

    $Revision: 1.5 $       $Date: 2004/10/06 21:21:27 $


=head1 DESCRIPTION

Improved mapping for the feature-based tagger, see the NEMLAR 2004 papers:

    MorphoTrees of Arabic and Their Annotation in the TrEd Environment
    Otakar Smrz, Petr Pajas
    L<http://ufal.mff.cuni.cz/~smrz/NEMLAR2004/nemlar-tred.pdf>

    Prague Arabic Dependency Treebank: Development in Data and Tools
    Jan Hajic, Otakar Smrz, Petr Zemanek, Jan Snaidauf, Emanuel Beska
    L<http://ufal.mff.cuni.cz/~smrz/NEMLAR2004/nemlar-padt.pdf>

This is an extended version of mapping, compared to the one with the published results in tagging.
Nevertheless, the current mapping is equivalent to the version that is used in the MorphoTrees of
the Prague Arabic Dependency Treebank 1.0.

The improvements are in better resolution of the values of formal definiteness and in the new
optional C<distinguish_POSVector> function expanding the value C<3> for case into C<2> and C<4>
and the value C<X> for definiteness to C<D> and C<C>. The C<-> case of pronouns expands to C<1>,
C<2>, C<4>.

The unspecified values for B<number and gender> are B<not expanded>, as it would mean to ignore
the already specified information for e.g. illusory feminine plural and overgenerate too much
(recall logical vs. formal vs. illusory categories treated in the papers).


=head1 AUTHOR

Otakar Smrz, L<http://ufal.mff.cuni.cz/~smrz/>

    eval { 'E<lt>' . 'smrz' . "\x40" . ( join '.', qw 'ufal mff cuni cz' ) . 'E<gt>' }

Perl is also designed to make the easy jobs not that easy ;)


=head1 COPYRIGHT AND LICENSE

Copyright (C) 2004 by Otakar Smrz

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.2 or,
at your option, any later version of Perl 5 you may have available.


=cut
