From 49fbbffacc1df479c8ce7e442ed62a0ba87fa2fa Mon Sep 17 00:00:00 2001 From: Inari Listenmaa Date: Sun, 21 Jun 2020 21:06:06 +0200 Subject: [PATCH] (Hun) Add postmod field to CN and NP, to better control word order. --- src/hungarian/CatHun.gf | 1 + src/hungarian/ConjunctionHun.gf | 12 ++++++++---- src/hungarian/NounHun.gf | 6 ++++-- src/hungarian/PhraseHun.gf | 2 +- src/hungarian/ResHun.gf | 12 ++++++++---- src/hungarian/VerbHun.gf | 11 +++++++++-- 6 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/hungarian/CatHun.gf b/src/hungarian/CatHun.gf index e60c34b8..b4705e3f 100644 --- a/src/hungarian/CatHun.gf +++ b/src/hungarian/CatHun.gf @@ -122,5 +122,6 @@ concrete CatHun of Cat = CommonX - [Adv] ** open ResHun, Prelude in { linref CN = linCN ; + NP = linNP ; } diff --git a/src/hungarian/ConjunctionHun.gf b/src/hungarian/ConjunctionHun.gf index 689a9c89..15305eb2 100644 --- a/src/hungarian/ConjunctionHun.gf +++ b/src/hungarian/ConjunctionHun.gf @@ -35,17 +35,21 @@ lin -- Noun phrases lincat - [NP] = ResHun.BaseNP ** {s1,s2 : Possessor => Case => Str} ; + [NP] = ResHun.BaseNP ** {s1,s2 : Possessor => Case => Str ; postmod : Str} ; lin - BaseNP x y = twoTable2 Possessor Case x y ** y ; - ConsNP x xs = xs ** consrTable2 Possessor Case comma x xs ; + BaseNP x y = twoTable2 Possessor Case (contNP x) y ** y ; + ConsNP x xs = xs ** consrTable2 Possessor Case comma (contNP x) xs ; ConjNP co xs = conjunctDistrTable2 Possessor Case co xs ** xs ** { agr = Pl ; _ => co.n }> } ; - + oper + contNP : NP -> NP = \np -> + let linTable : Possessor => Case => Str = + \\p,c => case of {_ => linNP' p c np} ; + in np ** {s = linTable} ; -- Relative sentences lincat [RS] = {s1,s2 : Number => Case => Str} ; diff --git a/src/hungarian/NounHun.gf b/src/hungarian/NounHun.gf index 6044939a..841630cb 100644 --- a/src/hungarian/NounHun.gf +++ b/src/hungarian/NounHun.gf @@ -36,6 +36,7 @@ concrete NounHun of Noun = CatHun ** open -- : Pron -> NP ; UsePron pron = pron ** { s = \\_ => pron.s ; + postmod = [] ; } ; -- : Predet -> NP -> NP ; -- only the man @@ -77,7 +78,7 @@ concrete NounHun of Noun = CatHun ** open } ; -- : CN -> NP ; - MassNP cn = emptyNP ** { + MassNP cn = emptyNP ** cn ** { s = \\p,c => case p of { NoPoss => caseFromStem glue cn c Sg ; Poss per rnum => @@ -192,6 +193,7 @@ concrete NounHun of Noun = CatHun ** open -- : N2 -> CN ; UseN,UseN2 = \n -> n ** { compl = \\_,_ => [] ; + postmod = [] ; } ; -- : N2 -> NP -> CN ; @@ -221,7 +223,7 @@ concrete NounHun of Noun = CatHun ** open -- : CN -> Adv -> CN ; AdvCN cn adv = case adv.isPre of { True => AdjCN (invarAP adv.s) cn ; - False => cn ** {compl = \\n,c => cn.compl ! n ! c ++ adv.s} + False => cn ** {postmod = cn.postmod ++ adv.s} } ; -- Nouns can also be modified by embedded sentences and questions. diff --git a/src/hungarian/PhraseHun.gf b/src/hungarian/PhraseHun.gf index e31d338b..7b07bd83 100644 --- a/src/hungarian/PhraseHun.gf +++ b/src/hungarian/PhraseHun.gf @@ -12,7 +12,7 @@ concrete PhraseHun of Phrase = CatHun ** open Prelude, ResHun in { UttImpPol = UttImpSg ; -} UttIP, - UttNP = \np -> {s = np.s ! NoPoss ! Nom} ; + UttNP = \np -> {s = linNP np} ; UttVP vp = {s = vp.obj ++ vp.adv ++ vp.s ! VInf} ; UttAdv adv = adv ; UttCN cn = {s = linCN cn} ; diff --git a/src/hungarian/ResHun.gf b/src/hungarian/ResHun.gf index f6256624..cda65dda 100644 --- a/src/hungarian/ResHun.gf +++ b/src/hungarian/ResHun.gf @@ -15,6 +15,7 @@ resource ResHun = NounMorphoHun ** open Prelude, Predef in { oper CNoun : Type = Noun ** { compl : Number => Case => Str ; + postmod : Str ; } ; mkCaseNoun : Str -> Number => Case => Str = \s -> @@ -78,13 +79,14 @@ oper NounPhrase : Type = BaseNP ** { s : Possessor => Case => Str ; + postmod : Str ; } ; emptyNP : NounPhrase = { s = \\_,_ => [] ; agr = ; objdef = Indef ; - empty = [] ; + postmod, empty = [] ; } ; indeclNP : Str -> NounPhrase = \s -> emptyNP ** {s = \\p,c => s} ; @@ -95,7 +97,9 @@ oper objdef = Def ; } ; - linCN : CNoun -> Str = \cn -> cn.s ! SgNom ++ cn.compl ! Sg ! Nom ; + linCN : CNoun -> Str = \cn -> cn.s ! SgNom ++ cn.compl ! Sg ! Nom ++ cn.postmod ; + linNP' : Possessor -> Case -> NounPhrase -> Str = \p,c,np -> np.s ! p ! c ++ np.postmod ; + linNP : NounPhrase -> Str = linNP' NoPoss Nom ; -------------------------------------------------------------------------------- -- Pronouns @@ -273,7 +277,7 @@ oper emptyAdp : Adposition = nomAdp [] ; applyAdp : Adposition -> NounPhrase -> Str = \adp,np -> - adp.pr ++ np.s ! NoPoss ! adp.c ++ adp.s ; + adp.pr ++ np.s ! NoPoss ! adp.c ++ adp.s ++ np.postmod ; applyCase : (Str->Str->Str) -> Case -> Noun -> NumCaseStem -> Str = \bind,cas,cn,stem -> bind (cn.s ! stem) (endCase cas ! cn.h) ; @@ -503,7 +507,7 @@ oper s = \\t,a,p => let subjcase : Case = case vp.sc of { SCNom => Nom ; SCDat => Dat } - in np.s ! NoPoss ! subjcase + in linNP' NoPoss subjcase np ++ if_then_Pol p [] "nem" ++ vp.s ! agr2vf np.agr ++ vp.obj -- ! np.agr diff --git a/src/hungarian/VerbHun.gf b/src/hungarian/VerbHun.gf index ef21c063..15ba59ef 100644 --- a/src/hungarian/VerbHun.gf +++ b/src/hungarian/VerbHun.gf @@ -128,13 +128,14 @@ lin _ => cn.s ! SgNom ++ cn.compl ! Sg ! Nom ++ copula.s ! vf} ; + adv = cn.postmod ; } ; -- : NP -> Comp ; CompNP np = UseCopula ** { s = \\vf => case vf of { - VPres P3 _ => np.s ! NoPoss ! Nom ; - _ => np.s ! NoPoss ! Nom ++ copula.s ! vf } ; + VPres P3 _ => linNP np ; + _ => linNP np ++ copula.s ! vf } ; } ; -- : Adv -> Comp ; @@ -151,6 +152,12 @@ insertObj : ResHun.VPSlash -> NounPhrase -> VerbPhrase = \vps,np -> vps ** { => [] ; _ => np.s ! NoPoss ! vps.c2 } ; + -- To accommodate application grammars that use AdvCN in place of AdvVP. + -- (Easy mistake to make, because in English it doesn't affect word order.) + -- If you want the NP's postmodifiers to go right next to the NP, + -- put np.postmod right after np.s. + adv = vps.adv ++ np.postmod ; + s = \\vf => -- If verb's subject case is Dat and object Nom, verb agrees with obj. case of { -- have_V2 needs its object possessed by the subject