From a52300205d23ea4915c955bfad647f3eeb04769b Mon Sep 17 00:00:00 2001 From: Inari Listenmaa Date: Thu, 23 Apr 2020 16:14:31 +0200 Subject: [PATCH] (Hun) Squeeze further down to 7 stems --- src/hungarian/NounHun.gf | 2 +- src/hungarian/NounMorphoHun.gf | 153 +++++++++++++++++---------------- src/hungarian/ParamHun.gf | 15 ++-- src/hungarian/ResHun.gf | 23 +++-- src/hungarian/VerbHun.gf | 8 +- 5 files changed, 107 insertions(+), 94 deletions(-) diff --git a/src/hungarian/NounHun.gf b/src/hungarian/NounHun.gf index 2927c9071..cb702c1c6 100644 --- a/src/hungarian/NounHun.gf +++ b/src/hungarian/NounHun.gf @@ -180,7 +180,7 @@ concrete NounHun of Noun = CatHun ** open ResHun, Prelude, Coordination in { -- : AP -> CN -> CN AdjCN ap cn = cn ** { - s = \\n,c => ap.s ! Sg ++ cn.s ! n ! c ; + s = \\nc => ap.s ! Sg ++ cn.s ! nc ; compl = \\n,c => ap.compar ++ cn.compl ! n ! c ; } ; diff --git a/src/hungarian/NounMorphoHun.gf b/src/hungarian/NounMorphoHun.gf index c21178e74..6e3ee80a3 100644 --- a/src/hungarian/NounMorphoHun.gf +++ b/src/hungarian/NounMorphoHun.gf @@ -1,7 +1,7 @@ resource NounMorphoHun = ParamHun ** open Prelude, Predef in { oper - Noun = {s : Number => CaseStem => Str ; h : Harm} ; + Noun = {s : NumCaseStem => Str ; h : Harm} ; -- Paradigm functions -- http://www.cse.chalmers.se/~aarne/articles/smart-preprint.pdf @@ -13,13 +13,13 @@ oper -- Apply mkNoun to the lengthened stem "almá" or "kefé" nAlmá : Noun = mkNoun almá ; in nAlmá ** { - s = \\n,c => case of { + s = \\nc => case nc of { -- Singular nominative uses the given form, e.g. "alma" or "kefe" - => alma ; + SgNom => alma ; -- The rest of the forms are formed with the regular constructor, -- using "almá" or "kefé" as the stem. - _ => nAlmá.s ! n ! c } + _ => nAlmá.s ! nc } } ; --Handles words like "ló, lé, kő" which are "lovak, levek, kövek" in plural. @@ -32,15 +32,15 @@ oper nLova = mkNoun lova ; nLó = mkNoun ló ; in nLova ** { - s = \\n,c => case of { + s = \\nc => case nc of { -- All plural forms and Sg Acc, Sg Sup use the "lova" stem - | => nLova.s ! n ! c ; - => nLov.s ! n ! c ; + PlStem | PlAcc | SgAcc => nLova.s ! nc ; + SgSup => nLov.s ! nc ; -- The rest of the forms are formed with the regular constructor, -- using "ló" as the stem. - _ => nLó.s ! n ! c } + _ => nLó.s ! nc } } ; -- NB. arguments are Sg Nom, Pl Nom @@ -50,13 +50,14 @@ oper nFalva = mkNoun falva ; nFalu = mkNoun falu ; in nFalu ** { - s = \\n,c => case of { + s = \\nc => case nc of { + + -- All plural forms and Sg Acc, Sg Sup use the "falu" stem + PlStem | PlAcc => nFalva.s ! nc ; - -- All plural forms and Sg Acc, Sg Sup use the "lova" stem - => nFalva.s ! n ! c ; -- The rest of the forms are formed with the regular constructor, -- using "ló" as the stem. - _ => nFalu.s ! n ! c } + _ => nFalu.s ! nc } } ; @@ -72,14 +73,14 @@ oper nMajmo = mkNoun majmo ; nMajom = mkNoun majom ; in nMajmo ** { - s = \\n,c => case of { + s = \\nc => case nc of { -- All plural forms and Sg Acc and Sg Sup use the "majmo" stem - | => nMajmo.s ! n ! c ; - => nMajmo.s ! n ! c ; + PlStem | PlAcc | SgAcc => nMajmo.s ! nc ; + SgSup => nMajmo.s ! nc ; -- The rest of the forms are formed with the regular constructor, -- using "majom" as the stem. - _ => nMajom.s ! n ! c + _ => nMajom.s ! nc } } ; @@ -91,13 +92,13 @@ oper nTolla = mkNoun tolla ; nToll = mkNoun toll ; in nTolla ** { - s = \\n,c => case of { + s = \\nc => case nc of { -- All plural forms and Sg Acc use the "tolla" stem - | => nTolla.s ! n ! c ; + PlStem | PlAcc | SgAcc => nTolla.s ! nc ; -- The rest of the forms are formed with the regular constructor, -- using "toll" as the stem. - _ => nToll.s ! n ! c + _ => nToll.s ! nc } } ; @@ -300,52 +301,31 @@ oper harm1 : Str -> HarmForms = \i -> harm i i ; -- Variant of case forms when the noun stem ends in consonant. - endCaseCons : CaseStem -> HarmForms = \c -> case c of { - AccFull => harm3 "ot" "et" "öt" ; - SupFull => harm3 "on" "en" "ön" ; + endCaseCons : NumCaseStem -> HarmForms = \c -> case c of { + SgSup => harm3 "on" "en" "ön" ; + SgAcc|PlAcc => harm3 "ot" "et" "öt" ; _ => harm1 [] } ; - endCase : Case -> HarmForms = \c -> case c of { - Nom => harm1 [] ; - Acc => harm3 "ot" "et" "öt" ; - Dat => harm "nak" "nek" ; - Ins => harm "al" "el" ; - Tra => harm "á" "é" ; - Ill => harm "ba" "be" ; - Ine => harm "ban" "ben" ; - Ela => harm "ból" "ből" ; - All => harm3 "hoz" "hez" "höz" ; - Ade => harm "nál" "nél" ; - Abl => harm "tól" "től" ; - Sub => harm "ra" "re" ; - Sup => harm3 "on" "en" "ön" ; - Del => harm "ról" "ről" ; - Cau => harm1 "ért" - -- Ess => harm "stul" "stül" ; -- Essive-modal 'with and its parts' - -- Ter => harm1 "ig" ; -- Terminative 'as far as ' - -- For => harm1 "ként" ; -- Formal 'as ' - -- Tem => harm1 "kor" -- Temporal 'at '. Only used with numerals. - } ; -- Variant where accusative has the allomorph -at - endCaseConsAccAt : CaseStem -> HarmForms = \c -> case c of { - AccFull => harm3 "at" "et" "öt" ; + endCaseConsAccAt : NumCaseStem -> HarmForms = \c -> case c of { + SgAcc|PlAcc => harm3 "at" "et" "öt" ; _ => endCaseCons c } ; -- Variant where accusative has the allomorph -t for consonants -- Examples: "pénz, bor, orr, szín, lány, kés, dal" - endCaseConsAcc : CaseStem -> HarmForms = \c -> case c of { - AccFull => harm1 "t" ; + endCaseConsAcc : NumCaseStem -> HarmForms = \c -> case c of { + SgAcc => harm1 "t" ; _ => endCaseCons c } ; -- Variant of case forms when the noun stem ends in vowel. - endCaseVow : CaseStem -> HarmForms = \c -> case c of { - AccFull => harm1 "t" ; - SupFull => harm1 "n" ; - InsTraStem => harm1 "v" ; + endCaseVow : NumCaseStem -> HarmForms = \c -> case c of { + SgAcc => harm1 "t" ; + SgSup => harm1 "n" ; + SgInsStem => harm1 "v" ; -- Other forms are shared with endCaseCons. _ => endCaseCons c } ; @@ -372,40 +352,63 @@ oper mkNounHarm : Harm -> (plural : Str) -> Str -> Noun = mkNounHarmAcc True ; mkNounHarmAcc : (useAt : Bool) -> Harm -> (plural : Str) -> Str -> Noun = \useAt,h,plural,w -> - let endCaseSg : CaseStem -> HarmForms = case of { - <_,_ + #v> => endCaseVow ; - <_,_ + #v + ("sz"|"z"|"s"|"zs"|"j" - |"ly"|"l"|"r"|"n"|"ny"|"ssz"|"zz" - |"ss"|"ll"|"rr"|"nn"|"ns"|"nsz" - |"nz")> => endCaseConsAcc ; - => endCaseConsAccAt ; - _ => endCaseCons } ; - endCasePl : CaseStem -> HarmForms = case of { - <"ak",_> => endCaseConsAccAt ; - <_,True> => endCaseConsAccAt ; - _ => endCaseCons } ; + let endCaseSg : NumCaseStem -> HarmForms = + case of { + <_,_ + #v> => endCaseVow ; + <_,_ + #v + ("sz"|"z"|"s"|"zs"|"j"|"ly"|"l"|"r"|"n"|"ny"|"ssz" + |"zz"|"ss"|"ll"|"rr"|"nn"|"ns"|"nsz"|"nz")> => endCaseConsAcc ; + => endCaseConsAccAt ; + _ => endCaseCons } ; + endCasePl : NumCaseStem -> HarmForms = + case of { + <"ak",_> => endCaseConsAccAt ; + <_,True> => endCaseConsAccAt ; + _ => endCaseCons } ; -- Last consonant doubles before instrumental and translative duplConsStem : Str = case vowFinal w of { True => w ; False => duplicateLast w } ; - -- Noun is {s : Number => Case => Str}, we construct nested tables. + -- Noun is {s : NumCaseStem => Str} in {h = h ; s = table { - Sg => table { - -- Double the last letter (if consonant) before Ins, Tra - c@(InsTraStem) => duplConsStem + endCaseSg c ! h ; - c@_ => w + endCaseSg c ! h } ; + -- Before Sg Ins, Tra: + -- * Double the last letter if consonant + -- * Add v if vowel (comes from endCaseSg) + SgInsStem => duplConsStem + endCaseSg SgInsStem ! h ; - Pl => table { - -- Double the plural k before Ins, Tra - c@(InsTraStem) => w + plural + "k" + endCasePl c ! h ; + -- endCaseCons, because we only use -k as plural morpheme. + -- If we add possessive forms with allomorph -i, then revise. + c@(PlStem|PlAcc) => w + plural + endCasePl c ! h ; - -- endCaseCons, because we only use -k as plural morpheme. - -- If we add possessive forms with allomorph -i, then revise. - c@_ => w + plural + endCasePl c ! h } - } + -- All other singular forms and stems + c => w + endCaseSg c ! h } ; } ; + +-- This is used in ResHun.caseFromStem, not here. + + endCase : Case -> HarmForms = \c -> case c of { + Nom => harm1 [] ; + Acc => harm3 "ot" "et" "öt" ; + Dat => harm "nak" "nek" ; + Ins => harm "al" "el" ; + Tra => harm "á" "é" ; + Ill => harm "ba" "be" ; + Ine => harm "ban" "ben" ; + Ela => harm "ból" "ből" ; + All => harm3 "hoz" "hez" "höz" ; + Ade => harm "nál" "nél" ; + Abl => harm "tól" "től" ; + Sub => harm "ra" "re" ; + Sup => harm3 "on" "en" "ön" ; + Del => harm "ról" "ről" ; + Cau => harm1 "ért" + -- Ess => harm "stul" "stül" ; -- Essive-modal 'with and its parts' + -- Ter => harm1 "ig" ; -- Terminative 'as far as ' + -- For => harm1 "ként" ; -- Formal 'as ' + -- Tem => harm1 "kor" -- Temporal 'at '. Only used with numerals. + } ; + } diff --git a/src/hungarian/ParamHun.gf b/src/hungarian/ParamHun.gf index d4db0679f..0d287629a 100644 --- a/src/hungarian/ParamHun.gf +++ b/src/hungarian/ParamHun.gf @@ -20,10 +20,13 @@ oper param - CaseStem = - NomFull | AccFull | SupFull -- These may use 2-3 different stems - | InsTraStem -- Instrumental and translative: -v after vowels - | OblStem ; -- The rest of the cases are regular and attach to this stem + NumCaseStem = + SgNom | SgAcc | SgSup -- These may use 2-3 different stems + | PlAcc -- May have irregular vowel in suffix + | SgInsStem -- Instrumental and translative: -v after vowels + | SgStem -- Rest of the cases in Sg + | PlStem -- Rest of the cases in Pl + ; Case = Nom | Acc | Dat @@ -31,8 +34,8 @@ param | Cau -- Causal-final 'for the purpose of, for the reason that' | Ins -- Instrumental | Tra -- Translative - -- | Ess | Ter | For - -- | Tem -- Temporal, e.g. hatkor ‘six o’clock’ (from hat ‘6’) + -- | Ess | Ter | For + -- | Tem -- Temporal, e.g. hatkor ‘six o’clock’ (from hat ‘6’) ; SubjCase = SCNom | SCDat ; -- Limited set of subject cases diff --git a/src/hungarian/ResHun.gf b/src/hungarian/ResHun.gf index cb0e63af8..56b4b02e1 100644 --- a/src/hungarian/ResHun.gf +++ b/src/hungarian/ResHun.gf @@ -23,12 +23,14 @@ oper \\n,c => caseFromStem False c (regNounNomAcc no ac) n ; caseFromStem : Bool -> Case -> Noun -> Number -> Str = \usebind,cas,cn,n -> - case cas of { - Nom => cn.s ! n ! NomFull ; - Acc => cn.s ! n ! AccFull ; - Sup => cn.s ! n ! SupFull ; - Ins => glueIf usebind (cn.s ! n ! InsTraStem) (endCase Ins ! cn.h) ; - Tra => glueIf usebind (cn.s ! n ! InsTraStem) (endCase Tra ! cn.h) ; + case of { + => cn.s ! SgNom ; + => cn.s ! SgAcc ; + => cn.s ! SgSup ; + => cn.s ! PlAcc ; + => cn.s ! PlStem ; + => glueIf usebind (cn.s ! SgInsStem) (endCase cas ! cn.h) ; + => glueIf usebind (glue (cn.s ! PlStem) "k") (endCase cas ! cn.h) ; _ => applyOblCase usebind (endCase cas) n cn } ; @@ -58,7 +60,7 @@ oper objdef = Def ; } ; - linCN : CNoun -> Str = \cn -> cn.s ! Sg ! NomFull ++ cn.compl ! Sg ! Nom ; + linCN : CNoun -> Str = \cn -> cn.s ! SgNom ++ cn.compl ! Sg ! Nom ; -------------------------------------------------------------------------------- -- Pronouns @@ -160,8 +162,11 @@ oper applyAdp : Adposition -> NounPhrase -> Str = \adp,np -> adp.pr ++ np.s ! adp.c ++ adp.s ; - applyOblCase : Bool -> HarmForms -> Number -> Noun -> Str = \usebind,adp,n,np -> - glueIf usebind (np.s ! n ! OblStem) (adp ! np.h) ; + applyOblCase : Bool -> HarmForms -> Number -> Noun -> Str = + \usebind,adp,n,np -> + let stem : NumCaseStem = case n of { + Sg => SgStem ; Pl => PlStem } ; + in glueIf usebind (np.s ! stem) (adp ! np.h) ; glueIf : Bool -> (_,_ : Str) -> Str = \f,a,b -> if_then_Str f (glue a b) (a + b) ; diff --git a/src/hungarian/VerbHun.gf b/src/hungarian/VerbHun.gf index ec6b2ad94..705805e2a 100644 --- a/src/hungarian/VerbHun.gf +++ b/src/hungarian/VerbHun.gf @@ -118,12 +118,14 @@ lin -- : CN -> Comp ; CompCN cn = UseCopula ** { s = \\vf => case vf of { - VPres P3 n => cn.s ! n ! NomFull + VPres P3 n => cn.s ! SgNom -- TODO ++ cn.compl ! n ! Nom ; - VPres _ n => cn.s ! n ! NomFull + + VPres _ n => cn.s ! SgNom -- TODO ++ cn.compl ! n ! Nom ++ copula.s ! vf ; - _ => cn.s ! Sg ! NomFull + + _ => cn.s ! SgNom ++ cn.compl ! Sg ! Nom ++ copula.s ! vf} ; } ;