MorPHP를 통한 한국어 동사 변화 규칙 서술

Posted by 적분 ∫2tdt=t²+c
2015.12.22 00:01 프로그래밍
// Korean Inflector

[Valency] := [act, psv]
[Honor] := [unhonor, honor]
[Tense] := [present, perfect, pluperf, gnomic]
[Irrealis] := [real, irreal]
[Formal] := [formal, fpolite, familiar, intimate, casual]
[Syntatic] := [att_con, indi, retr, subj]
[Attributive] := 
    [at_prog, at_perf, at_imperf, at_futr, at_nom, at_nom2, at_adv, at_adv2, at_adv3,
    con_go, con_myeo, con_myeonseo, con_geona, con_na, con_ni, con_nikka,
    con_myeon, con_seo, con_neunde, con_eo, con_ge, con_ji]
[Pragmatic] := [decl, prop, roga, impe]
[Polite] := [unpolite, polite]
[Harmonry] := [negative, positive]

<<Verb>> := <*Root> <Valency> <Honor> <Tense> <Real> <Formal> <SMood> <PMood> <Polite>;

<*Root> := {
    morph base '' [] + ATHarmory
}

attribute ATHarmory {
    [positive] in %[ㅏㅑㅗ][ㄱ-ㅎㅪㅭㅿㆆㅡ]*$%,
    [negative] in %([^ㅏㅑㅗ]|ㅸ)[ㄱ-ㅎㅪㅭㅿㆆㅡ]*$%
}

<Valency> := {
    empty [],
    morph {passive}'ㅣ' [psv]
}

{passive} := {
    'ㅓㅈ' / %ㅜ$% _,
    'ㅇ' / %[ㅎㅏ-ㅣ]$% _ ,
    'ㅎ' / %[ㄱㄷㅈㅂ]$% _ ,
    'ㄹ' / %[ㅪㄹ]$% _ ,
    'ㄱ' / %[ㄴㄶㅅㅁ]$% _,
    'ㅇㅓㅈ'
}

<Honor> := {
    empty [unhonor],
    morph {mov_eu}'ㅅㅣ' [honor]
}

<Tense> := {
    empty [gnomic] [present, att_con] [present, fpolite|familiar|intimate|casual] 
        [present, formal, irreal] [present, formal, real, retr|subj] 
        [present, formal, real, indi, prop|roga|impe],
    morph {neun_prs} [present, formal, real, indi, decl],
    morph 'ㅇ'{hvowel}'ㅆ' [perfect],
    morph 'ㅇ'{hvowel}'ㅆㅇㅓㅆ' [pluperf]
}

{hvowel} := {
    'ㅏ' / [positive] _,
    'ㅓ'
}

<Real> := {
    empty [real],
    morph 'ㄱㅔㅆ' [irreal]
}

<Formal> := {
    empty [formal|familiar|intimate|casual] [att_con],
    morph {seup} [fpolite]
}

{neun_prs} := {
    'ㄴㅡㄴ' / %[^ㅏ-ㅣㄹㅭㆆ]$% _,
    'ㄴ'
}

{seup} := {
    'ㅅㅡㅂ' / %[^ㅏ-ㅣㄹㅭ]$% _ in [^subj],
    'ㅇㅡㅂ' / %[^ㅏ-ㅣㄹㅭ]$% _ in [subj],
    'ㅂ'
}

{mov_eu} := {
    'ㅇㅡ' / %[^ㅏ-ㅣㄹㅭㆆ]$% _,
    ''
}

