From b7cb68eb08697a83269028d44cc1e13b44a40514 Mon Sep 17 00:00:00 2001 From: aarne Date: Wed, 7 Dec 2005 20:10:30 +0000 Subject: [PATCH] scand questions --- lib/resource-1.0/scandinavian/CatScand.gf | 2 +- lib/resource-1.0/scandinavian/DiffScand.gf | 43 ++++--- lib/resource-1.0/scandinavian/ParamScand.gf | 8 +- .../scandinavian/QuestionScand.gf | 120 ++++++++++-------- lib/resource-1.0/scandinavian/ResScand.gf | 18 ++- .../scandinavian/SentenceScand.gf | 61 ++++----- lib/resource-1.0/swedish/DiffSwe.gf | 2 + lib/resource-1.0/swedish/QuestionSwe.gf | 2 + lib/resource-1.0/swedish/TestSwe.gf | 2 +- 9 files changed, 142 insertions(+), 116 deletions(-) create mode 100644 lib/resource-1.0/swedish/QuestionSwe.gf diff --git a/lib/resource-1.0/scandinavian/CatScand.gf b/lib/resource-1.0/scandinavian/CatScand.gf index faa210d79..3716c29a1 100644 --- a/lib/resource-1.0/scandinavian/CatScand.gf +++ b/lib/resource-1.0/scandinavian/CatScand.gf @@ -19,7 +19,7 @@ incomplete concrete CatScand of Cat = -- Constructed in $Verb$. VP = { - s : SForm => { + s : VPForm => { fin : Str ; -- V1 har ---s1 inf : Str -- V2 sagt ---s4 } ; diff --git a/lib/resource-1.0/scandinavian/DiffScand.gf b/lib/resource-1.0/scandinavian/DiffScand.gf index ebf99e499..960024865 100644 --- a/lib/resource-1.0/scandinavian/DiffScand.gf +++ b/lib/resource-1.0/scandinavian/DiffScand.gf @@ -5,18 +5,11 @@ interface DiffScand = open ResScand, Prelude in { param Gender ; - CardOrd = NCard Gender | NOrd AFormSup ; -- sic! (AFormSup) - oper neutrum, utrum : Gender ; gennum : Gender -> Number -> GenNum ; - agrP3 : Gender -> Number -> Agr = \g,n -> { - gn = gennum g n ; - p = P3 - } ; - -- This is the form of the noun in "det stora berget"/"det store berg". detDef : Species ; @@ -27,6 +20,8 @@ interface DiffScand = open ResScand, Prelude in { conjThan : Str ; infMark : Str ; + subjIf : Str ; + artIndef : Gender => Str ; verbHave : {s : VForm => Str} ; @@ -37,9 +32,28 @@ interface DiffScand = open ResScand, Prelude in { negation : Polarity => Str ; +-- For determiners; mostly two-valued even in Norwegian. + + genderForms : (x1,x2 : Str) -> Gender => Str ; + +----------------------------------------------------------------------- +-- +-- The functions and parameters below are here because they depend on +-- the parametrized constants, but their definitions are fully given +-- here relative to the above. + + param + CardOrd = NCard Gender | NOrd AFormSup ; -- sic! (AFormSup) + + oper + agrP3 : Gender -> Number -> Agr = \g,n -> { + gn = gennum g n ; + p = P3 + } ; + -- This function is here because it depends on $verbHave, auxFut, auxCond$. - predV : Verb -> VP = \verb -> + predV : Verb -> VP = \verb -> let vfin : Tense -> Str = \t -> verb.s ! vFin t Act ; vsup = verb.s ! VI (VSupin Act) ; @@ -54,19 +68,19 @@ interface DiffScand = open ResScand, Prelude in { in { s = table { - VFinite t Simul => case t of { + VPFinite t Simul => case t of { Pres | Past => vf (vfin t) [] ; Fut => vf auxFut vinf ; Cond => vf auxCond vinf } ; - VFinite t Anter => case t of { + VPFinite t Anter => case t of { Pres | Past => vf (har t) vsup ; Fut => vf auxFut (ha ++ vsup) ; Cond => vf auxCond (ha ++ vsup) } ; - VImperat => vf (verb.s ! VF (VImper Act)) [] ; - VInfinit Simul => vf [] vinf ; - VInfinit Anter => vf [] (ha ++ vsup) + VPImperat => vf (verb.s ! VF (VImper Act)) [] ; + VPInfinit Simul => vf [] vinf ; + VPInfinit Anter => vf [] (ha ++ vsup) } ; a1 : Polarity => Str = negation ; n2 : Agr => Str = \\_ => [] ; @@ -75,8 +89,5 @@ interface DiffScand = open ResScand, Prelude in { en2,ea2,eext : Bool = False -- indicate if the field exists } ; --- For determiners; mostly two-valued even in Norwegian. - - genderForms : (x1,x2 : Str) -> Gender => Str ; } diff --git a/lib/resource-1.0/scandinavian/ParamScand.gf b/lib/resource-1.0/scandinavian/ParamScand.gf index 12c7adc41..38a1d3c61 100644 --- a/lib/resource-1.0/scandinavian/ParamScand.gf +++ b/lib/resource-1.0/scandinavian/ParamScand.gf @@ -37,10 +37,10 @@ param | VSupin Voice | VPtPret AFormPos Case ; - SForm = - VFinite Tense Anteriority - | VImperat - | VInfinit Anteriority ; + VPForm = + VPFinite Tense Anteriority + | VPImperat + | VPInfinit Anteriority ; NPForm = NPNom | NPAcc | NPPoss GenNum ; --- AdjPronForm = APron GenNum Case ; diff --git a/lib/resource-1.0/scandinavian/QuestionScand.gf b/lib/resource-1.0/scandinavian/QuestionScand.gf index 4d6b5d6af..8444f4427 100644 --- a/lib/resource-1.0/scandinavian/QuestionScand.gf +++ b/lib/resource-1.0/scandinavian/QuestionScand.gf @@ -1,54 +1,66 @@ ---concrete QuestionScand of Question = CatScand ** open ResScand in { --- --- flags optimize=all_subs ; --- --- lin --- --- QuestCl cl = { --- s = \\t,a,p => --- let cls = cl.s ! t ! a ! p --- in table { --- QDir => cls ! OQuest ; --- QIndir => "if" ++ cls ! ODir --- } ---- "whether" in ExtScand --- } ; --- --- QuestVP qp vp = --- let cl = mkS (qp.s ! Nom) {n = qp.n ; p = P3} vp.s vp.s2 --- in {s = \\t,a,b,_ => cl.s ! t ! a ! b ! ODir} ; --- --- QuestSlash ip slash = { --- s = \\t,a,p => --- let --- cls = slash.s ! t ! a ! p ; --- who = slash.c2 ++ ip.s ! Acc --- stranding in ExtScand --- in table { --- QDir => who ++ cls ! OQuest ; --- QIndir => who ++ cls ! ODir --- } --- } ; --- --- QuestIAdv iadv cl = { --- s = \\t,a,p => --- let --- cls = cl.s ! t ! a ! p ; --- why = iadv.s --- in table { --- QDir => why ++ cls ! OQuest ; --- QIndir => why ++ cls ! ODir --- } --- } ; --- --- PrepIP p ip = {s = p.s ++ ip.s ! Nom} ; --- --- AdvIP ip adv = { --- s = \\c => ip.s ! c ++ adv.s ; --- n = ip.n --- } ; --- --- IDetCN idet num ord cn = { --- s = \\c => idet.s ++ num.s ++ ord.s ++ cn.s ! idet.n ! c ; --- n = idet.n --- } ; --- ---} +incomplete concrete QuestionScand of Question = + CatScand ** open DiffScand, ResScand in { + + flags optimize=all_subs ; + + lin + + QuestCl cl = { + s = \\t,a,p => + let cls = cl.s ! t ! a ! p + in table { + QDir => cls ! Inv ; + QIndir => subjIf ++ cls ! Sub + } + } ; + + QuestVP qp vp = { + s = \\t,a,b,q => + let + somo = case q of { + QIndir => <"som",Sub> ; + _ => <[], Main> + } ; + cl = mkClause (qp.s ! nominative ++ somo.p1) {gn = qp.gn ; p = P3} vp + in + cl.s ! t ! a ! b ! somo.p2 + } ; + + QuestSlash ip slash = { + s = \\t,a,p => + let + cls = slash.s ! t ! a ! p ; + who = slash.c2 ++ ip.s ! accusative --- stranding in ExtScand + in table { + QDir => who ++ cls ! Inv ; + QIndir => who ++ cls ! Sub + } + } ; + + QuestIAdv iadv cl = { + s = \\t,a,p => + let + cls = cl.s ! t ! a ! p ; + why = iadv.s + in table { + QDir => why ++ cls ! Inv ; + QIndir => why ++ cls ! Sub + } + } ; + + PrepIP p ip = { + s = p.s ++ ip.s ! accusative + } ; + + AdvIP ip adv = { + s = \\c => ip.s ! c ++ adv.s ; + gn = ip.gn + } ; + + IDetCN idet num ord cn = let g = cn.g in { + s = \\c => + idet.s ! g ++ num.s ! g ++ ord.s ++ cn.s ! idet.n ! idet.det ! caseNP c ; + gn = gennum g idet.n + } ; + +} diff --git a/lib/resource-1.0/scandinavian/ResScand.gf b/lib/resource-1.0/scandinavian/ResScand.gf index 27fd2f212..6e29532df 100644 --- a/lib/resource-1.0/scandinavian/ResScand.gf +++ b/lib/resource-1.0/scandinavian/ResScand.gf @@ -138,9 +138,9 @@ resource ResScand = ParamScand ** open Prelude in { } ; VP = { - s : SForm => { - fin : Str ; -- V1 har ---s1 - inf : Str -- V2 sagt ---s4 + s : VPForm => { + fin : Str ; -- V1 har ---s1 + inf : Str -- V2 sagt ---s4 } ; a1 : Polarity => Str ; -- A1 inte ---s3 n2 : Agr => Str ; -- N2 dig ---s5 @@ -188,7 +188,7 @@ resource ResScand = ParamScand ** open Prelude in { -- agrVerb (verb.s ! VPres) (verb.s ! VInf) ; infVP : VP -> Agr -> Str = \vp,a -> - (vp.s ! VInfinit Simul).inf ++ vp.n2 ! a ++ vp.a2 ++ vp.ext ; --- a1 + (vp.s ! VPInfinit Simul).inf ++ vp.n2 ! a ++ vp.a2 ++ vp.ext ; --- a1 -- agrVerb : Str -> Str -> Agr -> Str = \has,have,agr -> -- case agr of { @@ -236,14 +236,12 @@ resource ResScand = ParamScand ** open Prelude in { s : Tense => Anteriority => Polarity => Order => Str } ; - mkS : Str -> Agr -> - (SForm => {fin,inf : Str}) -> (Polarity => Str) -> (Agr => Str) -> Clause = - \subj,agr,verb,adv,compl0 -> { + mkClause : Str -> Agr -> VP -> Clause = \subj,agr,vp -> { s = \\t,a,b,o => let - verb = verb ! VFinite t a ; - neg = adv ! b ; - compl = compl0 ! agr + verb = vp.s ! VPFinite t a ; + neg = vp.a1 ! b ; + compl = vp.n2 ! agr ++ vp.a2 ++ vp.ext in case o of { Main => subj ++ verb.fin ++ neg ++ verb.inf ++ compl ; diff --git a/lib/resource-1.0/scandinavian/SentenceScand.gf b/lib/resource-1.0/scandinavian/SentenceScand.gf index 0234c3a0a..98e1177b5 100644 --- a/lib/resource-1.0/scandinavian/SentenceScand.gf +++ b/lib/resource-1.0/scandinavian/SentenceScand.gf @@ -4,35 +4,36 @@ incomplete concrete SentenceScand of Sentence = flags optimize=all_subs ; lin - PredVP np vp = mkS (np.s ! nominative) np.a vp.s vp.a1 vp.n2 ; + PredVP np vp = mkClause (np.s ! nominative) np.a vp ; + + PredSCVP sc vp = mkClause sc.s (agrP3 neutrum Sg) vp ; + + ImpVP vp = { + s = \\pol,n => + let + agr = {gn = gennum utrum n ; p = P2} ; + verb = vp.s ! VPImperat ; + in + verb.fin ++ vp.a1 ! pol ++ verb.inf ++ vp.n2 ! agr ++ vp.a2 ++ vp.ext + } ; + + SlashV2 np v2 = + mkClause + (np.s ! nominative) np.a + (predV v2) ** + {c2 = v2.c2} ; + + SlashVVV2 np vv v2 = + mkClause + (np.s ! nominative) np.a + (insertObj (\\_ => vv.c2 ++ infVP (predV v2) np.a) (predV vv)) ** + {c2 = v2.c2} ; + + AdvSlash slash adv = { + s = \\t,a,b,o => slash.s ! t ! a ! b ! o ++ adv.s ; + c2 = slash.c2 + } ; + + SlashPrep cl prep = cl ** {c2 = prep.s} ; --- PredSCVP sc vp = mkS sc.s (agrP3 Sg) vp.s vp.s2 ; --- --- ImpVP vp = { --- s = \\pol,n => --- let --- agr = {n = n ; p = P2} ; --- verb = infVP vp agr ; --- dont = case pol of { --- Neg => "don't" ; --- _ => [] --- } --- in --- dont ++ verb --- } ; --- --- SlashV2 np v2 = mkS (np.s ! Nom) np.a (predV v2).s (\\_ => []) ** --- {c2 = v2.c2} ; --- --- SlashVVV2 np vv v2 = --- mkS (np.s ! Nom) np.a (predV vv).s (\\_ => "to" ++ v2.s ! VInf) ** --- {c2 = v2.c2} ; --- --- AdvSlash slash adv = { --- s = \\t,a,b,o => slash.s ! t ! a ! b ! o ++ adv.s ; --- c2 = slash.c2 --- } ; --- --- SlashPrep cl prep = cl ** {c2 = prep.s} ; --- } diff --git a/lib/resource-1.0/swedish/DiffSwe.gf b/lib/resource-1.0/swedish/DiffSwe.gf index 2e2e79d6e..42a6191f3 100644 --- a/lib/resource-1.0/swedish/DiffSwe.gf +++ b/lib/resource-1.0/swedish/DiffSwe.gf @@ -24,6 +24,8 @@ instance DiffSwe of DiffScand = open ResScand, Prelude in { conjThan = "än" ; infMark = "att" ; + subjIf = "om" ; + artIndef : Gender => Str = table { Utr => "en" ; Neutr => "ett" diff --git a/lib/resource-1.0/swedish/QuestionSwe.gf b/lib/resource-1.0/swedish/QuestionSwe.gf new file mode 100644 index 000000000..001cecf53 --- /dev/null +++ b/lib/resource-1.0/swedish/QuestionSwe.gf @@ -0,0 +1,2 @@ +concrete QuestionSwe of Question = CatSwe ** QuestionScand with + (DiffScand = DiffSwe) ; diff --git a/lib/resource-1.0/swedish/TestSwe.gf b/lib/resource-1.0/swedish/TestSwe.gf index 226c0a66c..67a55ad33 100644 --- a/lib/resource-1.0/swedish/TestSwe.gf +++ b/lib/resource-1.0/swedish/TestSwe.gf @@ -7,7 +7,7 @@ concrete TestSwe of Test = AdverbSwe, -- -- NumeralSwe, SentenceSwe, --- QuestionSwe, + QuestionSwe, -- RelativeSwe, -- ConjunctionSwe, PhraseSwe,