1
0
forked from GitHub/gf-rgl

(May) WIP: Possessive and object pronouns

This commit is contained in:
Inari Listenmaa
2020-08-19 22:02:02 +02:00
parent 20483a23b1
commit 014c3569eb
10 changed files with 164 additions and 67 deletions

View File

@@ -11,7 +11,7 @@ lin
-- ComparAdvAdjS : CAdv -> A -> S -> Adv ; -- more warmly than he runs -- ComparAdvAdjS : CAdv -> A -> S -> Adv ; -- more warmly than he runs
-- : Prep -> NP -> Adv ; -- : Prep -> NP -> Adv ;
PrepNP = cc2 ; PrepNP prep np = {s = applyPrep prep np} ;
-- Adverbs can be modified by 'adadjectives', just like adjectives. -- Adverbs can be modified by 'adadjectives', just like adjectives.

View File

@@ -105,7 +105,7 @@ lin drink_V2 = mkV2 "minum" ;
-- lin ear_N = mkN "" ; -- lin ear_N = mkN "" ;
-- lin earth_N = mkN "" ; -- lin earth_N = mkN "" ;
-- lin eat_V2 = mkV2 "" ; lin eat_V2 = mkV2 "makan" ;
-- lin egg_N = mkN "" ; -- lin egg_N = mkN "" ;
-- lin empty_A = mkA "" ; -- lin empty_A = mkA "" ;
-- lin enemy_N = mkN "" ; -- lin enemy_N = mkN "" ;
@@ -170,7 +170,7 @@ lin green_A = mkA "hijau" ;
-- lin heart_N = mkN "" ; -- lin heart_N = mkN "" ;
-- lin heavy_A = mkA "" ; -- lin heavy_A = mkA "" ;
-- lin hill_N = mkN "" ; -- lin hill_N = mkN "" ;
-- lin hit_V2 = mkV2 "" ; lin hit_V2 = mkV2 "pukul" ;
-- lin hold_V2 = mkV2 "" ; -- lin hold_V2 = mkV2 "" ;
-- lin hope_VS = mkV "" ; -- lin hope_VS = mkV "" ;
-- lin horn_N = mkN "" ; -- lin horn_N = mkN "" ;
@@ -276,7 +276,7 @@ lin person_N = mkN "orang" ;
-- lin radio_N = mkN "" ; -- lin radio_N = mkN "" ;
-- lin rain_N = mkN "" ; -- lin rain_N = mkN "" ;
-- lin rain_V0 = mkV "" ; -- lin rain_V0 = mkV "" ;
-- lin read_V2 = mkV2 "" ; lin read_V2 = mkV2 "baca" ;
-- lin ready_A = mkA "" ; -- lin ready_A = mkA "" ;
-- lin reason_N = mkN "" ; -- lin reason_N = mkN "" ;
-- lin red_A = mkA "" ; -- lin red_A = mkA "" ;

View File

