(Hun) Add possessive suffixes to nouns in DetCN

This commit is contained in:
Inari Listenmaa
2020-04-23 21:12:37 +02:00
parent 26253d5353
commit fc699d231f
3 changed files with 60 additions and 17 deletions

View File

@@ -8,10 +8,14 @@ concrete NounHun of Noun = CatHun ** open ResHun, Prelude, Coordination in {
-- : Det -> CN -> NP
DetCN det cn = emptyNP ** det ** {
s = \\c => case det.caseagr of {
s = \\c =>
let foo : Str = case det.dt of {
NoPoss => caseFromStem glue cn c det.n ;
DetPoss _ => caseFromPossStem cn det c } ;
in case det.caseagr of {
True => det.s ! c ;
False => det.s ! Nom
} ++ caseFromStem glue cn c det.n
} ++ foo
++ cn.compl ! det.n ! c ;
agr = <P3,det.n> ;
} ;
@@ -77,6 +81,8 @@ concrete NounHun of Noun = CatHun ** open ResHun, Prelude, Coordination in {
<True,True> => [] ;
_ => quant.sp ! num.n ! c }
++ num.s ! Indep ;
dt = case quant.qt of { QuantPoss stem => DetPoss stem ;
_ => NoPoss } ;
} ;
-- : Quant -> Num -> Ord -> Det ; -- these five best
@@ -134,28 +140,28 @@ concrete NounHun of Noun = CatHun ** open ResHun, Prelude, Coordination in {
-- OrdNumeralSuperl num a = num ** { } ;
-- : Quant
DefArt = {
DefArt = mkQuant "a" "a" ** {
s,
sp = \\_,_ => pre {"a" ; "az" / v } ;
qt = Article ;
objdef = Def ;
caseagr = True ;
} ;
-- : Quant
IndefArt = {
IndefArt = mkQuant "egy" [] ** {
s = \\n,_ => case n of {Sg => "egy" ; Pl => []} ;
sp = \\n,_ => case n of {Sg => "egy" ; Pl => "sok"} ;
qt = Article ;
objdef = Indef ;
caseagr = True ;
} ;
-- : Pron -> Quant
-- PossPron pron =
-- let p = pron.poss ;
-- in DefArt ** {
-- } ;
PossPron pron = pron ** {
s,sp = \\_ => pron.s ;
qt = QuantPoss (agr2PossStem pron.agr) ;
objdef = Def ;
caseagr = False ;
} ;
--2 Common nouns

View File

@@ -17,7 +17,19 @@ oper
-- Quant
param
QuantType = Possessive | Article ;
QuantType =
Article -- Needed to prevent "a 2 cars"
| Other -- Not poss, not article
| QuantPoss PossStem -- Which possessive stem it takes
;
DetType =
NoPoss -- distinction between Article and Other no longer needed
| DetPoss PossStem -- Sill need to know which stem it takes if Poss
;
-- Singular stems. Plural is always same, no need to add here.
PossStem = dSg_rSg1P2 | dSg_rP3 | dSg_rPl1 ;
oper
-- standard trick to prevent "a one car"
@@ -27,6 +39,13 @@ oper
_ => False
} ;
agr2PossStem : Person*Number -> PossStem = \pn ->
case <pn.p1,pn.p2> of {
<P1,Pl> => dSg_rPl1 ;
<P3,_> => dSg_rP3 ;
_ => dSg_rSg1P2
} ;
--------------------------------------------------------------------------------
-- Nouns
@@ -56,8 +75,6 @@ param
SubjCase = SCNom | SCDat ; -- Limited set of subject cases
Possessor = NoPoss | Poss Number Person ;
oper
caseTable : (x1,_,_,_,_,_,_,_,_,_,_,_,_,_,x15 : Str) -> Case=>Str =

View File

@@ -29,13 +29,24 @@ oper
<Sg,Acc> => bind (cn.s ! SgAccStem) "t" ;
<Sg,Sup> => cn.s ! SgSup ;
<Pl,Acc> => cn.s ! PlAcc ;
<Pl,Nom> => cn.s ! PlStem ;
<Pl,Nom> => cn.s ! PlStem ; -- don't use applyCase', it adds a BIND which breaks everything!
<Sg,Ins|Tra> => applyCase' SgInsStem ;
<Pl,Ins|Tra> => bind (bind (cn.s ! PlStem) "k") (endCase cas ! cn.h) ;
<Sg,_> => applyCase' SgStem ;
<Pl,_> => applyCase' PlStem
} ;
caseFromPossStem : Noun -> Determiner -> Case -> Str = \cn,det,cas ->
let stem : NumCaseStem = case <det.n,det.dt> of {
<Sg,DetPoss st> => case st of {
dSg_rSg1P2 => SgAccStem ;
dSg_rP3 => PossdSg_PossrP3 ;
dSg_rPl1 => PossdSg_PossrPl1 } ;
<Pl,DetPoss _> => PossdPl ;
_ => Predef.error "caseFromPossStem: Trying to apply to non-possessive Det"
} ;
in applyCaseSuf (det.poss ! cn.h) cas cn stem ;
BaseNP : Type = {
agr : Person*Number ;
objdef : ObjDef ;
@@ -82,6 +93,7 @@ oper
-- Det, Quant, Card, Ord
BaseQuant : Type = {
poss : HarmForms ; -- Quants made by PossPron need this, empty for others
objdef : ObjDef ; -- How V2 agrees if NP with this Det is an object
caseagr : Bool ; -- If it agrees in case: "azoknak a nőknek" vs. "sok nőknek"
} ;
@@ -97,9 +109,10 @@ oper
mkQuant : (s,sp : Str) -> Quant = \s,sp -> {
s = mkCaseNoun s ;
sp = mkCaseNoun sp ;
qt = Article ;
qt = Other ;
objdef = Def ;
caseagr = True ;
poss = harm1 [] ;
} ;
-- Det is formed in DetQuant : Quant -> Num -> Det
@@ -108,7 +121,8 @@ oper
s,
sp : Case => Str ;
n : Number ;
numtype : NumType ; -- Whether its Num component is digit, numeral or Sg/Pl
-- numtype : NumType ; -- Whether its Num component is digit, numeral or Sg/Pl
dt : DetType ;
} ;
mkDet : (s : Str) -> ObjDef -> Number -> Bool -> Determiner = \s,d,n,ca -> {
@@ -118,6 +132,8 @@ oper
numtype = NoNum ;
objdef = d ;
caseagr = ca ;
dt = NoPoss ;
poss = harm1 [] ;
} ;
mkDet2 : (n,a : Str) -> ObjDef -> Number -> Bool -> Determiner = \no,ac,d,n,ca ->
@@ -173,7 +189,11 @@ oper
adp.pr ++ np.s ! adp.c ++ adp.s ;
applyCase : (Str->Str->Str) -> Case -> Noun -> NumCaseStem -> Str =
\bind,cas,cn,stem -> bind (cn.s ! stem) (endCase cas ! cn.h) ;
\bind,cas,cn,stem -> bind (cn.s ! stem) (endCase cas ! cn.h) ;
applyCaseSuf : Str -> Case -> Noun -> NumCaseStem -> Str =
\suf,cas,cn,stem -> glue (glue (cn.s ! stem) suf) (endCase cas ! cn.h) ;
------------------
-- Conj