mirror of
https://github.com/GrammaticalFramework/gf-rgl.git
synced 2026-06-30 02:58:35 -06:00
The files for GrammarGer and AllGer (but not Construction, Documentation, Markup)
are edited to allow for glued Prep+DefArt, using new categories NP',Det',Quant',
Predet',DAP'.
The previous NP.s : Case => Str*Str allows parsing
"in dem Meer" = in_Prep ++ (np.s ! Case).p1
"im Meer" = in_Prep ++ (np.s ! Case).p2,
but since only one of the strings of (np.s!Case) is used, the tree
contains a metavariable like ?2 (the grammar is "erasing"). (Similarly, if we used
NP.s : Case => Str and NP.s2 : Case => Str.)
To get rid of the metavariables, we have to choose BY A PARAMETER, say
NP.s : droppedDefArt? => Case => Str
Using np.a = Ag g n p, the preposition can select between preposition
alone or preposition with definite article (glued or not), via
Prep = {s : GenNum => Str ; s2 :Str ; c : Case ; isPrep : PrepType }
The combination is done in appPrepNP' and appPrep'. This is
independent of the number of glued Prep+DefArt. But LangGer compiles
now in 200s using 30% memory (without SlashV2VNP). Can AppPrepNP' (and
insertObjNP') be simplified?
This commit is contained in:
+47
-44
@@ -7,8 +7,7 @@ concrete NounGer of Noun' = CatGer ** open ResGer, MorphoGer, Prelude in {
|
||||
|
||||
lin
|
||||
DetCN det cn = {
|
||||
s = \\c => <(det.s ! cn.g ! c).quant,
|
||||
(det.s ! cn.g ! c).num ++ cn.s ! (adjfCase det.a c) ! det.n ! c ++ cn.adv> ;
|
||||
s = \\b,c => det.s ! b ! cn.g ! c ++ cn.s ! (adjfCase det.a c) ! det.n ! c ++ cn.adv ;
|
||||
a = agrgP3 cn.g det.n ;
|
||||
-- isLight = det.isDef ; -- ich sehe den Mann nicht vs. ich sehe nicht einen Mann
|
||||
-- isPron = False ; -- HL 6/2019 (but:) sehe (die|einige) Männer nicht
|
||||
@@ -24,7 +23,7 @@ concrete NounGer of Noun' = CatGer ** open ResGer, MorphoGer, Prelude in {
|
||||
} ;
|
||||
|
||||
DetNP det = { -- more genders in ExtraGer -- HL: der+er,den+en ; der drei,den drei+en
|
||||
s = \\c => <(det.sp ! Neutr ! c).quant, (det.sp ! Neutr ! c).num> ;
|
||||
s = \\b,c => det.sp ! b ! Neutr ! c ;
|
||||
a = agrP3 det.n ;
|
||||
-- isLight = det.isDef ;
|
||||
-- isPron = False ; -- HL 6/2019: don't apply pronoun switch: ich gebe ihr das vs. ich gebe es ihr
|
||||
@@ -33,14 +32,14 @@ concrete NounGer of Noun' = CatGer ** open ResGer, MorphoGer, Prelude in {
|
||||
} ;
|
||||
|
||||
UsePN pn = {
|
||||
s = \\c => <[], pn.s ! c> ;
|
||||
s = \\_,c => pn.s ! c ;
|
||||
a = agrgP3 pn.g Sg ;
|
||||
w = WLight' ; -- means: this is not a heavy NP, but comes before negation
|
||||
rc, ext = [] -- Pron => Light HL 6/2019: to regulate Pron/NonPronNP order
|
||||
} ;
|
||||
|
||||
UsePron pron = {
|
||||
s = \\c => <[], pron.s ! NPCase c> ;
|
||||
s = \\_,c => pron.s ! NPCase c ;
|
||||
a = pron.a ;
|
||||
w = WPron' ;
|
||||
rc, ext = []
|
||||
@@ -48,28 +47,27 @@ concrete NounGer of Noun' = CatGer ** open ResGer, MorphoGer, Prelude in {
|
||||
|
||||
PredetNP pred np =
|
||||
let ag = case pred.a of {PAg n => agrP3 n ; _ => np.a} in np ** {
|
||||
s = \\c0 =>
|
||||
s = \\b,c0 =>
|
||||
let c = case pred.c.k of {NoCase' => c0 ; PredCase' k => k} in
|
||||
<pred.s ! numberAgr ag ! genderAgr np.a ! c0 ++ pred.c.p ++ (np.s ! c).p1, (np.s ! c).p2> ;
|
||||
pred.s ! numberAgr ag ! genderAgr np.a ! c0 ++ pred.c.p ++ np.s ! b ! c ;
|
||||
a = ag ;
|
||||
w = WHeavy'
|
||||
w = WHeavy'
|
||||
} ;
|
||||
|
||||
PPartNP np v2 = np ** {
|
||||
s = incr2 np.s (embedInCommas (v2.s ! VPastPart APred)) ; --- invar part
|
||||
s = \\b,c => np.s ! b ! c ++ (embedInCommas (v2.s ! VPastPart APred)) ; --- invar part
|
||||
w = WHeavy'
|
||||
} ;
|
||||
{- "eine erfolgreiche Frau, geliebt von vielen," but only with v2 not possible in German?
|
||||
HL: PPartNP np vps|vp: "der Autor, heute vergessen" , "der Mond, gerade aufgegangen,"
|
||||
-}
|
||||
-- SS: "eine erfolgreiche Frau, geliebt von vielen," but only with v2 not possible in German?
|
||||
-- HL: PPartNP np vps|vp: "der Autor, heute vergessen" , "der Mond, gerade aufgegangen,"
|
||||
|
||||
AdvNP np adv = np ** {
|
||||
s = incr2 np.s adv.s ;
|
||||
s = \\b,c => np.s ! b ! c ++ adv.s ;
|
||||
w = WHeavy'
|
||||
} ;
|
||||
|
||||
ExtAdvNP np adv = np ** {
|
||||
s = incr2 np.s (embedInCommas adv.s) ;
|
||||
s = \\b,c => np.s ! b ! c ++ (embedInCommas adv.s) ;
|
||||
w = WHeavy'
|
||||
} ;
|
||||
|
||||
@@ -80,17 +78,17 @@ concrete NounGer of Noun' = CatGer ** open ResGer, MorphoGer, Prelude in {
|
||||
-- But parsing "im warmen Meer" results in a
|
||||
-- PrepNP in_Prep (DetCN (DetQuant ? NumSg) (AdjCN ... ))
|
||||
-- because (DetQuant.s!g!c).quant is ignored, but the .num is part of (np.s!c).p2.
|
||||
-- To avoid the metavariable ?, we have to make Det.s and NP.s depend on t:PrepType = isPrep.
|
||||
-- To avoid the metavariable ?, we have to made Det.s and NP.s depend on t:PrepType = isPrep.
|
||||
|
||||
DetQuantOrd quant num ord =
|
||||
let -- does not work, since here DefArt is combined with ord
|
||||
n = num.n ; --
|
||||
let
|
||||
n = num.n ;
|
||||
a = quant.a
|
||||
in {
|
||||
s = \\g,c => {quant = quant.s ! num.isNum ! n ! g ! c;
|
||||
num = num.s!g!c ++ ord.s ! agrAdj g (adjfCase a c) n c} ;
|
||||
sp = \\g,c => {quant = quant.sp ! num.isNum ! n ! g ! c;
|
||||
num = num.s!g!c ++ ord.s ! agrAdj g (adjfCase quant.aPl c) n c} ;
|
||||
s = \\b,g,c => quant.s ! b ! num.isNum ! n ! g ! c ++ num.s!g!c ++
|
||||
ord.s ! agrAdj g (adjfCase a c) n c ;
|
||||
sp = \\b,g,c => quant.sp ! b ! num.isNum ! n ! g ! c ++ num.s!g!c ++
|
||||
ord.s ! agrAdj g (adjfCase quant.aPl c) n c ;
|
||||
n = n ;
|
||||
a = case n of {Sg => a ; Pl => quant.aPl} ;
|
||||
isDef = case <quant.a, quant.aPl> of {<Strong,Strong> => False ; _ => True} ;
|
||||
@@ -100,10 +98,11 @@ concrete NounGer of Noun' = CatGer ** open ResGer, MorphoGer, Prelude in {
|
||||
DetQuant quant num =
|
||||
let
|
||||
n = num.n ;
|
||||
a = quant.a
|
||||
a = quant.a ;
|
||||
b = andB quant.hasDefArt (case num.n of {Sg => True ; _ => False}) ;
|
||||
in {
|
||||
s = \\g,c => {quant = quant.s ! num.isNum ! n ! g ! c ; num = num.s!g!c} ;
|
||||
sp = \\g,c => {quant = quant.sp ! num.isNum ! n ! g ! c ; num = num.s!g!c} ;
|
||||
s = \\b,g,c => quant.s ! b ! num.isNum ! n ! g ! c ++ num.s ! g ! c ;
|
||||
sp = \\_,g,c => quant.sp ! False ! num.isNum ! n ! g ! c ++ num.s!g!c ;
|
||||
-- HL: der+er,den+en ; der drei,den drei+en
|
||||
n = n ;
|
||||
a = case n of {Sg => a ; Pl => quant.aPl} ;
|
||||
@@ -112,8 +111,8 @@ concrete NounGer of Noun' = CatGer ** open ResGer, MorphoGer, Prelude in {
|
||||
} ;
|
||||
|
||||
PossPron p = {
|
||||
s = \\_,n,g,c => p.s ! NPPoss (gennum g n) c ;
|
||||
sp = \\_,n,g,c => p.s ! NPPoss (gennum g n) c ;
|
||||
s = \\_,_,n,g,c => p.s ! NPPoss (gennum g n) c ;
|
||||
sp = \\_,_,n,g,c => p.s ! NPPoss (gennum g n) c ;
|
||||
a = Strong ;
|
||||
aPl = Weak ;
|
||||
hasDefArt = False ;
|
||||
@@ -137,8 +136,9 @@ concrete NounGer of Noun' = CatGer ** open ResGer, MorphoGer, Prelude in {
|
||||
OrdNumeralSuperl n a = {s = \\af => n.s ! NOrd APred ++ Predef.BIND ++ a.s ! Superl ! af} ; -- drittbeste
|
||||
|
||||
DefArt = {
|
||||
s = \\_,n,g,c => artDef ! (gennum g n) ! c ;
|
||||
sp = \\_,n,g,c => case <n,c> of {
|
||||
s = table{True => \\_,n,g,c => [] ; -- defart dropped
|
||||
False => \\_,n,g,c => artDef ! (gennum g n) ! c} ;
|
||||
sp = \\_,_,n,g,c => case <n,c> of {
|
||||
<Pl,Dat> => "denen" ; -- HL 6/2019
|
||||
<Pl,Gen> => "derer" ; -- HL 6/2019
|
||||
_ => artDef ! (gennum g n) ! c } ;
|
||||
@@ -146,14 +146,14 @@ concrete NounGer of Noun' = CatGer ** open ResGer, MorphoGer, Prelude in {
|
||||
hasDefArt = True
|
||||
} ;
|
||||
IndefArt = {
|
||||
s = table {
|
||||
s = \\_ => table {
|
||||
True => \\_,_,c => [] ;
|
||||
False => table {
|
||||
Sg => \\g,c => "ein" + pronEnding ! GSg g ! c ;
|
||||
Pl => \\_,c => []
|
||||
}
|
||||
} ;
|
||||
sp = table {
|
||||
sp = \\_ => table {
|
||||
True => \\_,_,c => [] ;
|
||||
False => table {
|
||||
Sg => \\g,c => (detUnlikeAdj' False Sg "ein").s ! g ! c ;
|
||||
@@ -165,7 +165,7 @@ concrete NounGer of Noun' = CatGer ** open ResGer, MorphoGer, Prelude in {
|
||||
} ;
|
||||
|
||||
MassNP cn = {
|
||||
s = \\c => <[], cn.s ! Strong ! Sg ! c ++ cn.adv> ;
|
||||
s = \\_,c => cn.s ! Strong ! Sg ! c ++ cn.adv ;
|
||||
a = agrgP3 cn.g Sg ;
|
||||
-- isLight = True ; -- ich trinke Bier nicht vs. ich trinke kein Bier
|
||||
-- isPron = False ;
|
||||
@@ -231,33 +231,36 @@ concrete NounGer of Noun' = CatGer ** open ResGer, MorphoGer, Prelude in {
|
||||
AdvCN cn a = cn ** {adv = cn.adv ++ a.s} ;
|
||||
|
||||
ApposCN cn np = let g = cn.g in cn ** {
|
||||
s = \\a,n,c => cn.s ! a ! n ! c ++ (np.s ! c).p1 ++ (np.s ! c).p2 ++ bigNP' np } ;
|
||||
s = \\a,n,c => cn.s ! a ! n ! c ++ np.s ! False ! c ++ bigNP' np } ;
|
||||
|
||||
-- PossNP cn np = cn ** {
|
||||
-- s = \\a,n,c => cn.s ! a ! n ! c ++ np.s ! NPP CVonDat ++ bigNP np } ;
|
||||
PossNP cn np = cn ** {
|
||||
s = \\a,n,c => cn.s ! a ! n ! c ++ appPrep2' vonDat' np.s ++ bigNP' np } ; -- HL, ad hoc
|
||||
s = \\a,n,c => cn.s ! a ! n ! c ++ appPrep' vonDat' (np.s ! False) ++ bigNP' np } ; -- HL, ad hoc
|
||||
|
||||
-- PartNP cn np = todo -- glass of wine
|
||||
PartNP cn np = case np.w of {
|
||||
WPron' => cn ** {s = \\a,n,c => cn.s ! a ! n ! c ++ appPrep' vonDat' (np.s ! False) ++ np.rc} ;
|
||||
_ => cn ** {s = \\a,n,c => cn.s ! a ! n ! c ++ np.s ! False ! Gen} -- HL 7/2022, ad hoc
|
||||
}; -- glass of wine
|
||||
|
||||
CountNP det np = -- drei der Kinder | drei von den Kindern -- HL 7/22, ad-hoc
|
||||
CountNP det np = -- drei der Kinder | drei von den Kindern -- HL 7/22, ad-hoc TODO
|
||||
-- det or numeral? np or rather (DefArt +) cn? drei (einiger Kinder) ?
|
||||
let g = genderAgr np.a
|
||||
in {
|
||||
s = \\c => det.s ! g ! c ++ np.s ! NPP CVonDat ++ bigNP np ;
|
||||
s = \\b,c => det.s ! b ! g ! c ++ appPrepNP' vonDat' np ++ bigNP' np ;
|
||||
a = agrgP3 g det.n ;
|
||||
w = case det.isDef of { True => WLight ; _ => WHeavy } ;
|
||||
w = case det.isDef of { True => WLight' ; _ => WHeavy' } ;
|
||||
rc = np.rc ;
|
||||
ext = np.ext
|
||||
} ;
|
||||
|
||||
-- AdjDAP dap adj = ?? TODO -- the large (one)
|
||||
|
||||
DetDAP det = {s = \\g,c => (det.s ! g ! c).quant ++ (det.s ! g ! c).num ; -- HL 7/22
|
||||
sp = \\g,c => (det.sp ! g ! c).quant ++ (det.sp ! g ! c).num ;
|
||||
AdjDAP dap ap = -- the large (one) -- HL 8/22 der auf dich stolze; die ihm treue; der so dumme, infzu
|
||||
{s, sp = \\g,c => dap.s ! g ! c ++ ap.c.p1 ++ ap.c.p2 ++ ap.s ! (AMod (gennum g dap.n) c) ++ ap.ext ;
|
||||
a = dap.a ; n = dap.n ; isDef = dap.isDef ; hasDefArt = dap.hasDefArt } ;
|
||||
|
||||
DetDAP det = {s = \\g,c => det.s ! False ! g ! c ; -- HL 7/22 todo: check
|
||||
sp = \\g,c => det.sp ! False ! g ! c ;
|
||||
n = det.n ; a = det.a ; isDef = det.isDef ; hasDefArt = det.hasDefArt} ;
|
||||
oper
|
||||
incr2 : (Case => Str * Str) -> Str -> (Case => Str * Str) = \tab,str ->
|
||||
\\c => <(tab ! c).p1, (tab ! c).p2 ++ str> ;
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user