Reorganizing Ger by smaller prepositions and separating object cases from all (N, NP, etc.) cases (#474)

* (Ger) prepositions of contracting type, to base S,VV,QS-correlates and split adverbs on

* api/TryGer: omit mkAdv,mkIAdv,mkConj from ParadigmsGer, mkStructuralGer

* (Ger) sync with 'master' (undo changes unrelated to Preposition) up to few corrections

* (Ger) correct GPl to CPl in ExtraGer

* Returning to f4aae6a61a by ignoring prep-contraction

* (Ger) Prep contracting with DefArtSg, IP, RP

* (Ger) Corrected GPl to CPl in ExtraGer, ExtendGer

* (Ger) Simplified many lincats (Prep,V2,N2,A2,.. VPSlash,ClSlash) by reducing
      Preposition from 4*3 = 12 parameters to 3*2 = 6 via
         Prepositon : Type = {s : PrepForm => Str; s2:Str ; c : ObjCase ; t : PrepType} ;
         param PrepType = isCase | isPrep ; -- isPrepDefArt
               ObjCase = Acc | Dat | Gen ;   Case = Nom | Obj ObjCase ;
This commit is contained in:
Hans Leiß authored and GitHub committed 2026-09-07 16:33:05 +02:00
1 parent dcc0f3f56c
commit 997a9adae3
15 files changed
+387 -252

No files matched your search

+147 -69
View File
@@ -23,7 +23,9 @@ resource ResGer = ParamX ** open Prelude in {
-- These are the standard four-value case and three-value gender.
param
Case = Nom | Acc | Dat | Gen ;
Case = Nom | Obj ObjCase ;
ObjCase = Acc | Dat | Gen ;
Gender = Masc | Fem | Neutr ;
-- Complex $CN$s, like adjectives, have strong and weak forms.
@@ -52,6 +54,7 @@ resource ResGer = ParamX ** open Prelude in {
AgPl _ | AgPlPol => Pl
} ;
numberAgr : VAgr -> Number = \r -> case r of {VAg n _ => n} ;
numberAgr : RAgr -> Number = \r -> case r of {RAg n _ => n ; RNoAg => Sg} ;
} ;
personAgr = overload {
personAgr : Agr -> Person = \r -> case r of {
@@ -132,7 +135,7 @@ resource ResGer = ParamX ** open Prelude in {
param VAux = VHaben | VSein ;
param VType = VAct | VRefl Case ;
param VType = VAct | VRefl ObjCase ;
-- The order of a sentence depends on whether it is used as a main
-- clause, inverted, or subordinate.
@@ -189,20 +192,20 @@ resource ResGer = ParamX ** open Prelude in {
agrAdj : Adjf -> GenNum -> Case -> AForm = \a,gn,c ->
let
e = AMod (GSg Fem) Nom ;
en = AMod (GSg Masc) Acc ;
en = AMod (GSg Masc) (Obj Acc) ;
in
case a of {
Strong => AMod gn c ;
Weak => case <gn,c> of {
<GSg _, Nom> => e ;
<GSg Masc,Acc> => en ;
<GSg _, Acc> => e ;
<GSg Masc,Obj Acc> => en ;
<GSg _, Obj Acc> => e ;
_ => en } ;
Mixed => case <gn,c> of {
<GSg g, Nom|Acc> => AMod gn c ;
<GSg g, Nom|Obj Acc> => AMod gn c ;
_ => en } ;
MixedStrong => case <gn,c> of {
<GSg _, Dat|Gen> => en ;
<GSg _, Obj Dat|Obj Gen> => en ;
_ => AMod gn c }
} ;
@@ -210,7 +213,7 @@ resource ResGer = ParamX ** open Prelude in {
-- This is used twice in NounGer.
adjfCase : Adjf -> Case -> Adjf = \a,c -> case c of {
Nom|Acc => a ;
Nom | Obj Acc => a ;
_ => Weak
} ;
@@ -251,6 +254,12 @@ resource ResGer = ParamX ** open Prelude in {
caselist : (x1,_,_,x4 : Str) -> Case => Str = \n,a,d,g ->
table {
Nom => n ;
Obj Acc => a ;
Obj Dat => d ;
Obj Gen => g
} ;
objcaselist : (x1,_,x3 : Str) -> ObjCase => Str = \a,d,g ->
table {
Acc => a ;
Dat => d ;
Gen => g
@@ -274,7 +283,7 @@ resource ResGer = ParamX ** open Prelude in {
g : Gender
} ;
NP : Type = { -- HL 7/22: Bool = True if DefArt is dropped to combine with prep of type isPrepDefArt
NP : Type = { -- HL 7/22: Bool = True if DefArt is dropped to combine with contracting prep
s : Bool => Case => Str ;
rc : Str ; -- die Frage , [rc die ich gestellt habe]
ext : Str ; -- die Frage , [sc wo sie schläft] ; die Regel , [vp kein Fleisch zu essen] | [s dass ...]
@@ -345,6 +354,7 @@ resource ResGer = ParamX ** open Prelude in {
let
einb : Bool -> Str -> Str = \b,geb ->
if_then_Str b (ein + geb) geb ;
gebEn : Str = case geben of {an + "tun" => an + "tuen" ; _ => geben} ;
in
{s = table {
VInf False => ein + geben ;
@@ -364,14 +374,14 @@ resource ResGer = ParamX ** open Prelude in {
VImpfSubj Sg _ => gaebe ; --# notpresent
VImpfSubj Pl P2 => gaebe + "t" ; --# notpresent
VImpfSubj Pl _ => gaebe + "n" ; --# notpresent
VPresSubj Sg P2 => init geben + "st" ;
VPresSubj Sg _ => init geben ;
VPresSubj Pl P2 => init geben + "t" ;
VPresSubj Sg P2 => init gebEn + "st" ;
VPresSubj Sg _ => init gebEn ;
VPresSubj Pl P2 => init gebEn + "t" ;
VPresSubj Pl _ => geben
}) ;
VImper Sg => gib ;
VImper Pl => gebt ;
VPresPart a => ein + (regA (geben + "d")).s ! Posit ! a ;
VPresPart a => ein + (regA (gebEn + "d")).s ! Posit ! a ;
VPastPart a => ein + (regA gegeben).s ! Posit ! a
} ;
prefix = ein ;
@@ -445,67 +455,119 @@ resource ResGer = ParamX ** open Prelude in {
-- Prepositions indicate the case of their complement noun phrase.
-- There are three types: (i) cases, (ii) pure pre-, post- and circum-positions,
-- and (iii) prepositions glued with definite article in singular (using s!(GSg g)).
-- There are two types: (i) object cases, (ii) pure pre-, post- and circum-positions,
-- where the pre part may contract with the definite article in singular or
-- with demonstrative pronoun (da+für, hier+für) [= pronominal adverb] or
-- with interrogative pronoun (wo+für).
-- e.g. in+Dat: in dem CN => im CN ; in da => darin ; in wo => worin
-- Gen+wegen: des CN!Gen wegen ; des(sen) wegen => deswegen ; wes(sen) wegen => weswegen
param
PrepType = isCase | isPrep | isPrepDefArt ; -- HL 7/2022
PrepType = isCase | isPrep ; -- | isContracting ;
PrepForm = CPl | CSg Gender | CAdvPron | CIPron ;
oper
Preposition : Type = {s : GenNum => Str ; s2:Str ; c : Case ; t : PrepType} ;
Preposition : Type = {s : PrepForm => Str ; s2:Str ; c : ObjCase ; t : PrepType} ;
isaCase : Preposition -> Bool = \p -> case p.t of {isCase => True ; _ => False} ;
isaPrep : Preposition -> Bool = \p -> case p.t of {isPrep => True ; _ => False} ;
isaPrepDefArt : Preposition -> Bool = \p -> case p.t of {isPrepDefArt => True ; _ => False} ;
-- To specify subjects of V, VP etc, extend to allow nominative -- HL 9/26
SubjectPrep : Type = {s : PrepForm => Str ; s2:Str ; c : Case ; t : PrepType} ;
-- To apply a preposition to a complement.
-- auxiliary type for interrogative and relative pronoun
appPrep : Preposition -> (Case => Str) -> Str = \prep,arg ->
prep.s ! GPl ++ arg ! prep.c ++ prep.s2 ;
IP : Type = {s : Bool => Case => Str ; a : GenNum ; isPron : Bool} ;
RP : Type = {s : RelGenNum => Case => Str ; a : RAgr} ;
appPrepNP : Preposition -> NP -> Str = \prep,np ->
-- To apply a preposition to a noun phrase, interrogative or relative pronoun
appPrep = overload {
appPrep : Preposition -> (ObjCase => Str) -> Str = appPrep0 ;
-- appPrep : Preposition -> (Case => Str) -> Str = \p,c -> appSPrep (toSPrep p) c ; -- does not infer lintype e.g. in ExtraGer.AdvRAP
appPrep : SubjectPrep -> (Case => Str) -> Str = appSPrep ;
appPrep : SubjectPrep -> NP -> Str = appSPrepNP ; -- e.g. in dem CN => im CN
appPrep : SubjectPrep -> IP -> Str = appPrepIP ; -- e.g. in was => worin
appPrep : SubjectPrep -> RP -> RelGenNum => Str -- e.g. in was => worin
= appPrepRP ;
-- appPrep : Preposition -> DemPron -> Str = use CAdvPron ; -- e.g. in dem => darin
} ;
appPrep0 : Preposition -> (ObjCase => Str) -> Str = \prep,arg ->
prep.s ! CPl ++ arg ! prep.c ++ prep.s2 ;
appSPrep : SubjectPrep -> (Case => Str) -> Str = \prep,arg ->
prep.s ! CPl ++ arg ! prep.c ++ prep.s2 ;
appSPrepNP : SubjectPrep -> NP -> Str = \prep,np ->
let
g : Gender = genderAgr np.a ;
n : Number = numberAgr np.a ;
glues = case <prep.t,n> of {<isPrepDefArt,Sg> => True ; _ => False} ;
nps = np.s ! glues ! prep.c
b = case <prep.t,n,np.w> of {
<isPrep,Sg,WDefArt> => True ; -- e.g. "zum Hof|zur Tür|zum Fenster herein"
_ => False} ; -- e.g. "auf dem Hof|auf der Tür|auf dem Fenster"
f = case b of {True => CSg g ; _ => CPl} ;
in
case <glues, np.w> of {
<True, WDefArt> => -- e.g. "zum Hof|zur Tür|zum Fenster herein"
prep.s ! (GSg g) ++ nps ++ np.ext ++ prep.s2 ++ np.rc ;
_ => prep.s ! GPl ++ nps ++ np.ext ++ prep.s2 ++ np.rc
} ;
prep.s ! f ++ np.s ! b ! prep.c ++ np.ext ++ prep.s2 ++ np.rc ;
appPrepNP : Preposition -> NP -> Str = \prep,np ->
appSPrepNP (toSPrep prep) np ;
appPrepIP : SubjectPrep -> IP -> Str = \prep,np ->
let
g : Gender = genGenNum np.a ;
n : Number = numGenNum np.a ;
b = case <np.isPron,n,g> of {<True,Sg,Neutr> => True ; _ => False} ;
f = case b of {True => CIPron ; _ => CPl} -- e.g. "zu was" => "wozu"
in prep.s ! f ++ np.s ! b ! prep.c ++ prep.s2 ;
appPrepRP : SubjectPrep -> RP -> (RelGenNum => Str) = \prep,np ->
let
uncontracted : RelGenNum => Str =
\\gn => prep.s ! CPl ++ np.s ! gn ! prep.c ++ prep.s2
in
case <prep.t, np.a> of {
<isPrep, RNoAg> => table{RSentence => prep.s ! CIPron ;
-- RGenNum (GSg Neutr) => prep.s ! CIPron ;
gn => uncontracted ! gn} ;
_ => uncontracted
} ;
{- -- Simplify to test the effect on grammar compilation complexity (without SlashV2VNP):
-- with glues = False: 27096 msec, 3,2M VerbGer.gfo, 854 SentenceGer.gfo
-- contracts = False: 27096 msec, 3,2M VerbGer.gfo, 854 SentenceGer.gfo
-- and SlashV2VNP:102597 msec, 16 M VerbGer.gfo, 854 SentenceGer.gfo (good!)
appPrepNP : Preposition -> NP -> Str = \prep,np ->
let
glues = False ;
nps = np.s ! glues ! prep.c
in prep.s ! GPl ++ nps ++ np.ext ++ prep.s2 ++ np.rc ;
contracts = False ;
nps = np.s ! contracts ! prep.c
in prep.s ! CPl ++ nps ++ np.ext ++ prep.s2 ++ np.rc ;
-}
bigNP : NP -> Str = \np -> np.ext ++ np.rc ;
-- To build a preposition from just a case. -- HL 9/19: no longer used in RGL
noPreposition : Case -> Preposition = \c ->
noPreposition : Case -> SubjectPrep = \c ->
{s = \\_ => [] ; s2 = [] ; c = c ; t = isCase} ;
-- To build a preposition from just a case. -- HL 9/19: moved to mkPrep in ParadigmsGer
PrepNom : Preposition = {s = \\_ => [] ; t = isCase ; c = Nom ; s2 = []} ;
PrepNom : SubjectPrep = {s = \\_ => [] ; t = isCase ; c = Nom ; s2 = []} ;
vonDat : Preposition = {s=table{GPl => "von" ; GSg Fem => "von der"; _ => "vom"};
s2=[]; c=Dat; t=isPrepDefArt} ;
vonDat : Preposition = {s=table{CPl => "von" ; CSg Fem => "von der" ; CSg _ => "vom" ;
CAdvPron => "davon" ; CIPron => "wovon"};
s2=[]; c=Dat; t=isPrep} ;
toSPrep : Preposition -> SubjectPrep = \prep ->
{s = prep.s ; s2 = prep.s2 ; c = Obj prep.c ; t = prep.t} ;
fromSPrep : SubjectPrep -> Preposition = \prep -> -- default Acc for Nom
{s = prep.s ; s2 = prep.s2 ; c = case prep.c of {Obj d => d ; Nom => Acc} ; t = prep.t} ;
-- To build passive: accusative object -> nom subject; others -> same case or prep
subjPrep : Preposition -> Preposition = \prep ->
subjPrep : Preposition -> SubjectPrep = \prep ->
let r : {s : PrepForm => Str ; s2:Str ; t : PrepType} = {s = prep.s ; s2 = prep.s2 ; t = prep.t} in
case <prep.c,prep.t> of {
<Acc,isCase> => prep ** {c = Nom} ;
_ => prep
<Acc,isCase> => r ** {c = Nom} ;
<c, _> => r ** {c = Obj c}
} ;
-- Pronouns and articles
@@ -532,7 +594,7 @@ resource ResGer = ParamX ** open Prelude in {
<_,Sg,P2> => AgSgP2 -- for "man", "Sie", set in StructuralGer HL
} ;
sp = table {PossF (GSg Masc) Nom => mein + "er" ; -- HL 12/23
PossF (GSg Neutr) (Nom|Acc) => mein + "es" ;
PossF (GSg Neutr) (Nom|Obj Acc) => mein + "es" ;
PossF gn c => mein + (pronEnding ! gn ! c)} ;
} ;
@@ -579,7 +641,7 @@ resource ResGer = ParamX ** open Prelude in {
let adj = adjForms teuer teur
in
table {
AMod (GSg Masc| GSg Neutr) Gen => teur + "es" ;
AMod (GSg Masc| GSg Neutr) (Obj Gen) => teur + "es" ;
a => adj ! a
} ;
@@ -613,7 +675,7 @@ resource ResGer = ParamX ** open Prelude in {
ext : Str ; -- sentential complement of V(2)S, V(2)Q, e.g. dass|ob sie kommt
inf : {inpl: (Agr => Str)*Str ; -- infinitival complement of V(2)V HL 3/2022
extr: (Agr => Str)} ; -- e.g. ihn [] versuchen (lasse) [, ihr zu helfen]
c1 : Preposition -- case of subject
c1 : SubjectPrep -- case of subject
} ;
VPSlash = VP ** {c2 : Preposition ; objCtrl : Bool} ; -- HL 3/2019 objCtr added
@@ -769,12 +831,12 @@ resource ResGer = ParamX ** open Prelude in {
insertObjNP : NP -> Preposition -> VPSlash -> VPSlash = \np,prep,vp ->
let obj = appPrepNP prep np ;
b : Bool = case prep.t of {isPrep | isPrepDefArt => True ; _ => False} ;
b : Bool = case prep.t of {isPrep => True ; _ => False} ;
w = np.w ;
c = prep.c
c = prep.c -- TODO turn to ObjCase?
in insertObj' obj b w c vp ;
insertObj' : Str -> Bool -> Weight -> Case -> VPSlash -> VPSlash = \obj,isPrep,w,c,vp ->
insertObj' : Str -> Bool -> Weight -> ObjCase -> VPSlash -> VPSlash = \obj,isPrep,w,c,vp ->
vp ** {
nn = \\a =>
let vpnn = vp.nn ! a in
@@ -800,7 +862,7 @@ resource ResGer = ParamX ** open Prelude in {
insertObjRefl : VPSlash -> VPSlash = \vp -> -- HL 6/2019, to order reflPron < neg < prep+reflPron
let prep = vp.c2 ;
obj : Agr => Str = \\a => prep.s ! GPl ++ reflPron ! a ! prep.c ++ prep.s2
obj : Agr => Str = \\a => prep.s ! CPl ++ reflPron ! a ! prep.c ++ prep.s2
in vp ** {
nn = \\a =>
let vpnn = vp.nn ! a in
@@ -989,23 +1051,39 @@ resource ResGer = ParamX ** open Prelude in {
in
glue (embedInf vpi.inpl <vpi.objs, vpi.pred>) ++ vpi.extr!agr ++ vp.ext ;
-- The nominative case is not used as reflexive, but defined here
-- so that we can reuse this in personal pronouns.
-- Relfexive pronouns have object cases only, so nominative is omittet. -- HL 9/26
-- (The old reflPron with nominative forms is not reused to define personal pronouns.)
reflPron : Agr => Case => Str = table { -- with persPron nominative
AgSgP1 => caselist "ich" "mich" "mir" "meiner" ;
AgSgP2 => caselist "du" "dich" "dir" "deiner" ;
AgSgP3 Masc => caselist "er" "sich" "sich" "seiner" ;
AgSgP3 Fem => caselist "sie" "sich" "sich" "ihrer" ;
AgSgP3 Neutr => caselist "es" "sich" "sich" "seiner" ;
AgPl P1 => caselist "wir" "uns" "uns" "unser" ;
AgPl P2 => caselist "ihr" "euch" "euch" "euer" ;
AgPl P3 => caselist "sie" "sich" "sich" "ihrer" ;
AgPlPol => caselist "Sie" "sich" "sich" "Ihrer" -- HL 8/2023
-- AgSgP3Gen => caselist "man selbst" "sich" "sich" "seiner" ; -- älter als man selbst sein
-- ; AgPlReci => caselist "man" "einander" "einander" "einander" -- reciPron ?
reflPron : Agr => ObjCase => Str = table {
AgSgP1 => objcaselist "mich" "mir" "meiner" ;
AgSgP2 => objcaselist "dich" "dir" "deiner" ;
AgSgP3 Masc => objcaselist "sich" "sich" "seiner" ;
AgSgP3 Fem => objcaselist "sich" "sich" "ihrer" ;
AgSgP3 Neutr => objcaselist "sich" "sich" "seiner" ;
AgPl P1 => objcaselist "uns" "uns" "unser" ;
AgPl P2 => objcaselist "euch" "euch" "euer" ;
AgPl P3 => objcaselist "sich" "sich" "ihrer" ;
AgPlPol => objcaselist "sich" "sich" "Ihrer" -- HL 8/2023
-- AgSgP3Gen => objcaselist "sich" "sich" "seiner" ; -- man wundert sich
-- ; AgPlReci => objcaselist "einander" "einander" "einander" -- man grüßt einander
} ;
-- Nominative forms of the personal pronouns, used in ExtendGer.ReflPron : RNP
persPronNom : Agr => Str = table {
AgSgP1 => "ich" ;
AgSgP2 => "du" ;
AgSgP3 Masc => "er";
AgSgP3 Fem => "sie" ;
AgSgP3 Neutr => "es" ;
AgPl P1 => "wir" ;
AgPl P2 => "ihr" ;
AgPl P3 => "sie" ;
AgPlPol => "Sie"
-- AgSgP3Gen => "man" ; -- älter als man selbst sein
-- ; AgPlReci => "man" ;
} ;
possPron : Agr -> Number -> Gender -> Case -> Str = \a,n,g,c -> case <a,n,g> of {
<AgSgP1,Sg,Masc> => caselist "mein" "meinen" "meinem" "meines" ! c ;
<AgSgP1,Sg,Fem> => caselist "meine" "meine" "meiner" "meiner" ! c ;
@@ -1063,20 +1141,20 @@ resource ResGer = ParamX ** open Prelude in {
case rgn of {
RGenNum gn =>
case <gn,c> of {
<GSg Fem,Gen> => "deren" ;
<GSg g,Gen> => "dessen" ;
<GPl,Dat> => "denen" ;
<GPl,Gen> => "deren" ;
<GSg Fem,Obj Gen> => "deren" ;
<GSg g,Obj Gen> => "dessen" ;
<GPl,Obj Dat> => "denen" ;
<GPl,Obj Gen> => "deren" ;
_ => artDef ! gn ! c
} ;
RSentence => (caselist "was" "was" "was" "wessen") ! c -- wessen HL 4/2022
} ;
-- Function that allows the construction of non-nominative subjects.
mkSubject : NP -> Preposition -> {s:Str ; a:Agr} = \np, prep ->
mkSubject : NP -> SubjectPrep -> {s:Str ; a:Agr} = \np, prep ->
let
agr = case prep.c of { Nom => np.a ; _ => AgSgP3 Masc } ;
subj = appPrepNP prep np
subj = appSPrepNP prep np
in {s = subj ; a = agr} ;
sex2gender : Sex -> Gender = \g ->