<SMood> := {
    empty [intimate|casual] [indi, formal, decl|prop] [subj, formal] [familiar, impe],
    morph 'ㄴㅣ' [indi, fpolite],
    morph 'ㄷㅣ' [retr, fpolite],
    morph 'ㅅㅣ' [subj, fpolite],
    morph 'ㄴ' [indi, familiar, decl|prop],
    morph 'ㄷ' [retr, familiar, decl|prop],
    morph 'ㅅ' [subj, familiar, decl|prop],
    morph 'ㄴㅡㄴ' [indi, formal, roga] [indi, familiar, roga],
    morph 'ㄷㅓ'{mov_n} [retr, formal] [retr, familiar, roga],
    
    morph 'ㄴㅡㄴ' [att_con, at_prog],
    morph {mov_eu}'ㄴ' [att_con, at_perf],
    morph 'ㄷㅓㄴ' [att_con, at_imperf],
    morph {mov_eu}'ㄹ' [att_con, at_futr],
    
    morph 'ㄱㅣ' [att_con, at_nom],
    morph {mov_eu}'ㅁ' [att_con, at_nom2],
    morph 'ㅇㅣ' [att_con, at_adv],
    morph 'ㄱㅔ' [att_con, at_adv2],
    morph 'ㄷㅗㄹㅗㄱ' [att_con, at_adv3],
    
    morph 'ㄱㅗ' [att_con, con_go],
    morph {mov_eu}'ㅁㅕ' [att_con, con_myeo],
    morph {mov_eu}'ㅁㅕㄴㅅㅓ' [att_con, con_myeonseo],
    morph {mov_eu}'ㄴㅏ' [att_con, con_na],
    morph {mov_eu}'ㄴㅣ' [att_con, con_ni],
    morph {mov_eu}'ㄴㅣㄲㅏ' [att_con, con_nikka],
    morph {mov_eu}'ㅁㅕㄴ' [att_con, con_myeon],
    morph 'ㅇ'{hvowel}'ㅅㅓ' [att_con, con_seo],
    morph 'ㄴㅡㄴㄷㅔ' [att_con, con_neunde],
    morph 'ㅇ'{hvowel} [att_con, con_eo],
    morph 'ㄱㅔ' [att_con, con_ge],
    morph 'ㅈㅣ' [att_con, con_ji],
    morph 'ㄱㅓㄴㅏ' [att_con, con_geona]
}

{mov_n} := {
    '' / _ in [decl],
    'ㄴ'
}

<PMood> := {
    empty [att_con],
    morph 'ㄷㅏ' [decl|prop, fpolite] [decl, indi, formal],
    morph 'ㄲㅏ' [roga, fpolite],
    morph 'ㅇㅗ' [impe, fpolite],
    morph 'ㄹㅏ' [decl, retr, formal],
    morph 'ㅈㅏ' [prop, formal],
    morph 'ㅑ' [roga, formal],
    morph 'ㅇ'{hvowel}'ㄹㅏ' [impe, formal],
    morph 'ㅔ' [decl|prop, familiar],
    morph 'ㄱㅏ' [roga, familiar],
    morph 'ㄱㅔ' [impe, familiar],
    morph 'ㅇ'{hvowel} [intimate],
    morph 'ㅈㅣ' [casual]
}

<Polite> := {
    empty [unpolite] [att_con],
    morph 'ㅇㅛ' [polite]
}

combine <Root> <*> {
    %ㅎㅏ% %ㅇㅏ% => 'ㅎㅐ',
    %ㅏ% %ㅇㅏ% => 'ㅏ',
    %ㅓ% %ㅇㅓ% => 'ㅓ',
    %ㅗ% %ㅇㅏ% => 'ㅘ',
    %ㅜ% %ㅓ% => 'ㅝ',
    %ㅭㅡ% %ㅇ([ㅏㅓ])% => 'ㄹㅡㄹ\1',
    %ㅭㅡ% %% => 'ㄹㅡ',
    %ㅡ% %ㅇ([ㅏㅓ])% => '\1',
    %ㄹ% %([ㄴㄹㅂㅅ])% => '\1',
    %ㄹ% %ㅁ$% => 'ㄻ',
    %ㅪ% %ㅇ([ㅏ-ㅣ])% => 'ㄹㅇ\1',
    %ㅪ% %% => 'ㄷ',
    %ㅸ% %ㅇㅏ% => 'ㅇㅘ',
    %ㅸ% %ㅇㅓ% => 'ㅇㅝ',
    %ㅸ% %ㅇㅡ% => 'ㅇㅜ',
    %ㅸ% %% => 'ㅂ',
    %ㅿ% %ㅇ([ㅏ-ㅣ])% => 'ㅇ\1',
    %ㅿ% %% => 'ㅅ',
    %ㅭ% %ㅇ([ㅏㅓ])% => 'ㄹㄹ\1',
    %ㅭ% %% => 'ㄹㅡ',
    %[ㅏㅓ]ㆆ% %ㅇ[ㅏㅓ]% => 'ㅐ',
    %[ㅑㅕ]ㆆ% %ㅇ[ㅏㅓ]% => 'ㅒ',
    %ㆆ% %ㅅㅡ% => 'ㅎㅅㅡ',
    %ㆆ% %([ㄴㄹㅁㅅ])% => '\1',
    %ㆆ% %% => 'ㅎ'
}

combine <Honor> <*> {
    %ㅣ% %ㅇㅓ% => 'ㅕ'
}



이 코드로 동사변화를 (거의) 서술할 수 있습니다. 아직 미흡한 부분이 있긴 하지만 사전 유틸리티로는 쓸만합니다.

사용 예제 보기 http://lab.bab2min.pe.kr/kverbConj


이 댓글을 비밀 댓글로