# 
# Feature(POS) to Internal State mapping
# 
# NOTE:
#   -  This file is handeled as a perl library.
#   -  The charset of this file should be the same as that of dictionary. 
#

sub init_rewrite {}; 

sub unigram_rewrite {

    # 読み,発音をとりのぞいて, 品詞1,2,3,4,活用形,活用型,原形,よみ を使う
    my @F = @{shift @_}[0..7];

    # 原形の同一視ルール
    if ($F[6] =~ /^(言う|いう|云う)$/) {
	$F[6] = "言う";
    } elsif ($F[6] =~ /^(来る|くる)$/) {
	$F[6] = "来る";
    } elsif ($F[6] =~ /^(行く|行う|する)$/) {
	$F[6] = "行く";
    }

    return \@F;
}

sub left_rewrite {

    # 読み,発音をとりのぞいて, 品詞1,2,3,4,活用形,活用型,原形のみを使う
    my @F = @{shift @_}[0..6]; 

    if ($F[0] =~ /^(助詞|助動詞)/) {

	# 語彙化なのでそのまま    

    } elsif ($F[0] =~ /^動詞/) {

	if ($F[6] =~ /^(言う|いう|云う)$/) {
	    $F[6] = "言う";
	} elsif ($F[6] =~ /^(来る|くる)$/) {
	    $F[6] = "来る";
	} elsif ($F[6] =~ /^(行く|行う|する)$/) {
	    $F[6] = $1;
	} else {
	    $F[6] = "*";
	}

    } elsif ($F[0] =~ /^形容詞/) {

	if ($F[6] =~ /(ない|づらい|にくい|ぽい|っぽい|たらしい|ったらしい|くさい)$/) {
	    $F[6] = $1; # 語尾でまとめる
	} elsif ($F[6] =~ /(欲しい|ほしい)$/) {
	    $F[6] = "欲しい";
	} elsif ($F[6] =~ /(がたい|難い)$/) {
	    $F[6] = "難い";
	} else {
	    $F[6] = "*";
	}

    } else {
	$F[6] = "*"; # 語彙部分を * に変更
    }

    return \@F;
}

sub right_rewrite {
    return left_rewrite (shift @_);
}

1;
