forked from GitHub/gf-rgl
(May) WIP: Possessive and object pronouns
This commit is contained in:
@@ -11,7 +11,7 @@ lin
|
||||
-- ComparAdvAdjS : CAdv -> A -> S -> Adv ; -- more warmly than he runs
|
||||
|
||||
-- : Prep -> NP -> Adv ;
|
||||
PrepNP = cc2 ;
|
||||
PrepNP prep np = {s = applyPrep prep np} ;
|
||||
|
||||
-- Adverbs can be modified by 'adadjectives', just like adjectives.
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ lin drink_V2 = mkV2 "minum" ;
|
||||
|
||||
-- lin ear_N = mkN "" ;
|
||||
-- lin earth_N = mkN "" ;
|
||||
-- lin eat_V2 = mkV2 "" ;
|
||||
lin eat_V2 = mkV2 "makan" ;
|
||||
-- lin egg_N = mkN "" ;
|
||||
-- lin empty_A = mkA "" ;
|
||||
-- lin enemy_N = mkN "" ;
|
||||
@@ -170,7 +170,7 @@ lin green_A = mkA "hijau" ;
|
||||
-- lin heart_N = mkN "" ;
|
||||
-- lin heavy_A = mkA "" ;
|
||||
-- lin hill_N = mkN "" ;
|
||||
-- lin hit_V2 = mkV2 "" ;
|
||||
lin hit_V2 = mkV2 "pukul" ;
|
||||
-- lin hold_V2 = mkV2 "" ;
|
||||
-- lin hope_VS = mkV "" ;
|
||||
-- lin horn_N = mkN "" ;
|
||||
@@ -276,7 +276,7 @@ lin person_N = mkN "orang" ;
|
||||
-- lin radio_N = mkN "" ;
|
||||
-- lin rain_N = mkN "" ;
|
||||
-- lin rain_V0 = mkV "" ;
|
||||
-- lin read_V2 = mkV2 "" ;
|
||||
lin read_V2 = mkV2 "baca" ;
|
||||
-- lin ready_A = mkA "" ;
|
||||
-- lin reason_N = mkN "" ;
|
||||
-- lin red_A = mkA "" ;
|
||||
|
||||
@@ -7,13 +7,11 @@ concrete NounMay of Noun = CatMay ** open ResMay, Prelude in {
|
||||
--2 Noun phrases
|
||||
|
||||
-- : Det -> CN -> NP
|
||||
DetCN det cn = {
|
||||
s =
|
||||
case det.isPoss of {
|
||||
True => cn.s ! NF det.n (Poss P3) ; -- TODO add possessive determiners
|
||||
False => cn.s ! NF det.n Bare }
|
||||
++ det.s ;
|
||||
p = P3
|
||||
DetCN det cn = emptyNP ** {
|
||||
s = \\poss => case det.poss of {
|
||||
Bare => cn.s ! NF det.n poss ;
|
||||
_ => cn.s ! NF det.n det.poss -- TODO check if this make sense
|
||||
} ++ det.s ;
|
||||
} ;
|
||||
|
||||
-- : PN -> NP ;
|
||||
@@ -21,7 +19,10 @@ concrete NounMay of Noun = CatMay ** open ResMay, Prelude in {
|
||||
-- } ;
|
||||
|
||||
-- : Pron -> NP ;
|
||||
-- UsePron pron = pron ;
|
||||
UsePron pron = pron ** {
|
||||
s = \\_ => pron.s ;
|
||||
a = IsPron pron.p ;
|
||||
};
|
||||
|
||||
-- : Predet -> NP -> NP ; -- only the man
|
||||
-- PredetNP predet np =
|
||||
@@ -39,19 +40,19 @@ concrete NounMay of Noun = CatMay ** open ResMay, Prelude in {
|
||||
|
||||
-- : NP -> RS -> NP ; -- Paris, which is here
|
||||
RelNP np rs = np ** {
|
||||
s = np.s ++ rs.s ! np.p
|
||||
s = \\poss => np.s ! poss ++ rs.s ! agr2p np.a
|
||||
} ;
|
||||
|
||||
-- Determiners can form noun phrases directly.
|
||||
|
||||
-- : Det -> NP ;
|
||||
-- DetNP det = emptyNP ** {
|
||||
-- } ;
|
||||
DetNP det = emptyNP ** {
|
||||
s = \\_ => det.s ;
|
||||
} ;
|
||||
|
||||
-- MassNP : CN -> NP ;
|
||||
MassNP cn = {
|
||||
s = cn.s ! NF Sg Bare ;
|
||||
p = P3
|
||||
MassNP cn = emptyNP ** {
|
||||
s = \\poss => cn.s ! NF Sg poss
|
||||
} ;
|
||||
|
||||
--2 Determiners
|
||||
@@ -60,9 +61,10 @@ concrete NounMay of Noun = CatMay ** open ResMay, Prelude in {
|
||||
-- quantifier and an optional numeral can be discerned.
|
||||
|
||||
-- : Quant -> Num -> Det ;
|
||||
DetQuant quant num = quant ** {
|
||||
n = num.n
|
||||
} ;
|
||||
DetQuant quant num = quant ** {
|
||||
s = quant.s ++ num.s ! Attrib ;
|
||||
n = num.n
|
||||
} ;
|
||||
|
||||
-- : Quant -> Num -> Ord -> Det ; -- these five best
|
||||
-- DetQuantOrd quant num ord =
|
||||
@@ -102,8 +104,6 @@ concrete NounMay of Noun = CatMay ** open ResMay, Prelude in {
|
||||
|
||||
-- : A -> Ord ;
|
||||
-- OrdSuperl a = {
|
||||
-- s = \\af => "제일" ++ a.s ! af ;
|
||||
-- n = Sg -- ?? is this meaningful?
|
||||
-- } ;
|
||||
|
||||
-- One can combine a numeral and a superlative.
|
||||
@@ -112,16 +112,16 @@ concrete NounMay of Noun = CatMay ** open ResMay, Prelude in {
|
||||
-- OrdNumeralSuperl num a = num ** { } ;
|
||||
|
||||
-- : Quant
|
||||
DefArt = baseQuant ** {sp = \\_ => []} ;
|
||||
DefArt = mkQuant [] ;
|
||||
|
||||
-- : Quant
|
||||
IndefArt = baseQuant ** {sp = \\_ => []} ;
|
||||
IndefArt = mkQuant [] ;
|
||||
|
||||
-- : Pron -> Quant
|
||||
-- PossPron pron =
|
||||
-- let p = pron.poss ;
|
||||
-- in DefArt ** {
|
||||
-- } ;
|
||||
PossPron pron = mkQuant pron.s ** {
|
||||
poss = Bare ; -- this becomes "kucing dia". for "kucingnya", use PossNP.
|
||||
} ;
|
||||
|
||||
|
||||
--2 Common nouns
|
||||
|
||||
@@ -130,7 +130,14 @@ concrete NounMay of Noun = CatMay ** open ResMay, Prelude in {
|
||||
UseN,UseN2 = ResMay.useN ;
|
||||
|
||||
-- : N2 -> NP -> CN ;
|
||||
-- ComplN2 n2 np =
|
||||
ComplN2 n2 np = {
|
||||
s = \\nf =>
|
||||
case <n2.c2.isPoss, np.a, nf> of {
|
||||
<True, IsPron p, NF num _>
|
||||
=> n2.s ! NF num (Poss p) ++ np.empty ;
|
||||
_ => n2.s ! nf ++ applyPrep n2.c2 np
|
||||
}
|
||||
} ;
|
||||
|
||||
-- : N3 -> NP -> N2 ; -- distance from this city (to Paris)
|
||||
-- ComplN3 n3 np =
|
||||
@@ -173,8 +180,13 @@ concrete NounMay of Noun = CatMay ** open ResMay, Prelude in {
|
||||
--2 Possessive and partitive constructs
|
||||
|
||||
-- : PossNP : CN -> NP -> CN ;
|
||||
-- PossNP cn np = cn ** {
|
||||
-- } ;
|
||||
PossNP cn np = cn ** {
|
||||
s = \\nf => case <np.a, nf> of {
|
||||
<IsPron p, NF num _>
|
||||
=> cn.s ! NF num (Poss p) ++ np.empty ;
|
||||
_ => cn.s ! nf ++ np.s ! Bare
|
||||
}
|
||||
} ;
|
||||
|
||||
-- : CN -> NP -> CN ; -- glass of wine / two kilos of red apples
|
||||
-- PartNP cn np = cn ** {
|
||||
|
||||
@@ -93,8 +93,8 @@ oper
|
||||
|
||||
|
||||
mkN2 = overload {
|
||||
mkN2 : Str -> N2 = \s -> lin N2 (mkNoun s) ;
|
||||
mkN2 : N -> N2 = \n -> lin N2 n ;
|
||||
mkN2 : Str -> N2 = \s -> lin N2 (mkNoun s ** {c2 = emptyPrep}) ;
|
||||
mkN2 : N -> N2 = \n -> lin N2 (n ** {c2 = emptyPrep}) ;
|
||||
} ;
|
||||
|
||||
-- mkPN = overload {
|
||||
|
||||
@@ -79,6 +79,8 @@ param
|
||||
|
||||
NForm = NF Number Possession ;
|
||||
|
||||
NPAgr = NotPron | IsPron Person ;
|
||||
|
||||
oper
|
||||
poss2str : Possession -> Str = \p -> case p of {
|
||||
Bare => [] ;
|
||||
@@ -89,6 +91,10 @@ oper
|
||||
|
||||
duplicate : Str -> Str = \s -> s + "-" + s ;
|
||||
|
||||
agr2p : NPAgr -> Person = \a -> case a of {
|
||||
NotPron => P3 ;
|
||||
IsPron p => p
|
||||
} ;
|
||||
--------------------------------------------------------------------------------
|
||||
-- Numerals
|
||||
|
||||
|
||||
@@ -6,13 +6,13 @@ concrete PhraseMay of Phrase = CatMay ** open Prelude, ResMay in {
|
||||
UttS s = s ;
|
||||
UttQS qs = qs ;
|
||||
UttIAdv iadv = iadv ;
|
||||
UttNP np = {s = np.s ! Bare} ;
|
||||
{-
|
||||
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 = } ;
|
||||
|
||||
@@ -7,8 +7,8 @@ oper
|
||||
Noun : Type = {
|
||||
s : NForm => Str
|
||||
} ;
|
||||
Noun2 : Type = Noun ; -- TODO eventually more parameters?
|
||||
Noun3 : Type = Noun ;
|
||||
Noun2 : Type = Noun ** {c2 : Preposition} ;
|
||||
Noun3 : Type = Noun2 ** {c3 : Preposition} ;
|
||||
|
||||
CNoun : Type = Noun ** {
|
||||
} ;
|
||||
@@ -25,29 +25,40 @@ oper
|
||||
useN : Noun -> CNoun = \n -> n ;
|
||||
|
||||
---------------------------------------------
|
||||
-- Pronoun
|
||||
|
||||
Pronoun : Type = {
|
||||
s : Str ;
|
||||
p : Person ; -- for relative clauses
|
||||
empty : Str ; -- need to avoid GF being silly. See https://inariksit.github.io/gf/2018/08/28/gf-gotchas.html#metavariables-or-those-question-marks-that-appear-when-parsing
|
||||
} ;
|
||||
|
||||
mkPron : Str -> Person -> Pronoun = \str,p -> {
|
||||
s = str ;
|
||||
p = p ;
|
||||
empty = []
|
||||
} ;
|
||||
---------------------------------------------
|
||||
-- NP
|
||||
|
||||
NounPhrase = {
|
||||
s : Str ;
|
||||
p : Person -- for relative clauses
|
||||
NounPhrase : Type = {
|
||||
s : Possession => Str ; -- maybe need to keep +nya etc. open for becoming possessed? TODO check
|
||||
a : NPAgr ; -- NP can be made out of nouns and pronouns, need to retain its origin
|
||||
empty : Str ; -- need to avoid GF being silly. See https://inariksit.github.io/gf/2018/08/28/gf-gotchas.html#metavariables-or-those-question-marks-that-appear-when-parsing
|
||||
} ;
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Pronouns
|
||||
|
||||
Pronoun : Type = NounPhrase ** {
|
||||
-- poss : { -- for PossPron : Pron -> Quant
|
||||
-- } ;
|
||||
sp : NForm => Str ;
|
||||
emptyNP : NounPhrase = {
|
||||
s = \\_ => [] ;
|
||||
a = NotPron ;
|
||||
empty = []
|
||||
} ;
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Det, Quant, Card, Ord
|
||||
|
||||
BaseQuant : Type = {
|
||||
s : Str ;
|
||||
isPoss : Bool
|
||||
poss : Possession ;
|
||||
} ;
|
||||
|
||||
Determiner : Type = BaseQuant ** {
|
||||
@@ -77,7 +88,7 @@ oper
|
||||
|
||||
baseQuant : BaseQuant = {
|
||||
s = [] ;
|
||||
isPoss = False ;
|
||||
poss = Bare ;
|
||||
} ;
|
||||
|
||||
mkQuant : Str -> Quant = \str -> baseQuant ** {
|
||||
@@ -85,22 +96,34 @@ oper
|
||||
sp = \\_ => str
|
||||
} ;
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
-- Prepositions
|
||||
|
||||
Preposition : Type = {
|
||||
s : Str ; -- dengan
|
||||
obj : Person => Str -- dengan+nya -- needed in relative clauses to refer to the object
|
||||
s : Str ; -- dengan
|
||||
obj : Person => Str ; -- dengan+nya -- needed in relative clauses to refer to the object
|
||||
isPoss : Bool ;
|
||||
} ;
|
||||
|
||||
mkPrep : Str -> Preposition = \dengan -> {
|
||||
s = dengan ;
|
||||
obj = \\p => dengan + poss2str (Poss p)
|
||||
obj = \\p => dengan + poss2str (Poss p) ;
|
||||
isPoss = False ;
|
||||
} ;
|
||||
|
||||
emptyPrep : Preposition = {
|
||||
s = [] ;
|
||||
obj = \\_ => []
|
||||
obj = table {
|
||||
P1 => BIND ++ "ku" ;
|
||||
P2 => BIND ++ "mu" ;
|
||||
P3 => BIND ++ "nya" } ;
|
||||
isPoss = True ;
|
||||
} ;
|
||||
|
||||
applyPrep : Preposition -> NounPhrase -> Str = \prep,np ->
|
||||
case np.a of {
|
||||
IsPron p => prep.obj ! p ++ np.empty ;
|
||||
NotPron => prep.s ++ np.s ! Bare
|
||||
} ;
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
@@ -198,7 +221,7 @@ oper
|
||||
Sentence : Type = {s : Str} ;
|
||||
|
||||
predVP : NounPhrase -> VerbPhrase -> Clause = \np,vp -> {
|
||||
subj = np.s ;
|
||||
subj = np.s ! Bare ;
|
||||
pred = vp.s
|
||||
} ;
|
||||
|
||||
|
||||
@@ -119,14 +119,14 @@ lin with_Prep = mkPrep "dengan" ;
|
||||
|
||||
-- Pronouns are closed class, no constructor in ParadigmsMay.
|
||||
-- it_Pron =
|
||||
-- i_Pron =
|
||||
-- youPol_Pron,
|
||||
-- youSg_Pron =
|
||||
-- he_Pron =
|
||||
-- she_Pron =
|
||||
-- we_Pron =
|
||||
-- youPl_Pron =
|
||||
-- they_Pron =
|
||||
lin i_Pron = mkPron "saya" P1 ;
|
||||
-- lin youPol_Pron = mkPron "" P3 ;
|
||||
-- lin youSg_Pron =
|
||||
lin he_Pron = mkPron "dia" P3 ;
|
||||
lin she_Pron = mkPron "dia" P3 ;
|
||||
lin we_Pron = mkPron "kami" P1 ;
|
||||
-- lin youPl_Pron =
|
||||
lin they_Pron = mkPron "mereka" P3 ;
|
||||
|
||||
--lin whatPl_IP = ;
|
||||
--lin whatSg_IP = :
|
||||
|
||||
@@ -43,7 +43,7 @@ lin
|
||||
|
||||
-- : V3 -> NP -> VPSlash ; -- give it (to her)
|
||||
Slash2V3 v3 dobj = useV {
|
||||
s = \\vf => v3.s ! vf ++ v3.c2.s ++ dobj.s
|
||||
s = \\vf => v3.s ! vf ++ applyPrep v3.c2 dobj
|
||||
} ** {
|
||||
c2 = v3.c3 -- Now the VPSlash is missing only the indirect object
|
||||
} ;
|
||||
@@ -66,7 +66,7 @@ lin
|
||||
-}
|
||||
-- : VPSlash -> NP -> VP
|
||||
ComplSlash vps np = vps ** {
|
||||
s = \\vf,pol => vps.s ! vf ! pol ++ vps.c2.s ++ np.s
|
||||
s = \\vf,pol => vps.s ! vf ! pol ++ applyPrep vps.c2 np
|
||||
} ;
|
||||
|
||||
-- : VV -> VPSlash -> VPSlash ;
|
||||
@@ -111,9 +111,12 @@ lin
|
||||
CompCN cn = useComp (cn.s ! NF Sg Bare) ;
|
||||
|
||||
-- NP -> Comp ;
|
||||
CompNP np = useComp np.s ;
|
||||
CompNP np = useComp (np.s ! Bare) ;
|
||||
|
||||
-- : Adv -> Comp ;
|
||||
--"Both bukan and tidak may negate prepositional phrases. The choice of either
|
||||
--depends on whether it is the noun within the phrase that is being negated
|
||||
--or the implied verb associated with the phrase." Mintz p. 281 (10.1.4)
|
||||
CompAdv adv = useV {s = \\_ => adv.s} ;
|
||||
|
||||
-- : VP -- Copula alone;
|
||||
|
||||
53
src/malay/unittest/pronouns.gftest
Normal file
53
src/malay/unittest/pronouns.gftest
Normal file
@@ -0,0 +1,53 @@
|
||||
----------
|
||||
-- Objects
|
||||
|
||||
-- that cat is with me
|
||||
Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (DetCN (DetQuant that_Quant NumSg) (UseN cat_N)) (UseComp (CompAdv (PrepNP with_Prep (UsePron i_Pron)))))
|
||||
LangEng: that cat is with me
|
||||
LangMay: kucing itu denganku
|
||||
|
||||
-- my cats are with that person
|
||||
Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (DetCN (DetQuant IndefArt NumPl) (PossNP (UseN cat_N) (UsePron i_Pron))) (UseComp (CompAdv (PrepNP with_Prep (DetCN (DetQuant that_Quant NumSg) (UseN person_N))))))
|
||||
LangMay: kucing-kucingku dengan orang itu
|
||||
|
||||
-- I hit him/her
|
||||
-- the &+ is a magic token, it will render in applications as "memukulnya"
|
||||
Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (ComplSlash (SlashV2a hit_V2) (UsePron he_Pron)))
|
||||
LangMay: saya memukul &+ nya
|
||||
|
||||
-- I hit that person
|
||||
Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (UsePron i_Pron) (ComplSlash (SlashV2a hit_V2) (DetCN (DetQuant that_Quant NumSg) (UseN person_N))))
|
||||
LangMay: saya memukul orang itu
|
||||
|
||||
-------------
|
||||
-- Possession
|
||||
|
||||
-- that cat is mine
|
||||
Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (DetCN (DetQuant that_Quant NumSg) (UseN cat_N)) (UseComp (CompNP (DetNP (DetQuant (PossPron i_Pron) NumSg)))))
|
||||
LangMay: kucing itu saya
|
||||
|
||||
-- his/her cat is green
|
||||
Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (DetCN (DetQuant (PossPron he_Pron) NumSg) (UseN cat_N)) (UseComp (CompAP (PositA green_A))))
|
||||
LangMay: kucing dia hijau
|
||||
|
||||
-- I read his/her father's book
|
||||
Lang: UseCl (TTAnt TPast ASimul) PPos (PredVP (UsePron i_Pron) (ComplSlash (SlashV2a read_V2) (DetCN (DetQuant DefArt NumSg) (PossNP (UseN book_N) (DetCN (DetQuant DefArt NumSg) (PossNP (UseN2 father_N2) (UsePron she_Pron)))))))
|
||||
LangMay: saya membaca buku bapanya
|
||||
|
||||
-- the cat buys his/her book -- two variants
|
||||
Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (DetCN (DetQuant that_Quant NumSg) (UseN cat_N)) (ComplSlash (SlashV2a buy_V2) (DetCN (DetQuant (PossPron she_Pron) NumSg) (UseN book_N))))
|
||||
LangMay: kucing itu membeli buku dia
|
||||
|
||||
Lang: UseCl (TTAnt TPres ASimul) PPos (PredVP (DetCN (DetQuant that_Quant NumSg) (UseN cat_N)) (ComplSlash (SlashV2a buy_V2) (DetCN (DetQuant IndefArt NumSg) (PossNP (UseN book_N) (UsePron she_Pron)))))
|
||||
LangMay: kucing itu membeli bukunya
|
||||
|
||||
-- Only the noun phrase
|
||||
Lang: MassNP (PossNP (UseN book_N) (UsePron he_Pron))
|
||||
LangMay: bukunya
|
||||
|
||||
Lang: DetCN (DetQuant (PossPron he_Pron) NumSg) (UseN book_N)
|
||||
LangMay: buku dia
|
||||
|
||||
-- For non-pronoun NPs, only this variant
|
||||
Lang: MassNP (PossNP (UseN book_N) (DetCN (DetQuant DefArt NumSg) (UseN cat_N)))
|
||||
LangMay: buku kucing
|
||||
Reference in New Issue
Block a user