mirror of
https://github.com/GrammaticalFramework/gf-rgl.git
synced 2026-06-28 20:36:29 -06:00
1. updated types in ../abstract/*'.gf to replace NP,Det,Quant,Predep,Prep,DAP by
their primed versions 2. implemented all linearizations to use the primed categories This allows linearization with prep+defart's, but parsing gives metavariables in parses (DetQuant ? NumSg) and (DetQuantOrd ? NumSg ord) for prep+defart. Todo: make Quant.s and NP. depend on PronType = isCat | isPron | isPronDefArt. Without SlashV2VNP', compiles in 84 sec and gives 3,6M VerbGer.gfo, 2,3M SentenceGer.gfo. Uses |Prep'|=12 instead of |Prep|=18, |NP'|=72 instead of |NP|=54
This commit is contained in:
+105
-124
@@ -7,142 +7,116 @@ concrete NounGer of Noun' = CatGer ** open ResGer, MorphoGer, Prelude in {
|
||||
|
||||
lin
|
||||
DetCN det cn = {
|
||||
s = \\c => det.s ! cn.g ! c ++
|
||||
(let k = (prepC c).c in cn.s ! adjfCase det.a k ! det.n ! k ++ cn.adv) ;
|
||||
a = agrgP3 cn.g det.n ;
|
||||
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> ;
|
||||
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
|
||||
-- don't see a|no man = sehe keinen Mann
|
||||
w = case det.isDef of { True => WLight ; _ => WHeavy } ;
|
||||
rc = cn.rc ! det.n ;
|
||||
ext = cn.ext
|
||||
} ;
|
||||
|
||||
-- HL:
|
||||
DetCN' det' cn = {
|
||||
s = \\c => <det'.s ! 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
|
||||
-- don't see a|no man = sehe keinen Mann
|
||||
-- w = case det'.isDef of { True => WLight' ; _ => WHeavy' } ;
|
||||
-- w = case det.isDef of { True => WLight' ; _ => WHeavy' } ;
|
||||
-- Would be clearer with w:Weight and hasDefArt:Bool with |NP|=|Agr|*3*2 = 108
|
||||
-- instead of the more efficient w:Weigth' with |NP|=|Agr|*4 = 18*4 = 54
|
||||
w = case det'.isDef of { True => case det'.hasDefArt of { True => WDefArt ;
|
||||
_ => WLight' } ;
|
||||
_ => WHeavy'
|
||||
} ;
|
||||
rc = cn.rc ! det'.n ;
|
||||
w = case det.isDef of { True => case det.hasDefArt of { True => WDefArt ;
|
||||
_ => WLight' } ;
|
||||
_ => WHeavy' } ;
|
||||
rc = cn.rc ! det.n ;
|
||||
ext = cn.ext
|
||||
} ;
|
||||
|
||||
DetNP det = {
|
||||
s = \\c => det.sp ! Neutr ! c ; -- more genders in ExtraGer -- HL: der+er,den+en ; der drei,den drei+en
|
||||
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> ;
|
||||
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
|
||||
w = case det.isDef of { True => WLight ; _ => WHeavy } ;
|
||||
w = case det.isDef of { True => WLight' ; _ => WHeavy' } ;
|
||||
rc, ext = []
|
||||
} ;
|
||||
|
||||
UsePN pn = {
|
||||
s = \\c => usePrepC c (\k -> pn.s ! k) ;
|
||||
s = \\c => <[], pn.s ! c> ;
|
||||
a = agrgP3 pn.g Sg ;
|
||||
-- isLight = True ; -- means: this is not a heavy NP, but comes before negation
|
||||
-- isPron = False ; -- HL 6/2019: to regulate Pron/NonPronNP order
|
||||
w = WLight ;
|
||||
rc, ext = []
|
||||
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 => usePrepC c (\k -> pron.s ! NPCase k) ;
|
||||
s = \\c => <[], pron.s ! NPCase c> ;
|
||||
a = pron.a ;
|
||||
-- isLight = True ;
|
||||
-- isPron = True ;
|
||||
w = WPron ;
|
||||
w = WPron' ;
|
||||
rc, ext = []
|
||||
} ;
|
||||
|
||||
PredetNP pred np =
|
||||
let ag = case pred.a of {PAg n => agrP3 n ; _ => np.a} in np ** {
|
||||
s = \\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 ;
|
||||
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> ;
|
||||
a = ag ;
|
||||
-- isLight = False ;
|
||||
-- isPron = False
|
||||
w = WHeavy
|
||||
w = WHeavy'
|
||||
} ;
|
||||
|
||||
PPartNP np v2 = np ** {
|
||||
s = \\c => np.s ! c ++ embedInCommas (v2.s ! VPastPart APred) ; --- invar part
|
||||
-- isPron = False
|
||||
w = WHeavy
|
||||
s = incr2 np.s (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,"
|
||||
-}
|
||||
|
||||
AdvNP np adv = np ** {
|
||||
s = \\c => np.s ! c ++ adv.s ;
|
||||
-- isLight = False ;
|
||||
-- isPron = False
|
||||
w = WHeavy
|
||||
s = incr2 np.s adv.s ;
|
||||
w = WHeavy'
|
||||
} ;
|
||||
|
||||
ExtAdvNP np adv = np ** {
|
||||
s = \\c => np.s ! c ++ embedInCommas adv.s ;
|
||||
-- isLight = False ;
|
||||
-- isPron = False
|
||||
w = WHeavy
|
||||
s = incr2 np.s (embedInCommas adv.s) ;
|
||||
w = WHeavy'
|
||||
} ;
|
||||
|
||||
DetQuantOrd quant num ord =
|
||||
let
|
||||
n = num.n ;
|
||||
a = quant.a
|
||||
in {
|
||||
s = \\g,c => quant.s ! num.isNum ! n ! g ! c ++ (let k = (prepC c).c in
|
||||
num.s!g!k ++ ord.s ! agrAdj g (adjfCase a k) n k) ;
|
||||
sp = \\g,c => quant.sp ! num.isNum ! n ! g ! c ++ (let k = (prepC c).c in
|
||||
num.s!g!k ++ ord.s ! agrAdj g (adjfCase quant.aPl k) n k) ;
|
||||
n = n ;
|
||||
a = case n of {Sg => a ; Pl => quant.aPl} ;
|
||||
isDef = case <quant.a, quant.aPl> of {<Strong,Strong> => False ; _ => True} ;
|
||||
} ;
|
||||
-- HL 21.7.2022: the dropping of DefArt in Prep+DefArt via hasDefArt works by splitting the
|
||||
-- np.s into det':Str and cn:Str and (det.s ! g ! n) into {quant:Str; num:Str}, so that in
|
||||
-- PrepNP in_Prep np we can replace "in" + "das" by "im" to get
|
||||
-- PrepNP in_Prep (DetCN (DetQuant DefArt NumSg) (warme Meer)) => im warmen Meer
|
||||
-- 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.
|
||||
|
||||
DetQuant quant num =
|
||||
let
|
||||
n = num.n ;
|
||||
DetQuantOrd quant num ord =
|
||||
let -- does not work, since here DefArt is combined with ord
|
||||
n = num.n ; --
|
||||
a = quant.a
|
||||
in {
|
||||
s = \\g,c => quant.s ! num.isNum ! n ! g ! c ++ (let k = (prepC c).c in
|
||||
num.s!g!k) ;
|
||||
sp = \\g,c => quant.sp ! num.isNum ! n ! g ! c ++ (let k = (prepC c).c in
|
||||
num.s!g!k) ; -- HL: der+er,den+en ; der drei,den drei+en
|
||||
n = n ;
|
||||
a = case n of {Sg => a ; Pl => quant.aPl} ;
|
||||
isDef = case <quant.a, quant.aPl> of {<Strong,Strong> => False ; _ => True} ;
|
||||
} ;
|
||||
DetQuant' quant num =
|
||||
let
|
||||
n = num.n ;
|
||||
a = quant.a
|
||||
in {
|
||||
s = \\g,c => quant.s ! num.isNum ! n ! g ! c ++ num.s!g!c ;
|
||||
sp = \\g,c => quant.sp ! num.isNum ! n ! g ! c ++ num.s!g!c ; -- HL: der+er,den+en ; der drei,den drei+en
|
||||
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} ;
|
||||
n = n ;
|
||||
a = case n of {Sg => a ; Pl => quant.aPl} ;
|
||||
isDef = case <quant.a, quant.aPl> of {<Strong,Strong> => False ; _ => True} ;
|
||||
hasDefArt = quant.hasDefArt ;
|
||||
} ;
|
||||
|
||||
DetQuant quant num =
|
||||
let
|
||||
n = num.n ;
|
||||
a = quant.a
|
||||
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} ;
|
||||
-- HL: der+er,den+en ; der drei,den drei+en
|
||||
n = n ;
|
||||
a = case n of {Sg => a ; Pl => quant.aPl} ;
|
||||
isDef = case <quant.a, quant.aPl> of {<Strong,Strong> => False ; _ => True} ;
|
||||
hasDefArt = quant.hasDefArt ;
|
||||
} ;
|
||||
|
||||
PossPron p = {
|
||||
s = \\_,n,g,c => usePrepC c (\k -> p.s ! NPPoss (gennum g n) k) ;
|
||||
sp = \\_,n,g,c => usePrepC c (\k -> p.s ! NPPoss (gennum g n) k) ;
|
||||
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 ;
|
||||
} ;
|
||||
|
||||
NumCard n = n ** {isNum = True} ;
|
||||
@@ -163,39 +137,6 @@ 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 => artDefContr (gennum g n) c ;
|
||||
-- sp = \\_,n,g,c => artDefContr (gennum g n) c ; ---- deren, denen ...
|
||||
sp = \\_,n,g,c => case <n,c> of {
|
||||
<Sg,NPP p> => let sp = prepC c ; gn = gennum g n
|
||||
in sp.s ++ artDef ! gn ! sp.c ;
|
||||
<Pl,NPP CInAcc> => let sp = prepC c in sp.s ++ "die" ;
|
||||
<Pl,NPP p> => let sp = prepC c ; gn = gennum g n
|
||||
in sp.s ++ (artDef ! gn ! sp.c + "en") ;
|
||||
<Pl,NPC Dat> => "denen" ; -- HL 6/2019
|
||||
<Pl,NPC Gen> => "derer" ; -- HL 6/2019
|
||||
_ => artDefContr (gennum g n) c } ; -- von den+en
|
||||
a, aPl = Weak
|
||||
} ;
|
||||
|
||||
IndefArt = {
|
||||
s = table {
|
||||
True => \\_,_,c => usePrepC c (\k -> []) ;
|
||||
False => table {
|
||||
Sg => \\g,c => usePrepC c (\k -> "ein" + pronEnding ! GSg g ! k) ;
|
||||
Pl => \\_,c => usePrepC c (\k -> [])
|
||||
}
|
||||
} ;
|
||||
sp = table {
|
||||
True => \\_,_,c => usePrepC c (\k -> []) ;
|
||||
False => table {
|
||||
Sg => \\g,c => usePrepC c (\k -> (detUnlikeAdj False Sg "ein").s ! g ! NPC k) ;
|
||||
Pl => \\_,c => usePrepC c (\k -> caselist "einige" "einige" "einigen" "einiger" ! k)
|
||||
}
|
||||
} ;
|
||||
a, aPl = Strong
|
||||
} ;
|
||||
-- HL
|
||||
DefArt' = {
|
||||
s = \\_,n,g,c => artDef ! (gennum g n) ! c ;
|
||||
sp = \\_,n,g,c => case <n,c> of {
|
||||
<Pl,Dat> => "denen" ; -- HL 6/2019
|
||||
@@ -204,15 +145,34 @@ concrete NounGer of Noun' = CatGer ** open ResGer, MorphoGer, Prelude in {
|
||||
a, aPl = Weak ;
|
||||
hasDefArt = True
|
||||
} ;
|
||||
IndefArt = {
|
||||
s = table {
|
||||
True => \\_,_,c => [] ;
|
||||
False => table {
|
||||
Sg => \\g,c => "ein" + pronEnding ! GSg g ! c ;
|
||||
Pl => \\_,c => []
|
||||
}
|
||||
} ;
|
||||
sp = table {
|
||||
True => \\_,_,c => [] ;
|
||||
False => table {
|
||||
Sg => \\g,c => (detUnlikeAdj' False Sg "ein").s ! g ! c ;
|
||||
Pl => \\_,c => caselist "einige" "einige" "einigen" "einiger" ! c
|
||||
}
|
||||
} ;
|
||||
a, aPl = Strong ;
|
||||
hasDefArt = False
|
||||
} ;
|
||||
|
||||
MassNP cn = {
|
||||
s = \\c => usePrepC c (\k -> cn.s ! Strong ! Sg ! k) ++ 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 ;
|
||||
w = WLight ;
|
||||
w = WLight' ;
|
||||
rc = cn.rc ! Sg ;
|
||||
ext = cn.ext
|
||||
ext = cn.ext ;
|
||||
hasDefArt = False
|
||||
} ;
|
||||
|
||||
UseN, UseN2 = \n -> {
|
||||
@@ -262,9 +222,8 @@ concrete NounGer of Noun' = CatGer ** open ResGer, MorphoGer, Prelude in {
|
||||
---- another layer of embedInCommas needed if there is a non-empty rc
|
||||
|
||||
RelNP np rs = np ** {
|
||||
rc = (np.rc ++ embedInCommas (rs.s ! RGenNum (gennum (genderAgr np.a) (numberAgr np.a)))) ;
|
||||
-- isPron = False
|
||||
w = case isPron np of { True => WLight ; _ => np.w }
|
||||
rc = np.rc ++ embedInCommas (rs.s ! RGenNum (gennum (genderAgr np.a) (numberAgr np.a))) ;
|
||||
w = case isPron' np of { True => WLight' ; _ => np.w }
|
||||
} ;
|
||||
|
||||
SentCN cn s = cn ** {ext = cn.ext ++ embedInCommas s.s} ;
|
||||
@@ -272,11 +231,33 @@ 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 ! NPC c ++ bigNP np } ;
|
||||
s = \\a,n,c => cn.s ! a ! n ! c ++ (np.s ! c).p1 ++ (np.s ! c).p2 ++ 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 ++ np.s ! NPP CVonDat ++ bigNP np } ;
|
||||
s = \\a,n,c => cn.s ! a ! n ! c ++ appPrep2' vonDat' np.s ++ bigNP' np } ; -- HL, ad hoc
|
||||
|
||||
DetDAP det = det ;
|
||||
-- PartNP cn np = todo -- glass of wine
|
||||
|
||||
CountNP det np = -- drei der Kinder | drei von den Kindern -- HL 7/22, ad-hoc
|
||||
-- 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 ;
|
||||
a = agrgP3 g det.n ;
|
||||
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 ;
|
||||
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