1
0
forked from GitHub/gf-rgl

Merge pull request #309 from inariksit/korean

Korean
This commit is contained in:
Inari Listenmaa
2020-04-06 18:37:01 +02:00
committed by GitHub
13 changed files with 110 additions and 47 deletions

View File

@@ -13,8 +13,8 @@ lin
-- : Prep -> NP -> Adv ;
PrepNP prep np = {
s = case prep.attaches of {
True => glue (np.s ! Bare) prep.s ;
False => np.s ! Bare ++ prep.s }
True => glue (np.s ! Bare) (prep.s ! np.p) ;
False => np.s ! Bare ++ (prep.s ! np.p)}
} ;
-- Adverbs can be modified by 'adadjectives', just like adjectives.

View File

@@ -8,8 +8,8 @@ concrete CatKor of Cat = CommonX ** open ResKor, Prelude in {
-- Constructed in SentenceKor, and also in IdiomKor
S = ResKor.Sentence ;
QS = SS ;
RS = SS ;
QS = SS ; -- Questions not implemented yet
RS = ResKor.Sentence ;
-- relative sentence. Tense and polarity fixed,
-- but agreement may depend on the CN/NP it modifies.

View File

@@ -29,11 +29,11 @@ concrete ConjunctionKor of Conjunction =
lincat
[Adv],[AdV],[IAdv],[RS] = ConjSS ;
[Adv],[AdV],[IAdv] = ConjSS ;
lin
BaseAdv, BaseAdV, BaseIAdv, BaseRS = baseSS ;
ConsAdv, ConsAdV, ConsIAdv, ConsRS = consSS ;
ConjAdv, ConjAdV, ConjIAdv, ConjRS = conjSS ;
BaseAdv, BaseAdV, BaseIAdv = baseSS ;
ConsAdv, ConsAdV, ConsIAdv = consSS ;
ConjAdv, ConjAdV, ConjIAdv = conjSS ;
oper
ConjSS : Type = SS ** {firstSS : ConjType => Str} ;
@@ -51,31 +51,48 @@ oper
s = co.s1 ++ ss.firstSS ! co.c ++ ss.s
} ;
-- Versions with commas, no repeated conjunctions
baseSScomma : SS -> SS -> ConjSS = \s1,s2 -> s2 ** {
firstSS = \\conj => s1.s ++ SOFT_BIND ++ "," ;
} ;
consSScomma : SS -> ConjSS -> ConjSS = \s,ss -> ss ** {
firstSS = \\conj =>
s.s ++ SOFT_BIND ++ "," ++ ss.firstSS ! conj ;
} ;
conjSScomma : Conj -> ConjSS -> SS = \co,ss -> {
s = co.s1
++ glue (ss.firstSS ! co.c) co.s2
++ ss.s
} ;
oper
mkFirstSS : SS -> ConjType => Str = \s ->
\\conj => glue s.s (conjTable ! NStar ! conj) ;
\\conj => glue s.s (conjTable ! VStar ! conj) ;
lincat
[S] = ResKor.Sentence ** {firstS : ConjType => Str} ;
[S], [RS] = ResKor.Sentence ** {firstS : ConjType => Str} ;
lin
BaseS s1 s2 = s2 ** {
BaseS,BaseRS = \s1,s2 -> s2 ** {
firstS = mkFirstS s1
} ;
ConsS s ss = ss ** {
ConsS,ConsRS = \s,ss -> ss ** {
firstS = \\conj =>
mkFirstS s ! conj ++ ss.firstS ! conj ;
} ;
ConjS co ss = ss ** {
ConjS,ConjRS = \co,ss -> ss ** {
s = \\st => co.s1 ++ ss.firstS ! co.c ++ ss.s ! st
} ;
oper
mkFirstS : ResKor.Sentence -> ConjType => Str = \s ->
\\conj => glue (s.s ! WithConj) (conjTable ! NStar ! conj) ;
\\conj => glue (s.s ! WithConj) (conjTable ! VStar ! conj) ;
lincat
[AP] = ResKor.AdjPhrase ** {firstAP : VForm => ConjType => Str} ;
@@ -97,9 +114,7 @@ lin
oper
mkFirstAP : ResKor.AdjPhrase -> VForm => ConjType => Str = \ap ->
\\af,conj => case af of {
VAttr p => glue (ap.s ! VAttr p) (conjTable ! NStar ! conj) ;
_ => glue (ap.s ! VStem) (conjTable ! VStar ! conj) } ;
\\af,conj => ap.compar ++ glue (ap.s ! VStem) (conjTable ! VStar ! conj) ;
{-
lincat

View File

@@ -95,7 +95,7 @@ lin do_V2 = mkV2 do_V ;
-- lin doctor_N = mkN "" ;
-- lin dog_N = mkN "" ;
-- lin door_N = mkN "" ;
-- lin drink_V2 = mkV2 "" ;
lin drink_V2 = mkV2 "마시다" ;
-- lin dry_A = mkA "" ;
-- lin dull_A = mkA "" ;
-- lin dust_N = mkN "" ;
@@ -209,7 +209,7 @@ lin laugh_V = mkV "웃다" ;
-- lin leave_V2 = mkV2 "" ;
-- lin leg_N = mkN "" ;
-- lin lie_V = mkV "" ;
lin like_V2 = mkV2 (mkV "좋다") topic subject ;
lin like_V2 = mkV2 (mkV "좋아" do_V) topic object ;
-- lin listen_V2 = mkV2 "" ;
-- lin live_V = mkV "";
-- lin liver_N = mkN "" ;

View File

@@ -165,7 +165,7 @@ concrete NounKor of Noun = CatKor ** open ResKor, Prelude in {
-- : CN -> RS -> CN ;
RelCN cn rs = cn ** {
rs = cn.rs ++ rs.s
rs = cn.rs ++ rs.s ! Subord
} ;

View File

@@ -18,7 +18,8 @@ oper
--2 Nouns
mkN : overload {
mkN : (noun : Str) -> N ; -- Predictable nouns
mkN : (noun : Str) -> N ; -- Predictable nouns with classifier 개
mkN : (noun,counter : Str) -> N ; -- Noun and classifier given as arguments.
} ;
--2 Adjectives
@@ -30,6 +31,7 @@ oper
mkA2 : overload {
mkA2 : Str -> A2 ; -- Regular adjective, given in -다 form, no postposition for complement.
mkA2 : Str -> Str -> A2 ; -- Adjective given in -다 form, postposition given as a string. If you want to use a postposition that has different forms for after vowel/after consonant, use the next constructor that takes a preconstructed Prep.
mkA2 : A -> Prep -> A2 ; -- Preconstructed adjective and postposition for complement.
} ;
@@ -77,7 +79,8 @@ oper
--2 Structural categories
mkPrep : overload {
mkPrep : (e : Str) -> Prep ; -- Particle like 에, attaches to the NP.
mkPrep : (e : Str) -> Prep ; -- Particle/postposition like 에: same form after vowel and consonant, attaches to the NP. Despite the name Prep, these are always postpositions.
mkPrep : (ro,euro : Str) -> Prep ; -- Particle like 로/으로: first argument is the form after vowel, second argument after consonant. Attaches to the NP.
mkPrep : (dwie : Str) -> (attaches : Bool) -> Prep ; -- `mkPrep "뒤에" False` for a postposition that doesn't attach to the NP.
} ;
@@ -109,7 +112,12 @@ oper
noCase = Bare ;
mkN = overload {
mkN : Str -> N = \s -> lin N (mkNoun s) ;
mkN : Str -> N = \s -> lin N (mkNoun s) ;
mkN : (noun,counter : Str) -> N = \n,c ->
let noun : Noun = mkNoun n ;
counter : Counter = mkCounter c ;
in lin N (noun ** {c = counter}) ;
} ;
@@ -129,6 +137,10 @@ oper
mkA2 = overload {
mkA2 : Str -> A2 = \s -> lin A2 (atoa2 (mkAdj s)) ;
mkA2 : Str -> Str -> A2
= \s,p -> let adj : Adjective = mkAdj s ;
prep : Prep = mkPrep p
in lin A2 (adj ** {p2 = prep}) ;
mkA2 : A -> Prep -> A2 = \a,p -> lin A2 (a ** {p2 = p}) ;
} ;
@@ -160,6 +172,8 @@ oper
mkPrep = overload {
mkPrep : (e : Str) -> Prep -- Particle like 에, attaches to the NP.
= \e -> lin Prep (ResKor.mkPrep e) ;
mkPrep : (ro,euro : Str) -> Prep
= \ro,euro -> lin Prep (ResKor.mkPrep2 ro euro) ;
mkPrep : (dwie : Str) -> (attaches : Bool) -> Prep -- `mkPrep "뒤에" False` for a postposition that doesn't attach to the NP.
= \dwie,f -> lin Prep (ResKor.mkPrep dwie ** {attaches = f}) ;
} ;

View File

@@ -19,7 +19,7 @@ concrete PhraseKor of Phrase = CatKor ** open Prelude, ResKor in {
UttVP vp = {s = linVP vp} ;
UttCN cn = {s = cn.rs ++ cn.s ! Bare} ;
UttCard n = {s = n.s ! NK ! Indep} ;
UttAP ap = { s = ap.s ! VF Plain Pos} ;
UttAP ap = { s = ap.compar ++ ap.s ! VF Plain Pos} ;
NoPConj = {s = []} ;
-- PConjConj conj = {s = conj.s1 ++ conj.s2 ! …} ;

View File

@@ -3,19 +3,20 @@ concrete RelativeKor of Relative = CatKor ** open
lin
-- : Cl -> RCl ; -- such that John loves her
RelCl cl = {s = \\t,a,p => cl.s ! t ! a ! p ! Subord} ;
RelCl = relSlash (ss "") ;
-- : RP -> VP -> RCl ;
RelVP rp vp = {
s = \\t,a,p => vp.s ! VAttr p -- TODO no tenses yet in the grammar
++ rp.s ;
} ;
RelVP rp vp = { -- TODO no tenses yet in the grammar
s = \\t,a,p,cltyp =>
rp.s ++ vp.adv ++ vp.nObj ++
case cltyp of {
WithConj => vp.s ! VStem ;
_ => vp.s ! VAttr p } ;
} ;
-- : RP -> ClSlash -> RCl ; -- whom John loves
RelSlash rp cls = {
s = \\t,a,p => cls.s ! t ! a ! p ! Subord
++ rp.s ;
} ;
RelSlash = relSlash ;
-- : RP ;
IdRP = {s = ""} ;
@@ -23,4 +24,12 @@ lin
-- : Prep -> NP -> RP -> RP ; -- the mother of whom
--FunRP prep np rp = {} ;
oper
relSlash : SS -> ClSlash -> ResKor.RClause = \rp,cls -> {
s = \\t,a,p,cltyp => rp.s ++
case cltyp of {
WithConj => cls.s ! t ! a ! p ! WithConj ;
_ => cls.s ! t ! a ! p ! Subord } ;
} ;
}

View File

@@ -13,6 +13,10 @@ oper
origin = NK
} ;
mkCounter : Str -> Counter = \s -> baseCounter ** {
s = s ;
} ;
BaseNoun : Type = {
s : NForm => Str ;
p : Phono ;
@@ -123,9 +127,13 @@ oper
--------------------------------------------------------------------------------
-- Postpositions
Postposition : Type = {s : Str ; attaches : Bool} ;
Postposition : Type = {s : Phono => Str ; attaches : Bool} ;
mkPrep : Str -> Postposition = \str -> {s=str ; attaches=True} ;
mkPrep : Str -> Postposition = \str -> {s=\\_ => str ; attaches=True} ;
mkPrep2 : (ro,euro : Str) -> Postposition = \ro,euro -> {
s = table {Vowel => ro ; Consonant => euro} ;
attaches = True
} ;
emptyPP : Postposition = mkPrep [] ** {attaches=False} ;
datPP : Postposition = mkPrep "에게" ;
@@ -254,7 +262,7 @@ oper
-- Conj
Conj : Type = {
s1 : Str ;
s1, s2 : Str ;
c : ConjType ; -- if it's And, Or, …
-- Need to add conjunction already in ConsX funs.
n : Number ;
@@ -296,7 +304,7 @@ oper
useVc : Verb2 -> VPSlash = \v2 -> baseVP ** v2 ;
insertComp : VPSlash -> NounPhrase -> VerbPhrase = \v2,np -> useV v2 ** {
nObj = np.s ! v2.c2 ++ v2.p2.s
nObj = np.s ! v2.c2 ++ v2.p2.s ! np.p
} ;
insertAdv : VerbPhrase -> SS -> VerbPhrase = \vp,adv -> vp ** {adv = adv.s} ;
@@ -313,7 +321,7 @@ oper
QClause : Type = Clause ;
RClause : Type = {s : Tense => Anteriority => Polarity => Str} ;
RClause : Type = Clause ;
Sentence : Type = {s : ClType => Str} ;

View File

@@ -56,7 +56,7 @@ lin
UseQCl t p cl = {s = t.s ++ p.s ++ cl.s ! t.t ! t.a ! p.p ! Statement} ;
-- : Temp -> Pol -> RCl -> RS ;
UseRCl t p rcl = {s = t.s ++ p.s ++ rcl.s ! t.t ! t.a ! p.p} ;
UseRCl t p rcl = {s = \\c => t.s ++ p.s ++ rcl.s ! t.t ! t.a ! p.p ! c} ;
-- AdvS : Adv -> S -> S ; -- then I will go home
AdvS = advS "" ;

View File

@@ -40,14 +40,13 @@ lin there_Adv = ss "" ;
lin and_Conj = {
s1 = [] ;
-- no need for strings here, actual values come from ParamKor.conjTable
-- s2 = \\phono => table {
-- VStar => "고" ;
-- NStar => "하고"} ;
-- no need for string, actual values come from ParamKor.conjTable
s2 = [] ; -- this is only used in the base/cons functions with comma.
-- another application can use commas and just one conjunction.
n = Pl ;
c = And
} ;
lin or_Conj = {s1 = [] ; n = Sg ; c = Or} ;
lin or_Conj = {s1,s2 = [] ; n = Sg ; c = Or} ;
-- lin if_then_Conj = mkConj
-- lin both7and_DConj = mkConj "" "" pl ;
-- lin either7or_DConj = {s2 = \\_ => "" ; s1 = "" ; n = Sg} ;
@@ -102,8 +101,8 @@ lin something_NP = mkNoun "무엇" ;
-- lin before_Prep = mkPrep "" ;
lin behind_Prep = mkPrep "뒤에" False ;
-- lin between_Prep = = mkPrep "" ;
-- lin by8agent_Prep = mkPrep ;
-- lin by8means_Prep = mkPrep ;
lin by8agent_Prep = mkPrep "에 의해" ; -- TODO check
lin by8means_Prep = mkPrep "에 인해" ; -- TODO check
-- lin during_Prep = mkPrep ;
-- lin except_Prep = mkPrep ;
lin for_Prep = mkPrep "에게" ;

View File

@@ -0,0 +1,16 @@
Lang: DetCN (DetQuant IndefArt NumSg) (RelCN (UseN cat_N) (UseRCl (TTAnt TPres ASimul) PPos (RelVP IdRP (UseV laugh_V))))
LangEng: a cat that laughs
LangKor: 웃는 고양이
Lang: AdvNP (DetCN (DetQuant IndefArt NumSg) (RelCN (UseN cat_N) (UseRCl (TTAnt TPres ASimul) PPos (RelVP IdRP (ComplSlash (SlashV2a drink_V2) (MassNP (UseN milk_N))))))) now_Adv
LangEng: a cat that drinks milk now
LangKor: 지금 우유를 마시는 고양이
-- 지금 우유를 마시고 있는 고양이
Lang: PhrUtt NoPConj (UttS (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (ComplSlash (SlashV2a like_V2) (DetCN (DetQuant IndefArt NumPl) (RelCN (UseN cat_N) (ConjRS and_Conj (BaseRS (UseRCl (TTAnt TPres ASimul) PPos (RelVP IdRP (UseV laugh_V))) (UseRCl (TTAnt TPres ASimul) PPos (RelVP IdRP (ComplSlash (SlashV2a drink_V2) (MassNP (UseN milk_N))))))))))))) NoVoc
LangEng: I like cats that laugh and that drink milk
LangKor: 저는 웃 &+ 고 우유를 마시는 고양이를 좋아해요
Lang: PhrUtt NoPConj (UttS (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (ComplSlash (SlashV2a like_V2) (DetCN (DetQuant IndefArt NumPl) (RelCN (UseN cat_N) (UseRCl (TTAnt TPres ASimul) PPos (RelVP IdRP (ComplSlash (SlashV2a like_V2) (UsePron i_Pron)))))))))) NoVoc
LangEng: I like cats that like me
LangKor: 저는 저를 좋아하는 고양이가 좋아요

View File

@@ -15,6 +15,8 @@ LangKor: 고양이가 키가 작아요
Lang: PhrUtt NoPConj (UttS (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (ComplSlash (SlashV2a have_V2) (DetCN (DetQuant IndefArt NumSg) (UseN cat_N)))))) NoVoc
LangKor: 저는 고양이가 있어요
-- Topic + object
-- LangEng: I like cats
Lang: PhrUtt NoPConj (UttS (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (ComplSlash (SlashV2a like_V2) (DetCN (DetQuant IndefArt NumPl) (UseN cat_N)))))) NoVoc
LangKor: 저는 고양이 좋아요
LangKor: 저는 고양이 좋아