@@ -7,13 +7,11 @@ concrete NounMay of Noun = CatMay ** open ResMay, Prelude in {
--2 Noun phrases --2 Noun phrases
-- : Det -> CN -> NP -- : Det -> CN -> NP
DetCN det cn = { DetCN det cn = emptyNP ** {
s = s = \\poss => case det.poss of {
case det.isPoss of { Bare => cn.s ! NF det.n poss ;
True => cn.s ! NF det.n (Poss P3) ; -- TODO add possessive determiners _ => cn.s ! NF det.n det.poss -- TODO check if this make sense
False => cn.s ! NF det.n Bare } } ++ det.s ;
++ det.s ;
p = P3
} ; } ;
-- : PN -> NP ; -- : PN -> NP ;
@@ -21,7 +19,10 @@ concrete NounMay of Noun = CatMay ** open ResMay, Prelude in {
-- } ; -- } ;
-- : Pron -> NP ; -- : Pron -> NP ;
-- UsePron pron = pron ; UsePron pron = pron ** {
s = \\_ => pron.s ;
a = IsPron pron.p ;
};
-- : Predet -> NP -> NP ; -- only the man -- : Predet -> NP -> NP ; -- only the man
-- PredetNP predet np = -- PredetNP predet np =
@@ -39,19 +40,19 @@ concrete NounMay of Noun = CatMay ** open ResMay, Prelude in {
-- : NP -> RS -> NP ; -- Paris, which is here -- : NP -> RS -> NP ; -- Paris, which is here
RelNP np rs = np ** { 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. -- Determiners can form noun phrases directly.
-- : Det -> NP ; -- : Det -> NP ;
-- DetNP det = emptyNP ** { DetNP det = emptyNP ** {
-- } ; s = \\_ => det.s ;
} ;
-- MassNP : CN -> NP ; -- MassNP : CN -> NP ;
MassNP cn = { MassNP cn = emptyNP ** {
s = cn.s ! NF Sg Bare ; s = \\poss => cn.s ! NF Sg poss
p = P3
} ; } ;
--2 Determiners --2 Determiners
@@ -61,6 +62,7 @@ concrete NounMay of Noun = CatMay ** open ResMay, Prelude in {
-- : Quant -> Num -> Det ; -- : Quant -> Num -> Det ;
DetQuant quant num = quant ** { DetQuant quant num = quant ** {
s = quant.s ++ num.s ! Attrib ;
n = num.n n = num.n
} ; } ;
@@ -102,8 +104,6 @@ concrete NounMay of Noun = CatMay ** open ResMay, Prelude in {
-- : A -> Ord ; -- : A -> Ord ;
-- OrdSuperl a = { -- OrdSuperl a = {
-- s = \\af => "제일" ++ a.s ! af ;
-- n = Sg -- ?? is this meaningful?
-- } ; -- } ;
-- One can combine a numeral and a superlative. -- 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 ** { } ; -- OrdNumeralSuperl num a = num ** { } ;
-- : Quant -- : Quant
DefArt = baseQuant ** {sp = \\_ => []} ; DefArt = mkQuant [] ;
-- : Quant -- : Quant
IndefArt = baseQuant ** {sp = \\_ => []} ; IndefArt = mkQuant [] ;
-- : Pron -> Quant -- : Pron -> Quant
-- PossPron pron = PossPron pron = mkQuant pron.s ** {
-- let p = pron.poss ; poss = Bare ; -- this becomes "kucing dia". for "kucingnya", use PossNP.
-- in DefArt ** { } ;
-- } ;
--2 Common nouns --2 Common nouns
@@ -130,7 +130,14 @@ concrete NounMay of Noun = CatMay ** open ResMay, Prelude in {
UseN,UseN2 = ResMay.useN ; UseN,UseN2 = ResMay.useN ;
-- : N2 -> NP -> CN ; -- : 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) -- : N3 -> NP -> N2 ; -- distance from this city (to Paris)
-- ComplN3 n3 np = -- ComplN3 n3 np =
@@ -173,8 +180,13 @@ concrete NounMay of Noun = CatMay ** open ResMay, Prelude in {
--2 Possessive and partitive constructs --2 Possessive and partitive constructs
-- : PossNP : CN -> NP -> CN ; -- : 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 -- : CN -> NP -> CN ; -- glass of wine / two kilos of red apples
-- PartNP cn np = cn ** { -- PartNP cn np = cn ** {

View File

@@ -93,8 +93,8 @@ oper
mkN2 = overload { mkN2 = overload {
mkN2 : Str -> N2 = \s -> lin N2 (mkNoun s) ; mkN2 : Str -> N2 = \s -> lin N2 (mkNoun s ** {c2 = emptyPrep}) ;
mkN2 : N -> N2 = \n -> lin N2 n ; mkN2 : N -> N2 = \n -> lin N2 (n ** {c2 = emptyPrep}) ;
} ; } ;
-- mkPN = overload { -- mkPN = overload {

View File

@@ -79,6 +79,8 @@ param
NForm = NF Number Possession ; NForm = NF Number Possession ;
NPAgr = NotPron | IsPron Person ;
oper oper
poss2str : Possession -> Str = \p -> case p of { poss2str : Possession -> Str = \p -> case p of {
Bare => [] ; Bare => [] ;
@@ -89,6 +91,10 @@ oper
duplicate : Str -> Str = \s -> s + "-" + s ; duplicate : Str -> Str = \s -> s + "-" + s ;
agr2p : NPAgr -> Person = \a -> case a of {
NotPron => P3 ;
IsPron p => p
} ;
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- Numerals -- Numerals

View File

@@ -6,13 +6,13 @@ concrete PhraseMay of Phrase = CatMay ** open Prelude, ResMay in {
UttS s = s ; UttS s = s ;
UttQS qs = qs ; UttQS qs = qs ;
UttIAdv iadv = iadv ; UttIAdv iadv = iadv ;
UttNP np = {s = np.s ! Bare} ;
{- {-
UttImpSg pol imp = UttImpSg pol imp =
UttImpPl pol imp = UttImpPl pol imp =
UttImpPol = UttImpSg ; UttImpPol = UttImpSg ;
UttIP ip = {s = ip.s ! } ; UttIP ip = {s = ip.s ! } ;
UttNP np = {s = np.s ! } ;
UttVP vp = {s = } ; UttVP vp = {s = } ;
UttAdv adv = {s = } ; UttAdv adv = {s = } ;
UttCN n = {s = } ; UttCN n = {s = } ;

View File

@@ -7,8 +7,8 @@ oper
Noun : Type = { Noun : Type = {
s : NForm => Str s : NForm => Str
} ; } ;
Noun2 : Type = Noun ; -- TODO eventually more parameters? Noun2 : Type = Noun ** {c2 : Preposition} ;
Noun3 : Type = Noun ; Noun3 : Type = Noun2 ** {c3 : Preposition} ;
CNoun : Type = Noun ** { CNoun : Type = Noun ** {
} ; } ;
@@ -25,29 +25,40 @@ oper
useN : Noun -> CNoun = \n -> n ; 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 -- NP
NounPhrase = { NounPhrase : Type = {
s : Str ; s : Possession => Str ; -- maybe need to keep +nya etc. open for becoming possessed? TODO check
p : Person -- for relative clauses 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
} ; } ;
-------------------------------------------------------------------------------- emptyNP : NounPhrase = {
-- Pronouns s = \\_ => [] ;
a = NotPron ;
Pronoun : Type = NounPhrase ** { empty = []
-- poss : { -- for PossPron : Pron -> Quant
-- } ;
sp : NForm => Str ;
} ; } ;
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- Det, Quant, Card, Ord -- Det, Quant, Card, Ord
BaseQuant : Type = { BaseQuant : Type = {
s : Str ; s : Str ;
isPoss : Bool poss : Possession ;
} ; } ;
Determiner : Type = BaseQuant ** { Determiner : Type = BaseQuant ** {
@@ -77,7 +88,7 @@ oper
baseQuant : BaseQuant = { baseQuant : BaseQuant = {
s = [] ; s = [] ;
isPoss = False ; poss = Bare ;
} ; } ;
mkQuant : Str -> Quant = \str -> baseQuant ** { mkQuant : Str -> Quant = \str -> baseQuant ** {
@@ -85,22 +96,34 @@ oper
sp = \\_ => str sp = \\_ => str
} ; } ;
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- Prepositions -- Prepositions
Preposition : Type = { Preposition : Type = {
s : Str ; -- dengan s : Str ; -- dengan
obj : Person => Str -- dengan+nya -- needed in relative clauses to refer to the object obj : Person => Str ; -- dengan+nya -- needed in relative clauses to refer to the object
isPoss : Bool ;
} ; } ;
mkPrep : Str -> Preposition = \dengan -> { mkPrep : Str -> Preposition = \dengan -> {
s = dengan ; s = dengan ;
obj = \\p => dengan + poss2str (Poss p) obj = \\p => dengan + poss2str (Poss p) ;
isPoss = False ;
} ; } ;
emptyPrep : Preposition = { emptyPrep : Preposition = {
s = [] ; 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} ; Sentence : Type = {s : Str} ;
predVP : NounPhrase -> VerbPhrase -> Clause = \np,vp -> { predVP : NounPhrase -> VerbPhrase -> Clause = \np,vp -> {
subj = np.s ; subj = np.s ! Bare ;
pred = vp.s pred = vp.s
} ; } ;

View File

@@ -119,14 +119,14 @@ lin with_Prep = mkPrep "dengan" ;
-- Pronouns are closed class, no constructor in ParadigmsMay. -- Pronouns are closed class, no constructor in ParadigmsMay.
-- it_Pron = -- it_Pron =
-- i_Pron = lin i_Pron = mkPron "saya" P1 ;
-- youPol_Pron, -- lin youPol_Pron = mkPron "" P3 ;
-- youSg_Pron = -- lin youSg_Pron =
-- he_Pron = lin he_Pron = mkPron "dia" P3 ;
-- she_Pron = lin she_Pron = mkPron "dia" P3 ;
-- we_Pron = lin we_Pron = mkPron "kami" P1 ;
-- youPl_Pron = -- lin youPl_Pron =
-- they_Pron = lin they_Pron = mkPron "mereka" P3 ;
--lin whatPl_IP = ; --lin whatPl_IP = ;
--lin whatSg_IP = : --lin whatSg_IP = :

View File

@@ -43,7 +43,7 @@ lin
-- : V3 -> NP -> VPSlash ; -- give it (to her) -- : V3 -> NP -> VPSlash ; -- give it (to her)
Slash2V3 v3 dobj = useV { 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 c2 = v3.c3 -- Now the VPSlash is missing only the indirect object
} ; } ;
@@ -66,7 +66,7 @@ lin
-} -}
-- : VPSlash -> NP -> VP -- : VPSlash -> NP -> VP
ComplSlash vps np = vps ** { 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 ; -- : VV -> VPSlash -> VPSlash ;
@@ -111,9 +111,12 @@ lin
CompCN cn = useComp (cn.s ! NF Sg Bare) ; CompCN cn = useComp (cn.s ! NF Sg Bare) ;
-- NP -> Comp ; -- NP -> Comp ;
CompNP np = useComp np.s ; CompNP np = useComp (np.s ! Bare) ;
-- : Adv -> Comp ; -- : 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} ; CompAdv adv = useV {s = \\_ => adv.s} ;
-- : VP -- Copula alone; -- : VP -- Copula alone;

View 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