Merge pull request #308 from inariksit/korean

Korean
This commit is contained in:
Inari Listenmaa
2020-04-03 20:16:18 +02:00
committed by GitHub
22 changed files with 320 additions and 205 deletions

View File

@@ -1,4 +1,4 @@
--# -path=.:alltenses:prelude:src/korean
--# -path=.:alltenses:prelude:../korean
resource CombinatorsKor = Combinators with
(Cat = CatKor),

View File

@@ -1,5 +1,5 @@
--# -path=.:alltenses:prelude
--# -path=.:alltenses:prelude:../korean
instance SyntaxKor of Syntax =
ConstructorsKor, CatKor, StructuralKor, CombinatorsKor ;
ConstructorsKor, CatKor, StructuralKor, CombinatorsKor **
open MissingKor in {} ;

View File

@@ -1,4 +1,5 @@
concrete AdjectiveKor of Adjective = CatKor ** open ResKor, Prelude in {
concrete AdjectiveKor of Adjective = CatKor **
open ResKor, (AK=AdverbKor), Prelude in {
flags optimize=all_subs ;
@@ -11,11 +12,14 @@ concrete AdjectiveKor of Adjective = CatKor ** open ResKor, Prelude in {
-- : A -> NP -> AP ;
ComparA a np = a ** {
compar = np.s ! Bare
s = \\vf => "더" ++ a.s ! vf ;
compar = glue (np.s ! Bare) "보다" ;
} ;
-- : A2 -> NP -> AP ; -- married to her
-- ComplA2 a2 np = a2 ** { } ;
ComplA2 a2 np = a2 ** {
compar = (AK.PrepNP a2.p2 np).s ;
} ;
-- : A2 -> AP ; -- married to itself
-- ReflA2 a2 = a2 ** { } ;
@@ -24,10 +28,10 @@ concrete AdjectiveKor of Adjective = CatKor ** open ResKor, Prelude in {
UseA2 = PositA ;
-- : A -> AP ; -- warmer
-- UseComparA a = a ** {
-- s = \\af => "???" ++ a.s ! af ;
-- compar = []
-- } ;
UseComparA a = a ** {
s = \\af => "" ++ a.s ! af ;
compar = [] ;
} ;
-- : CAdv -> AP -> NP -> AP ; -- as cool as John
@@ -37,7 +41,6 @@ concrete AdjectiveKor of Adjective = CatKor ** open ResKor, Prelude in {
-- : Ord -> AP ; -- warmest
AdjOrd ord = ord ** {
s = \\_ => ord.s ;
compar = []
} ;

View File

@@ -66,7 +66,7 @@ concrete CatKor of Cat = CommonX ** open ResKor, Prelude in {
Quant = ResKor.Quant ;
Num = ResKor.Num ;
Ord = {
s : Str ; -- AForm => Str ; -- Ord can come from AP and become AP again
s : VForm => Str ; -- Ord can come from AP and become AP again
n : Number -- Ord can come from Num, which has inherent number
} ;
DAP = ResKor.Determiner ;
@@ -116,7 +116,7 @@ concrete CatKor of Cat = CommonX ** open ResKor, Prelude in {
N = ResKor.Noun ;
N2 = ResKor.Noun2 ;
N3 = ResKor.Noun3 ;
PN = ResKor.PNoun ;
PN = ResKor.NounPhrase ;
linref
V, V2, V3, VP = linVerb ;

View File

@@ -1,5 +1,5 @@
concrete ConjunctionKor of Conjunction =
CatKor ** open ResKor, Coordination, Prelude in {
CatKor ** open ResKor, Prelude in {
flags optimize=all_subs ;
@@ -25,31 +25,37 @@ concrete ConjunctionKor of Conjunction =
ConsAdv = consrSS comma ;
ConjAdv = conjunctSS ;
--}
-- Adverb and other simple {s : Str} types.
lincat
[Adv],[AdV],[IAdv] = {s1,s2 : Str} ;
lin
BaseAdv, BaseAdV, BaseIAdv = twoSS ;
ConsAdv, ConsAdV, ConsIAdv = consrSS comma ;
ConjAdv, ConjAdV, ConjIAdv = conjunctDistrSS ;
{-
-- RS depends on X, Y and Z, otherwise exactly like previous.
-- RS can modify CNs, which are open for …, and have inherent …
lincat
[RS] = {s1,s2 : … => Str} ;
lin
BaseRS = twoTable3 … ;
ConsRS = consrTable3 … comma ;
ConjRS = conjunctRSTable ;
-}
lincat
[Adv],[AdV],[IAdv],[RS] = ConjSS ;
lin
BaseAdv, BaseAdV, BaseIAdv, BaseRS = baseSS ;
ConsAdv, ConsAdV, ConsIAdv, ConsRS = consSS ;
ConjAdv, ConjAdV, ConjIAdv, ConjRS = conjSS ;
oper
ConjSS : Type = SS ** {firstSS : ConjType => Str} ;
baseSS : SS -> SS -> ConjSS = \s1,s2 -> s2 ** {
firstSS = mkFirstSS s1 ;
} ;
consSS : SS -> ConjSS -> ConjSS = \s,ss -> ss ** {
firstSS = \\conj =>
mkFirstSS s ! conj ++ ss.firstSS ! conj ;
} ;
conjSS : Conj -> ConjSS -> SS = \co,ss -> {
s = co.s1 ++ ss.firstSS ! co.c ++ ss.s
} ;
oper
mkFirstSS : SS -> ConjType => Str = \s ->
\\conj => glue s.s (conjTable ! NStar ! conj) ;
lincat
[S] = ResKor.Sentence ** {firstS : ConjType => Str} ;
@@ -69,10 +75,10 @@ lin
oper
mkFirstS : ResKor.Sentence -> ConjType => Str = \s ->
\\conj => glue (s.s ! Subord) (conjTable ! NStar ! conj) ;
\\conj => glue (s.s ! WithConj) (conjTable ! NStar ! conj) ;
lincat
[AP] = ResKor.AdjPhrase ** {firstAP : AForm => ConjType => Str} ;
[AP] = ResKor.AdjPhrase ** {firstAP : VForm => ConjType => Str} ;
lin
BaseAP a1 a2 = a2 ** {
@@ -90,10 +96,10 @@ lin
oper
mkFirstAP : ResKor.AdjPhrase -> AForm => ConjType => Str = \ap ->
mkFirstAP : ResKor.AdjPhrase -> VForm => ConjType => Str = \ap ->
\\af,conj => case af of {
AAttr => glue (ap.s ! AAttr) (conjTable ! NStar ! conj) ;
APred _ => glue (ap.s ! APred VStem) (conjTable ! VStar ! conj) } ;
VAttr p => glue (ap.s ! VAttr p) (conjTable ! NStar ! conj) ;
_ => glue (ap.s ! VStem) (conjTable ! VStar ! conj) } ;
{-
lincat
@@ -131,4 +137,5 @@ oper
mkFirstNP : ResKor.NounPhrase -> ConjType => Str = \np ->
\\conj => glue (np.s ! Bare) (conjTable ! NStar ! conj) ;
}

View File

@@ -33,7 +33,7 @@ lin big_A = mkA "크다" ;
-- lin bike_N = mkN "" ;
-- lin bird_N = mkN "" ;
-- lin bite_V2 = mkV2 "" ;
-- lin black_A = mkA "" ;
lin black_A = mkA "검다" ;
-- lin blood_N = mkN "" ;
-- lin blow_V = mkV "" ;
lin blue_A = mkA "푸르다" ;
@@ -72,7 +72,7 @@ lin cat_N = mkN "고양이" ;
-- lin clever_A = mkA "" ;
-- lin close_V2 = mkV2 "" ;
-- lin cloud_N = mkN "" ;
-- lin coat_N = mkN "" ;
lin coat_N = mkN "코트" ;
-- lin cold_A = mkA "" ;
lin come_V = mkV "오다" ;
-- lin computer_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 "" ;
lin like_V2 = mkV2 (mkV "좋다") topic subject ;
-- lin listen_V2 = mkV2 "" ;
-- lin live_V = mkV "";
-- lin liver_N = mkN "" ;
@@ -279,7 +279,7 @@ lin person_N = mkN "사람" ;
-- lin read_V2 = mkV2 "" ;
-- lin ready_A = mkA "" ;
-- lin reason_N = mkN "" ;
-- lin red_A = mkA "" ;
lin red_A = mkA "빨갛다" ;
-- lin religion_N = mkN "" ;
-- lin restaurant_N = mkN "" ;
-- lin river_N = mkN "" ;
@@ -314,7 +314,7 @@ lin see_V2 = mkV2 "보다" ;
-- lin sharp_A = mkA "" ;
-- lin sheep_N = mkN "" fem ;
-- lin ship_N = mkN "" ;
-- lin shirt_N = mkN "" ;
lin shirt_N = mkN "셔츠" ;
-- lin shoe_N = mkN "" ;
-- lin shop_N = mkN "" ;
lin short_A = mkA "키가" small_A ; -- "height is small"

View File

@@ -9,18 +9,12 @@ oper AddAdvQVP : QVP -> IAdv -> QVP = notYet "AddAdvQVP" ;
oper AdjDAP : DAP -> AP -> DAP = notYet "AdjDAP" ;
oper AdnCAdv : CAdv -> AdN = notYet "AdnCAdv" ;
oper AdvAP : AP -> Adv -> AP = notYet "AdvAP" ;
oper AdvCN : CN -> Adv -> CN = notYet "AdvCN" ;
oper AdvIAdv : IAdv -> Adv -> IAdv = notYet "AdvIAdv" ;
oper AdvIP : IP -> Adv -> IP = notYet "AdvIP" ;
oper AdvNP : NP -> Adv -> NP = notYet "AdvNP" ;
oper AdvQVP : VP -> IAdv -> QVP = notYet "AdvQVP" ;
oper AdvSlash : ClSlash -> Adv -> ClSlash = notYet "AdvSlash" ;
oper ApposCN : CN -> NP -> CN = notYet "ApposCN" ;
oper BaseAdV : AdV -> AdV -> ListAdV = notYet "BaseAdV" ;
oper BaseAdv : Adv -> Adv -> ListAdv = notYet "BaseAdv" ;
oper BaseCN : CN -> CN -> ListCN = notYet "BaseCN" ;
oper BaseIAdv : IAdv -> IAdv -> ListIAdv = notYet "BaseIAdv" ;
oper BaseRS : RS -> RS -> ListRS = notYet "BaseRS" ;
oper CAdvAP : CAdv -> AP -> NP -> AP = notYet "CAdvAP" ;
oper CleftAdv : Adv -> S -> Cl = notYet "CleftAdv" ;
oper CleftNP : NP -> RS -> Cl = notYet "CleftNP" ;
@@ -28,7 +22,6 @@ oper CompIAdv : IAdv -> IComp = notYet "CompIAdv" ;
oper CompIP : IP -> IComp = notYet "CompIP" ;
oper ComparAdvAdj : CAdv -> A -> NP -> Adv = notYet "ComparAdvAdj" ;
oper ComparAdvAdjS : CAdv -> A -> S -> Adv = notYet "ComparAdvAdjS" ;
oper ComplA2 : A2 -> NP -> AP = notYet "ComplA2" ;
oper ComplN2 : N2 -> NP -> CN = notYet "ComplN2" ;
oper ComplN3 : N3 -> NP -> N2 = notYet "ComplN3" ;
oper ComplSlashIP : VPSlash -> IP -> QVP = notYet "ComplSlashIP" ;
@@ -36,17 +29,11 @@ oper ComplVA : VA -> AP -> VP = notYet "ComplVA" ;
oper ComplVQ : VQ -> QS -> VP = notYet "ComplVQ" ;
oper ComplVS : VS -> S -> VP = notYet "ComplVS" ;
oper ComplVV : VV -> VP -> VP = notYet "ComplVV" ;
oper ConjAdV : Conj -> ListAdV -> AdV = notYet "ConjAdV" ;
oper ConjAdv : Conj -> ListAdv -> Adv = notYet "ConjAdv" ;
oper ConjCN : Conj -> ListCN -> CN = notYet "ConjCN" ;
oper ConjDet : Conj -> ListDAP -> Det = notYet "ConjDet" ;
oper ConjIAdv : Conj -> ListIAdv -> IAdv = notYet "ConjIAdv" ;
oper ConjRS : Conj -> ListRS -> RS = notYet "ConjRS" ;
oper ConsAdV : AdV -> ListAdV -> ListAdV = notYet "ConsAdV" ;
oper ConsAdv : Adv -> ListAdv -> ListAdv = notYet "ConsAdv" ;
oper ConsCN : CN -> ListCN -> ListCN = notYet "ConsCN" ;
oper ConsIAdv : IAdv -> ListIAdv -> ListIAdv = notYet "ConsIAdv" ;
oper ConsRS : RS -> ListRS -> ListRS = notYet "ConsRS" ;
oper CountNP : Det -> NP -> NP = notYet "CountNP" ;
oper D_0, D_1, D_2, D_3, D_4, D_5, D_6, D_7, D_8, D_9 : Dig = notYet "D_9" ;
oper DetDAP : Det -> DAP = notYet "DetDAP" ;
@@ -85,7 +72,6 @@ oper PositAdAAdj : A -> AdA = notYet "PositAdAAdj" ;
oper PositAdvAdj : A -> Adv = notYet "PositAdvAdj" ;
oper PossNP : CN -> NP -> CN = notYet "PossNP" ;
oper PossPron : Pron -> Quant = notYet "PossPron" ;
oper PredSCVP : SC -> VP -> Cl = notYet "PredSCVP" ;
oper PrepIP : Prep -> IP -> IAdv = notYet "PrepIP" ;
oper ProgrVP : VP -> VP = notYet "ProgrVP" ;
oper QuestCl : Cl -> QCl = notYet "QuestCl" ;
@@ -96,12 +82,8 @@ oper QuestSlash : IP -> ClSlash -> QCl = notYet "QuestSlash" ;
oper QuestVP : IP -> VP -> QCl = notYet "QuestVP" ;
oper ReflA2 : A2 -> AP = notYet "ReflA2" ;
oper ReflVP : VPSlash -> VP = notYet "ReflVP" ;
oper RelCN : CN -> RS -> CN = notYet "RelCN" ;
oper RelCl : Cl -> RCl = notYet "RelCl" ;
oper RelNP : NP -> RS -> NP = notYet "RelNP" ;
oper RelS : S -> RS -> S = notYet "RelS" ;
oper RelSlash : RP -> ClSlash -> RCl = notYet "RelSlash" ;
oper RelVP : RP -> VP -> RCl = notYet "RelVP" ;
oper SSubjS : S -> Subj -> S -> S = notYet "SSubjS" ;
oper SelfAdVVP : VP -> VP = notYet "SelfAdVVP" ;
oper SelfAdvVP : VP -> VP = notYet "SelfAdvVP" ;
@@ -122,22 +104,10 @@ oper SlashVV : VV -> VPSlash -> VPSlash = notYet "SlashVV" ;
oper SubjS : Subj -> S -> Adv = notYet "SubjS" ;
oper Use2N3 : N3 -> N2 = notYet "Use2N3" ;
oper Use3N3 : N3 -> N2 = notYet "Use3N3" ;
oper UseComparA : A -> AP = notYet "UseComparA" ;
oper UsePN : PN -> NP = notYet "UsePN" ;
oper UsePron : Pron -> NP = notYet "UsePron" ;
oper UseRCl : Temp -> Pol -> RCl -> RS = notYet "UseRCl" ;
oper UseSlash : Temp -> Pol -> ClSlash -> SSlash = notYet "UseSlash" ;
oper UttAP : AP -> Utt = notYet "UttAP" ;
oper UttAdv : Adv -> Utt = notYet "UttAdv" ;
oper UttCN : CN -> Utt = notYet "UttCN" ;
oper UttCard : Card -> Utt = notYet "UttCard" ;
oper UttIP : IP -> Utt = notYet "UttIP" ;
oper UttImpPl : Pol -> Imp -> Utt = notYet "UttImpPl" ;
oper UttImpPol : Pol -> Imp -> Utt = notYet "UttImpPol" ;
oper UttImpSg : Pol -> Imp -> Utt = notYet "UttImpSg" ;
oper UttInterj : Interj -> Utt = notYet "UttInterj" ;
oper UttNP : NP -> Utt = notYet "UttNP" ;
oper UttVP : VP -> Utt = notYet "UttVP" ;
oper VPSlashPrep : VP -> Prep -> VPSlash = notYet "VPSlashPrep" ;
oper VocNP : NP -> Voc = notYet "VocNP" ;
oper above_Prep : Prep = notYet "above_Prep" ;

View File

@@ -18,16 +18,15 @@ concrete NounKor of Noun = CatKor ** open ResKor, Prelude in {
IsDig => glue dets cn.c.s ;
NoNum => dets } ;
in case isNum det of {
True => cns ++ detnum ;
False => detnum ++ cns }
True => cn.rs ++ cns ++ detnum ;
False => cn.rs ++ detnum ++ cns }
} ;
-- : PN -> NP ;
-- UsePN pn = pn ** {
-- } ;
UsePN pn = pn ;
-- : Pron -> NP ;
-- UsePron pron = pron ;
UsePron pron = pron ** {empty = []};
-- : Predet -> NP -> NP ; -- only the man
PredetNP predet np = np ** {s =
@@ -48,8 +47,13 @@ concrete NounKor of Noun = CatKor ** open ResKor, Prelude in {
-- PPartNP np v2 = np ** {
-- s = \\c => v2.s ! ??? ++ np.s ! c } ; ----
-- : NP -> Adv -> NP ; -- Paris today ; boys, such as ..
--AdvNP,ExtAdvNP = \np,adv -> np ** {} ;
-- : NP -> Adv -> NP ; -- Paris today
AdvNP np adv = np ** {
s = \\nf => adv.s ++ np.s ! nf
} ; -- TODO test
-- : NP -> Adv -> NP ; -- boys, such as ..
-- ExtAdvNP np adv = np ** {} ;
-- : NP -> RS -> NP ; -- Paris, which is here
-- RelNP np rs = np ** {
@@ -64,9 +68,9 @@ concrete NounKor of Noun = CatKor ** open ResKor, Prelude in {
} ;
-- MassNP : CN -> NP ;
-- MassNP cn = useN cn ** {
-- } ;
MassNP cn = cn ** {
s = \\nf => cn.rs ++ cn.s ! nf
} ;
--2 Determiners
@@ -97,7 +101,11 @@ concrete NounKor of Noun = CatKor ** open ResKor, Prelude in {
NumCard card = card ;
-- : Digits -> Card ;
-- NumDigits dig =
NumDigits dig = baseNum ** {
s = \\_,_ => dig.s ! NCard ;
n = dig.n ;
numtype = IsDig
} ;
-- : Numeral -> Card ;
NumNumeral num = num ;
@@ -115,10 +123,10 @@ concrete NounKor of Noun = CatKor ** open ResKor, Prelude in {
-- } ;
-- : A -> Ord ;
-- OrdSuperl a = {
-- s = \\af => "제일" ++ a.s ! af ;
-- n = Sg -- ?? is this meaningful?
-- } ;
OrdSuperl a = {
s = \\vf => "가장" ++ a.s ! vf ;
n = Sg -- ?? is this meaningful?
} ;
-- One can combine a numeral and a superlative.
@@ -130,10 +138,7 @@ concrete NounKor of Noun = CatKor ** open ResKor, Prelude in {
IndefArt = mkQuant [] [] ;
-- : Pron -> Quant
-- PossPron pron =
-- let p = pron.poss ;
-- in DefArt ** {
-- } ;
PossPron pron = pron.poss ;
--2 Common nouns
@@ -155,23 +160,28 @@ concrete NounKor of Noun = CatKor ** open ResKor, Prelude in {
-- Use3N3 n3 = lin N2 n3 ;
-- : AP -> CN -> CN
AdjCN ap cn = cn ** {
s = \\nf => ap.s ! AAttr ++ cn.s ! nf
s = \\nf => ap.compar ++ ap.s ! VAttr Pos ++ cn.s ! nf
} ;
-- : CN -> RS -> CN ;
-- RelCN cn rs = cn ** {
-- } ;
RelCN cn rs = cn ** {
rs = cn.rs ++ rs.s
} ;
{-
-- : CN -> Adv -> CN ;
AdvCN cn adv = cn ** { } ;
AdvCN cn adv = cn ** {
rs = cn.rs ++ adv.s
} ;
-- Nouns can also be modified by embedded sentences and questions.
-- For some nouns this makes little sense, but we leave this for applications
-- to decide. Sentential complements are defined in VerbKor.
-- : CN -> SC -> CN ; -- question where she sleeps
SentCN cn sc = cn ** { } ;
SentCN cn sc = cn ** {
rs = cn.rs ++ sc.s
} ;
--2 Apposition
@@ -179,8 +189,9 @@ concrete NounKor of Noun = CatKor ** open ResKor, Prelude in {
-- This is certainly overgenerating.
-- : CN -> NP -> CN ; -- city Paris (, numbers x and y)
ApposCN cn np = cn ** { s = } ;
-}
ApposCN cn np = cn ** {
s = \\nf => np.s ! Bare ++ cn.s ! nf -- TODO which form of NP?
} ;
--2 Possessive and partitive constructs

View File

@@ -84,7 +84,6 @@ lin
-- : Sub1000 -> Sub1000 -> Sub1000000 ; -- m * 1000 + n
pot3plus m n = TODO ;
oper
LinDigit : Type = ResKor.Numeral ** {isTwo : Bool ; ten : Str} ;
@@ -123,4 +122,45 @@ oper
} ;
TODO : ResKor.Numeral = mkNum2 "TODO" "TODO" ;
-- numerals as sequences of digits
lincat
Dig = TDigit ;
lin
-- : Dig -> Digits ; -- 8
IDig d = d ;
-- : Dig -> Digits -> Digits ; -- 876
IIDig d i = {
s = \\o => d.s ! NCard ++ BIND ++ i.s ! o ;
n = Pl
} ;
D_0 = mkDig "0" ;
D_1 = mk3Dig "1" "1번째" ResKor.Sg ;
D_2 = mkDig "2" ;
D_3 = mkDig "3" ;
D_4 = mkDig "4" ;
D_5 = mkDig "5" ;
D_6 = mkDig "6" ;
D_7 = mkDig "7" ;
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
oper
mk2Dig : Str -> Str -> TDigit = \c,o -> mk3Dig c o ResKor.Pl ;
mkDig : Str -> TDigit = \c -> mk2Dig c (c + "번째") ;
mk3Dig : Str -> Str -> ResKor.Number -> TDigit = \c,o,n -> {
s = table {NCard => c ; NOrd => o} ;
n = n
} ;
TDigit = {
n : ResKor.Number ;
s : CardOrd => Str
} ;
}

View File

@@ -4,11 +4,16 @@ oper
--2 Parameters
--
-- To abstract over number, valency and (some) case names,
-- To abstract over number, valency and (some) CaseParticle names,
-- we define the following identifiers. The application programmer
-- should always use these constants instead of the constructors
-- defined in $ResKor$.
CaseParticle : Type ; -- Arguments to give to V2, V3
topic : CaseParticle ; -- 은 or 는
subject : CaseParticle ; -- 이 or 가
object : CaseParticle ; -- 을 or 를
noCase : CaseParticle ; -- No case particle
--2 Nouns
@@ -23,8 +28,13 @@ oper
mkA : (kiga : Str) -> (jakda : A) -> A ; -- Compound adjective, e.g. 키가 작다 'short', literally 'height (is) small'. 키가 'height' given as string, 작다 'small' given as preconstructed A.
} ;
-- mkA2 : Str -> Prep -> A2 ;
mkA2 : overload {
mkA2 : Str -> A2 ; -- Regular adjective, given in -다 form, no postposition for complement.
mkA2 : A -> Prep -> A2 ; -- Preconstructed adjective and postposition for complement.
} ;
mkPN : Str -> PN
= \s -> lin PN (mkNoun s) ;
--2 Verbs
-- Verbs
@@ -36,8 +46,9 @@ oper
copula : V ; -- The copula verb ''
mkV2 : overload {
mkV2 : (plain : Str) -> V2 ; -- Regular verb. Takes plain, uninflected -다 form, object particle is 를.
mkV2 : V -> V2 ; -- Takes preconstructed V, object particle is 를.
mkV2 : (plain : Str) -> V2 ; -- Regular verb. Takes plain, uninflected -다 form, subject particle is 가/이 and object particle is 를/을.
mkV2 : V -> V2 ; -- Takes preconstructed V, subject particle is 가/이 and object particle is 를/을.
mkV2 : V -> (subj,obj : CaseParticle) -> V2 ; -- Takes preconstructed V, and subject and object particles. E.g. `mkV2 좋다_V topic subject` for "as for <SUBJ>는, <OBJ>가 is good".
} ;
-- mkV3 : overload {
@@ -91,6 +102,12 @@ oper
-- The definitions should not bother the user of the API. So they are
-- hidden from the document.
CaseParticle : Type = ResKor.NForm ;
topic = Topic ;
subject = Subject ;
object = Object ;
noCase = Bare ;
mkN = overload {
mkN : Str -> N = \s -> lin N (mkNoun s) ;
} ;
@@ -110,6 +127,11 @@ oper
jakda ** {s = \\af => kiga ++ jakda.s ! af} ;
} ;
mkA2 = overload {
mkA2 : Str -> A2 = \s -> lin A2 (atoa2 (mkAdj s)) ;
mkA2 : A -> Prep -> A2 = \a,p -> lin A2 (a ** {p2 = p}) ;
} ;
mkV = overload {
mkV : (plain : Str) -> V = \v -> lin V (mkVerb v) ;
mkV : (nore : Str) -> (hada : V) -> V = \nore,hada -> hada ** {
@@ -124,6 +146,8 @@ oper
mkV2 = overload {
mkV2 : (plain : Str) -> V2 = \v2 -> lin V2 (mkVerb2 v2) ;
mkV2 : V -> V2 = vtov2 ;
mkV2 : V -> (subj,obj : CaseParticle) -> V2 = \v,sc,c2 ->
vtov2 v ** {sc = sc ; c2 = c2} ;
} ;
mkV3 = overload {

Binary file not shown.

View File

@@ -6,20 +6,21 @@ concrete PhraseKor of Phrase = CatKor ** open Prelude, ResKor in {
UttS s = {s = s.s ! Statement} ;
UttQS qs = qs ;
UttIAdv iadv = iadv ;
UttAdv adv = adv ;
UttInterj i = i ;
{-
UttImpSg pol imp =
UttImpPl pol imp =
UttImpPol = UttImpSg ;
UttIP ip = {s = ip.s ! } ;
UttNP np = {s = np.s ! } ;
UttVP vp = {s = } ;
UttAdv adv = {s = } ;
UttCN n = {s = } ;
UttCard n = {s = } ;
UttAP ap = { s = ap.s ! } ;
UttInterj i = i ;
-}
UttIP ip = {s = ip.s ! Bare} ;
UttNP np = {s = np.s ! Bare} ;
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} ;
NoPConj = {s = []} ;
-- PConjConj conj = {s = conj.s1 ++ conj.s2 ! …} ;

View File

@@ -1,22 +1,26 @@
concrete RelativeKor of Relative = CatKor ** open
ResKor, Prelude, (NS=NounKor), (SS=StructuralKor) in {
{-
lin
-- : Cl -> RCl ; -- such that John loves her
-- RelCl cl = ;
RelCl cl = {s = \\t,a,p => cl.s ! t ! a ! p ! Subord} ;
-- : RP -> VP -> RCl ;
RelVP rp vp =
RelVP rp vp = {
s = \\t,a,p => vp.s ! VAttr p -- TODO no tenses yet in the grammar
++ rp.s ;
} ;
-- : RP -> ClSlash -> RCl ; -- whom John loves
RelSlash rp cls =
RelSlash rp cls = {
s = \\t,a,p => cls.s ! t ! a ! p ! Subord
++ rp.s ;
} ;
-- : RP ;
IdRP = {s = ""} ;
-- : Prep -> NP -> RP -> RP ; -- the mother of whom
--FunRP prep np rp = {} ;
-}
}

View File

@@ -13,76 +13,70 @@ oper
origin = NK
} ;
Noun : Type = {
BaseNoun : Type = {
s : NForm => Str ;
p : Phono ;
} ;
Noun : Type = BaseNoun ** {
c : Counter ;
} ;
Noun2 : Type = Noun ; -- TODO eventually more parameters?
Noun3 : Type = Noun ;
CNoun : Type = Noun ** {
rs : Str ; -- Relative clause comes before determiner
} ;
PNoun : Type = Noun ;
mkNoun : Str -> Noun = \str -> {
s = \\cas => str + allomorph cas str ;
p = if_then_else Phono (vowFinal str) Vowel Consonant ;
c = baseCounter
} ;
useN : Noun -> CNoun = \n -> n ;
useN : Noun -> CNoun = \n -> n ** {
rs = []
} ;
---------------------------------------------
-- NP
-- BaseNP : Type = {
-- a : Agreement ;
-- isPron : Bool ;
NounPhrase = BaseNoun ** {
-- empty : Str ; -- standard trick for pro-drop
-- } ;
--
-- emptyNP : NounPhrase = {
-- s = \\_ => [] ;
-- a = Sg3 Masc ;
-- isPron = False ;
-- empty = [] ;
-- } ;
--
-- indeclNP : Str -> NounPhrase = \s -> emptyNP ** {s = \\c => s} ;
--NounPhrase : Type = BaseNP ** {s : NForm => Str} ;
NounPhrase = Noun ;
} ;
--------------------------------------------------------------------------------
-- Pronouns
Pronoun : Type = NounPhrase ** {
-- poss : { -- for PossPron : Pron -> Quant
-- } ;
sp : NForm => Str ;
Pronoun : Type = BaseNoun ** {
poss : Quant ;
} ;
mkPron = overload {
mkPron : (stem,poss : Str) -> Pronoun = \s,poss -> mkNoun s ** {
poss = mkQuant poss (poss ++ "것") ;
} ;
mkPron : (stem : Str) -> Pronoun = \s -> mkNoun s ** {
poss = mkQuant (s + "의") (s + "의" ++ "것") ;
}
} ;
--------------------------------------------------------------------------------
-- Det, Quant, Card, Ord
BaseQuant : Type = {
sp : NForm => Str ;
isPoss : Bool ;
p : Phono
} ;
Determiner : Type = BaseQuant ** {
s : NumOrigin => Str ; -- Chosen by the counter of CN
sp : NForm => Str ;
n : Number ;
numtype : NumType ; -- Whether its Num component is digit, numeral or Sg/Pl
} ;
Quant : Type = BaseQuant ** {
s : Str ;
sp : NForm => Str ;
} ;
Num : Type = {
@@ -104,6 +98,7 @@ oper
} ;
baseQuant : BaseQuant = {
sp = \\_ => [] ;
isPoss = False ;
p = Vowel ;
} ;
@@ -114,6 +109,13 @@ oper
p = (mkNoun sp).p ;
} ;
mkDet : Str -> Number -> Determiner = \s,num -> baseQuant ** {
s = \\_ => (mkNoun s).s ! Bare ; -- NumOrigin irrelevant for non-numbers
sp = (mkNoun s).s ;
n = num ;
numtype = NoNum ;
} ;
plural : NForm => Str = table {
Bare => "들" ;
nf => "들" + allomorph nf "들"
@@ -131,17 +133,20 @@ oper
--------------------------------------------------------------------------------
-- Adjectives
Adjective : Type = {s : AForm => Str} ;
Adjective2 : Type = Adjective ;
Adjective : Type = {s : VForm => Str} ; -- Adjectives are verbs
Adjective2 : Type = Adjective ** {p2 : Postposition} ;
mkAdj : Str -> Adjective = \plain ->
let stem = init plain ;
verb = mkVerb plain ;
in {
s = table { AAttr => add_N stem ;
APred vf => verb.s ! vf }
s = table {
VAttr Pos => add_N stem ; -- Positive Attr form is different in
vf => verb.s ! vf } -- adjectives, otherwise adj forms == verb forms.
} ;
atoa2 : Adjective -> Adjective2 = \a -> a ** {c2=Bare ; p2=emptyPP} ;
AdjPhrase : Type = Adjective ** {compar : Str} ;
--------------------------------------------------------------------------------
-- Verbs
@@ -159,9 +164,6 @@ oper
mkVerb : (plain : Str) -> Verb = \plain ->
let stem = init plain ;
-- plainpres = case vowFinal stem of { -- not used in grammar yet
-- True => add_N stem + "다" ;
-- False => stem + "는다" } ;
informal = add_eo stem ; -- not used in grammar yet
polpres = informal + "요" ;
formalpres = case vowFinal stem of {
@@ -179,15 +181,19 @@ oper
mkVerbReg : (x1,_,_,x4 : Str) -> Verb =
\plain,polite,formal,neg ->
let stem = init plain ;
attrpos = stem + "는" ; -- TODO: ㄹ-irregulars
attrneg = neg ++ "않는" ;
planeg = neg ++ negForms ! Plain ;
polneg = neg ++ negForms ! Polite ;
formneg = neg ++ negForms ! Formal ;
in mkVerbFull stem plain polite formal planeg polneg formneg ;
in mkVerbFull stem attrpos attrneg plain polite formal planeg polneg formneg ;
mkVerbFull : (x1,_,_,_,_,_,x7 : Str) -> Verb =
\stem,plain,polite,formal,planeg,polneg,formneg -> {
mkVerbFull : (x1,_,_,_,_,_,_,_,x9 : Str) -> Verb =
\stem,attrpos,attrneg,plain,polite,formal,planeg,polneg,formneg -> {
s = table {
VStem => stem ;
VAttr Pos => attrpos ;
VAttr Neg => attrneg ;
VF Plain Pos => plain ;
VF Plain Neg => planeg ;
VF Polite Pos => polite ;
@@ -200,6 +206,8 @@ oper
copula : Verb = mkVerbFull
"이"
"이는" -- TODO does this exist?
"아니는" -- TODO does this exist?
"이다"
"이에요"
"입니다"
@@ -209,6 +217,7 @@ oper
copulaAfterVowel : Verb = copula ** {
s = \\vf => case vf of {
VAttr Pos => "는" ; -- TODO just guessing
VF Plain Pos => "다" ;
VF Polite Pos => "예요" ;
_ => copula.s ! vf }
@@ -216,6 +225,8 @@ oper
have_V : Verb = mkVerbFull
"있"
"있는"
"없는"
"있다"
"있어요"
"있습니다"
@@ -302,16 +313,20 @@ oper
QClause : Type = Clause ;
RClause : Type = {s : NForm => Tense => Anteriority => Polarity => Str} ;
RClause : Type = {s : Tense => Anteriority => Polarity => Str} ;
Sentence : Type = {s : ClType => Str} ;
predVP : NounPhrase -> VerbPhrase -> ClSlash = \np,vp -> vp ** {
predVP : NounPhrase -> VerbPhrase -> ClSlash = \np,vp ->
let npstr : Str = np.s ! vp.sc in predVP' npstr vp ;
predVP' : (np : Str) -> VerbPhrase -> ClSlash = \np,vp -> vp ** {
s = \\t,a,p,cltyp =>
let vf = case cltyp of {
Subord => VStem ;
Subord => VAttr p ;
WithConj => VStem ;
_ => VF Polite p } -- TODO: more tenses, politeness
in np.s ! vp.sc
in np
++ vp.nObj -- an object, not copula complement
++ vp.adv
++ vp.s ! vf
@@ -321,5 +336,6 @@ oper
-- linrefs
linVerb : Verb -> Str = \v -> v.s ! linVF ;
linVP : VerbPhrase -> Str = \vp -> vp.nObj ++ vp.adv ++ vp.s ! linVF ;
}

View File

@@ -11,7 +11,7 @@ lin
PredVP = predVP ;
-- : SC -> VP -> Cl ; -- that she goes is good (Saeed p. 94)
--PredSCVP sc vp = ;
PredSCVP sc vp = predVP' sc.s vp ;
--2 Clauses missing object noun phrases
-- : NP -> VPSlash -> ClSlash ;
@@ -35,16 +35,16 @@ lin
ImpVP vp = {s = \\num,pol => linVP (VImp num pol) Statement vp} ;
--2 Embedded sentences
-}
-- : S -> SC ;
EmbedS s = {s = s.s ! True} ; -- choose subordinate
EmbedS s = {s = s.s ! Subord ++ "것이"} ; -- TODO check subject case
-- : QS -> SC ;
-- EmbedQS qs = { } ;
-- : VP -> SC ;
EmbedVP vp = {s = infVP vp} ;
-}
EmbedVP vp = {s = vp.s ! VAttr Pos ++ "것이"} ;
--2 Sentences
-- : Temp -> Pol -> Cl -> S ;
@@ -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 cl = {s = } ;
UseRCl t p rcl = {s = t.s ++ p.s ++ rcl.s ! t.t ! t.a ! p.p} ;
-- AdvS : Adv -> S -> S ; -- then I will go home
AdvS = advS "" ;

View File

@@ -38,7 +38,7 @@ lin there_Adv = ss "" ;
-------
-- Conj
and_Conj = {
lin and_Conj = {
s1 = [] ;
-- no need for strings here, actual values come from ParamKor.conjTable
-- s2 = \\phono => table {
@@ -47,7 +47,7 @@ lin there_Adv = ss "" ;
n = Pl ;
c = And
} ;
-- lin or_Conj = {s2 = \\_ => "" ; s1 = [] ; n = Sg} ;
lin or_Conj = {s1 = [] ; n = Sg ; c = Or} ;
-- lin if_then_Conj = mkConj
-- lin both7and_DConj = mkConj "" "" pl ;
-- lin either7or_DConj = {s2 = \\_ => "" ; s1 = "" ; n = Sg} ;
@@ -68,17 +68,16 @@ lin all_Predet = {s = \\_ => "마다" ; p = Vowel} ;
lin only_Predet = {s = \\_ => "만" ; p = Consonant} ;
--lin most_Predet = {s = ""} ;
{-
lin every_Det = R.defDet [] pl **
{ s = mkVow } ;
lin few_Det = R.indefDet "" pl ;
lin many_Det = R.indefDet "" pl ;
lin much_Det = R.indefDet "" sg ;
lin somePl_Det =
lin someSg_Det =
lin no_Quant =
-}
--lin every_Det = ;
lin few_Det = mkDet "조금" Pl ;
lin many_Det = mkDet "많은" Pl ;
-- lin much_Det = ;
lin somePl_Det = mkDet "어떤" Pl ;
lin someSg_Det = mkDet "어떤" Sg ;
--lin no_Quant =
lin that_Quant = mkQuant "그" "그것" ;
lin this_Quant = mkQuant "이" "이것" ;
{-lin which_IQuant =
@@ -92,11 +91,8 @@ lin everything_NP = defNP "" N.NumSg ;
lin nobody_NP = mkVerb; ""
lin nothing_NP = defNP "" N.NumSg ;
lin somebody_NP = defNP "" N.NumSg ;
lin something_NP = defNP "" N.NumSg ;
oper
defNP : Str -> Num -> NP = {} ;
-}
lin something_NP = mkNoun "무엇" ;
-------
-- Prep
@@ -115,7 +111,7 @@ lin for_Prep = mkPrep "에게" ;
-- lin in8front_Prep = mkPrep "" ;
lin in_Prep = mkPrep "에서" ;
-- lin on_Prep = mkPrep "에서" ;
-- lin part_Prep = mkPrep ;
lin part_Prep = mkPrep "의" ;
lin possess_Prep = mkPrep "의" ;
-- lin through_Prep = mkPrep ;
lin to_Prep = mkPrep "에";
@@ -129,13 +125,15 @@ lin to_Prep = mkPrep "에";
-- Pronouns are closed class, no constructor in ParadigmsKor.
-- it_Pron =
-- i_Pron =
-- youPol_Pron,
-- youSg_Pron =
-- he_Pron =
-- she_Pron =
i_Pron = let iReg : Pronoun = mkPron "저" "제" in
iReg ** {s = table {Subject => "제가"; nf => iReg.s ! nf}
} ;
youPol_Pron = mkPron "당신" ;
youSg_Pron = mkPron "너" ; -- NB. this is very informal, best not used
he_Pron = mkPron "그" ;
she_Pron = mkPron "그녀" ;
-- we_Pron =
-- youPl_Pron =
youPl_Pron = mkPron "너희" ;
-- they_Pron =
--lin whatPl_IP = ;

View File

@@ -1,7 +1,7 @@
--# -path=.:../abstract:../common:../prelude
concrete SymbolKor of Symbol = CatKor **
open Prelude, ParadigmsKor, ResKor, (NS=NounKor) in {
open Prelude, ResKor, (NK=NounKor), (VK=VerbKor) in {
lin
@@ -15,28 +15,40 @@ lin
FloatPN i = mkPN i.s ;
-- : Card -> PN ; -- twelve [as proper name]
NumPN i = mkPN i.s ;
NumPN i = mkPN (i.s ! NK ! Indep) ;
oper
mkPN : Str -> NounPhrase = \s -> {
s = \\_ => s ;
p = Consonant ; -- ??
} ;
{-
lin
-- CNIntNP cn i = {} ;
-- : CN -> Int -> NP
CNIntNP cn i = NK.MassNP (cn ** {
s = \\nf => cn.s ! nf ++ i.s}) ;
-- : Det -> CN -> [Symb] -> NP ; -- (the) (2) numbers x and y
CNSymbNP det cn xs =
let cnSymb = cn ** { comp = cn.comp ++ xs.s }
in NS.DetCN det cnSymb ;
let cnSymb : CN = cn ** {s = \\nf => cn.s ! nf ++ xs.s}
in NK.DetCN det cnSymb ;
-- : CN -> Card -> NP ; -- level five ; level 5
CNNumNP cn i = NS.MassNP (cn ** { comp = cn.comp ++ i.s }) ;
CNNumNP cn i = NK.MassNP (cn ** {
s = \\nf => cn.s ! nf ++ i.s ! cn.c.origin ! Indep}) ;
-- : Symb -> S ;
SymbS sy = {s = } ;
SymbS sy = {s = \\_ => sy.s} ;
-- : Symb -> Card ;
SymbNum sy = { s = sy.s ; n = Pl } ;
SymbNum sy = baseNum ** {s = \\_,_ => sy.s} ;
-- : Symb -> Ord ;
SymbOrd sy = { s =} ;
-}
SymbOrd sy =
let comp : Comp = VK.CompAdv (lin Adv sy)
in {s = comp.s ; n=Pl} ;
lincat
Symb, [Symb] = SS ;

View File

@@ -111,7 +111,7 @@ lin
-- : AP -> Comp ;
CompAP ap = emptyComp ** {
s = \\vf => ap.s ! APred vf
s = \\vf => ap.compar ++ ap.s ! vf
} ;
-- : CN -> Comp ;

View File

@@ -0,0 +1,9 @@
-- Comparatives
-- LangEng: I am smaller than a cat
Lang: PhrUtt NoPConj (UttS (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (UseComp (CompAP (ComparA small_A (DetCN (DetQuant IndefArt NumSg) (UseN cat_N)))))))) NoVoc
LangKor: 제가 고양이 &+ 보다 더 작아요
-- LangEng: I am a woman smaller than a cat
Lang: PhrUtt NoPConj (UttS (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (UseComp (CompCN (AdjCN (ComparA small_A (DetCN (DetQuant IndefArt NumSg) (UseN cat_N))) (UseN woman_N))))))) NoVoc
LangKor: 제가 고양이 &+ 보다 더 작은 여자 &+ 예요

View File

@@ -1,6 +1,6 @@
Lang: PhrUtt NoPConj (UttS (UseCl (TTAnt TPres ASimul) PPos (PredVP (DetCN (DetQuant DefArt NumSg) (UseN cat_N)) (UseComp (CompAdv (PrepNP in_Prep (DetCN (DetQuant DefArt NumSg) (UseN house_N)))))))) NoVoc
LangEng: the cat is in the house
LangKor: 고양이가 집 BIND 에서 있어요
LangKor: 고양이가 집 &+ 에서 있어요
Lang: PhrUtt NoPConj (UttS (UseCl (TTAnt TPres ASimul) PPos (PredVP (DetCN (DetQuant DefArt NumSg) (UseN cat_N)) (UseComp (CompAdv (PrepNP behind_Prep (DetCN (DetQuant DefArt NumSg) (UseN house_N)))))))) NoVoc
LangEng: the cat is behind the house

View File

@@ -9,7 +9,7 @@ Lang: eat_V2
LangKor: 먹어요
Lang: UseComp (CompAP (PositA good_A))
LangKor: 좋
LangKor: 좋
-- Final ㅏ or ㅓ does not repeat itself
Lang: go_V

View File

@@ -0,0 +1,20 @@
-- Subject as subject case
-- LangEng: I see a cat
Lang: PhrUtt NoPConj (UttS (UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (ComplSlash (SlashV2a see_V2) (DetCN (DetQuant IndefArt NumSg) (UseN cat_N)))))) NoVoc
LangKor: 제가 고양이를 봐요
-- Double subject case
-- LangEng: the cat is short
Lang: PhrUtt NoPConj (UttS (UseCl (TTAnt TPres ASimul) PPos (PredVP (DetCN (DetQuant DefArt NumSg) (UseN cat_N)) (UseComp (CompAP (PositA short_A)))))) NoVoc
LangKor: 고양이가 키가 작아요
-- Topic as subject case
-- LangEng: I have a cat
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: 저는 고양이가 있어요
-- 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: 저는 고양이가 좋아요