diff --git a/lib/resource/danish/CategoriesDan.gf b/lib/resource/danish/CategoriesDan.gf new file mode 100644 index 000000000..171bf6600 --- /dev/null +++ b/lib/resource/danish/CategoriesDan.gf @@ -0,0 +1,4 @@ +--# -path=.:../scandinavian:../abstract:../../prelude + +concrete CategoriesDan of Categories = + CategoriesScand with (SyntaxScand=SyntaxDan) ; diff --git a/lib/resource/danish/MorphoDan.gf b/lib/resource/danish/MorphoDan.gf new file mode 100644 index 000000000..f7509e068 --- /dev/null +++ b/lib/resource/danish/MorphoDan.gf @@ -0,0 +1,228 @@ +--1 A Simple Danish Resource Morphology +-- +-- Aarne Ranta 2002 +-- +-- This resource morphology contains definitions needed in the resource +-- syntax. It moreover contains copies of the most usual inflectional patterns +-- as defined in functional morphology (in the Haskell file $RulesSw.hs$). +-- +-- We use the parameter types and word classes defined for morphology. + +resource MorphoDan = open Prelude, TypesDan in { + +-- Danish grammar source: http://users.cybercity.dk/~nmb3879/danish.html + +-- nouns + +oper + mkSubstantive : (_,_,_,_ : Str) -> {s : SubstForm => Str} = + \dreng, drengen, drenge, drengene -> {s = table { + SF Sg Indef c => mkCase dreng ! c ; + SF Sg Def c => mkCase drengen ! c ; + SF Pl Indef c => mkCase drenge ! c ; + SF Pl Def c => mkCase drengene ! c + } + } ; + + mkCase : Str -> Case => Str = \bil -> table { + Nom => bil ; + Gen => bil + "s" --- but: hus --> hus + } ; + + nDreng : Str -> Subst = \dreng -> + mkSubstantive dreng (dreng + "en") (dreng + "e") (dreng + "ene") ** + {h1 = Utr} ; + + nBil : Str -> Subst = \bil -> + mkSubstantive bil (bil + "en") (bil + "er") (bil + "erne") ** + {h1 = Utr} ; + + nUge : Str -> Subst = \uge -> + mkSubstantive uge (uge + "n") (uge + "r") (uge + "rne") ** + {h1 = Utr} ; + + nHus : Str -> Subst = \hus -> + mkSubstantive hus (hus + "et") hus (hus + "ene") ** + {h1 = Neutr} ; + +-- adjectives + + mkAdjective : (_,_,_,_,_ : Str) -> Adj = + \stor,stort,store,storre,storst -> {s = table { + AF (Posit (Strong (ASg Utr))) c => mkCase stor ! c ; + AF (Posit (Strong (ASg Neutr))) c => mkCase stort ! c ; + AF (Posit _) c => mkCase store ! c ; + AF Compar c => mkCase storre ! c ; + AF (Super SupStrong) c => mkCase storst ! c ; + AF (Super SupWeak) c => mkCase (storst + "e") ! c + } + } ; + + aRod : Str -> Adj = \rod -> + mkAdjective rod (rod + "t") (rod + "e") (rod + "ere") (rod + "est") ; + + aAbstrakt : Str -> Adj = \abstrakt -> + mkAdjective abstrakt abstrakt (abstrakt + "e") (abstrakt + "ere") (abstrakt + "est") ; + + aRask : Str -> Adj = \rask -> + mkAdjective rask rask (rask + "e") (rask + "ere") (rask + "est") ; + +-- verbs + + mkVerb : (_,_,_,_,_,_ : Str) -> Verbum = + \spise,spiser,spises,spiste,spist,spis -> {s = table { + VI (Inf v) => mkVoice v spise ; + VF (Pres m Act) => spiser ; + VF (Pres m Pass) => spises ; + VF (Pret m v) => mkVoice v spiste ; + VI (Supin v) => mkVoice v spist ; + VI (PtPret c) => mkCase spist ! c ; + VF Imper => spis + } + } ; + + mkVoice : Voice -> Str -> Str = \v,s -> case v of { + Act => s ; + Pass => s + "s" + } ; + + vHusk : Str -> Verbum = \husk -> + mkVerb (husk + "e") (husk + "er") (husk + "es") (husk + "ede") (husk + "et") husk ; + + vSpis : Str -> Verbum = \spis -> + mkVerb (spis + "e") (spis + "er") (spis + "es") (spis + "te") (spis + "t") spis ; + + vBo : Str -> Verbum = \bo -> + mkVerb bo (bo + "r") (bo + "es") (bo + "ede") (bo + "et") bo ; + +-- pronouns + +oper jag_32 : ProPN = + {s = table { + PNom => "jeg" ; + PAcc => "mig" ; + PGen (ASg Utr) => "min" ; + PGen (ASg Neutr) => "mit" ; + PGen APl => "mine" + } ; + h1 = Utr ; + h2 = Sg ; + h3 = P1 + } ; + +oper du_33 : ProPN = + {s = table { + PNom => "du" ; + PAcc => "dig" ; + PGen (ASg Utr) => "din" ; + PGen (ASg Neutr) => "dit" ; + PGen APl => "dine" + } ; + h1 = Utr ; + h2 = Sg ; + h3 = P2 + } ; + +oper han_34 : ProPN = + {s = table { + PNom => "han" ; + PAcc => "ham" ; + PGen (ASg Utr) => "hans" ; + PGen (ASg Neutr) => "hans" ; + PGen APl => "hans" + } ; + h1 = Utr ; + h2 = Sg ; + h3 = P3 + } ; +oper hon_35 : ProPN = + {s = table { + PNom => "hun" ; + PAcc => "hende" ; + PGen (ASg Utr) => "hendes" ; + PGen (ASg Neutr) => "hendes" ; + PGen APl => "hendes" + } ; + h1 = Utr ; + h2 = Sg ; + h3 = P3 + } ; + +oper vi_36 : ProPN = + {s = table { + PNom => "vi" ; + PAcc => "os" ; + PGen _ => "vores" + } ; + h1 = Utr ; + h2 = Pl ; + h3 = P1 + } ; + +oper ni_37 : ProPN = + {s = table { + PNom => "i" ; + PAcc => "jer" ; + PGen _ => "jeres" + } ; + h1 = Utr ; + h2 = Pl ; + h3 = P2 + } ; + +oper de_38 : ProPN = + {s = table { + PNom => "de" ; + PAcc => "dem" ; + PGen _ => "deres" + } ; + h1 = Utr ; + h2 = Pl ; + h3 = P3 + } ; + +oper De_38 : ProPN = + {s = table { + PNom => "De" ; + PAcc => "Dem" ; + PGen _ => "Deres" + } ; + h1 = Utr ; + h2 = Sg ; + h3 = P2 + } ; + +oper den_39 : ProPN = + {s = table { + PNom => "den" ; + PAcc => "den" ; + PGen _ => "dens" + } ; + h1 = Utr ; + h2 = Sg ; + h3 = P3 + } ; + +oper det_40 : ProPN = + {s = table { + PNom => "det" ; + PAcc => "det" ; + PGen _ => "dets" + } ; + h1 = Neutr ; + h2 = Sg ; + h3 = P3 + } ; + + +-- from Numerals + +param DForm = ental | ton | tiotal ; + +oper mkTal : Str -> Str -> Str -> {s : DForm => Str} = + \to, tolv, tyve -> + {s = table {ental => to ; ton => tolv ; tiotal => tyve}} ; +oper regTal : Str -> {s : DForm => Str} = \fem -> mkTal fem (fem + "ton") (fem + "tio") ; + + +} diff --git a/lib/resource/danish/NumeralsDan.gf b/lib/resource/danish/NumeralsDan.gf new file mode 100644 index 000000000..b243b94da --- /dev/null +++ b/lib/resource/danish/NumeralsDan.gf @@ -0,0 +1,37 @@ +-- AR 12/10/2002 following www.geocities.com/tsca.geo/dansk/dknummer.html + +concrete NumeralsDan of Numerals = open Prelude, MorphoDan in { + +lincat Numeral = {s : Str} ; +lincat Digit = {s : DForm => Str} ; +lincat Sub10 = {s : DForm => Str} ; +lincat Sub100 = {s : Str} ; +lincat Sub1000 = {s : Str} ; +lincat Sub1000000 = {s : Str} ; + +lin num x = x ; + +lin n2 = mkTal "to" "tolv" "tyve" ; +lin n3 = mkTal "tre" "tretten" "tredive" ; +lin n4 = mkTal "fire" "fjorten" "fyrre" ; +lin n5 = mkTal "fem" "femten" "halvtreds" ; +lin n6 = mkTal "seks" "seksten" "tres" ; +lin n7 = mkTal "syv" "sytten" "halvfjerds" ; +lin n8 = mkTal "otte" "atten" "firs" ; +lin n9 = mkTal "ni" "nitten" "halvfems" ; + +lin pot01 = {s = table {f => "en"}} ; --- +lin pot0 d = {s = table {f => d.s ! f}} ; +lin pot110 = ss "ti" ; +lin pot111 = ss "elleve" ; +lin pot1to19 d = ss (d.s ! ton) ; +lin pot0as1 n = ss (n.s ! ental) ; +lin pot1 d = ss (d.s ! tiotal) ; +lin pot1plus d e = ss (e.s ! ental ++ "og" ++ d.s ! tiotal) ; +lin pot1as2 n = n ; +lin pot2 d = ss (d.s ! ental ++ "hundrede") ; +lin pot2plus d e = ss (d.s ! ental ++ "hundrede" ++ "og" ++ e.s) ; +lin pot2as3 n = n ; +lin pot3 n = ss (n.s ++ "tusind") ; +lin pot3plus n m = ss (n.s ++ "tusind" ++ "og" ++ m.s) ; --- +} \ No newline at end of file diff --git a/lib/resource/danish/RulesDan.gf b/lib/resource/danish/RulesDan.gf new file mode 100644 index 000000000..fbde9d760 --- /dev/null +++ b/lib/resource/danish/RulesDan.gf @@ -0,0 +1,4 @@ +--# -path=.:../scandinavian:../abstract:../../prelude + +concrete RulesDan of Rules = + RulesScand with (SyntaxScand=SyntaxDan) ; diff --git a/lib/resource/danish/StructuralDan.gf b/lib/resource/danish/StructuralDan.gf new file mode 100644 index 000000000..4b205de9b --- /dev/null +++ b/lib/resource/danish/StructuralDan.gf @@ -0,0 +1,118 @@ +--# -path=.:../scandinavian:../abstract:../../prelude + +--1 The Top-Level Swedish Resource Grammar: Structural Words +-- +-- Aarne Ranta 2002 -- 2004 +-- +concrete StructuralDan of Structural = + CategoriesDan, NumeralsDan ** open Prelude, MorphoDan, SyntaxDan in { + lin + + INP = pronNounPhrase jag_32 ; + ThouNP = pronNounPhrase du_33 ; + HeNP = pronNounPhrase han_34 ; + SheNP = pronNounPhrase hon_35 ; + WeNumNP n = pronNounPhrase (pronWithNum vi_36 n) ; + YeNumNP n = pronNounPhrase (pronWithNum ni_37 n) ; + TheyNP = pronNounPhrase de_38 ; + TheyFemNP = pronNounPhrase de_38 ; + + YouNP = let {ni = pronNounPhrase ni_37 } in {s = ni.s ; g = ni.g ; n = Sg} ; + + ItNP = pronNounPhrase det_40 ; ---- + ThisNP = regNameNounPhrase ["det her"] NNeutr ; + ThatNP = regNameNounPhrase ["det der"] NNeutr ; + TheseNumNP n = + {s = \\c => ["de her"] ++ n.s ! npCase c ; g = Neutr ; n = Pl} ; + ThoseNumNP n = + {s = \\c => ["de der"] ++ n.s ! npCase c ; g = Neutr ; n = Pl} ; + + EveryDet = varjeDet ; + AllMassDet = mkDeterminerSgGender2 "all" "alt" IndefP ; + AllNumDet = mkDeterminerPlNum "alle" IndefP ; + AnyDet = mkDeterminerSgGender2 "nogen" "noget" IndefP ; + AnyNumDet = mkDeterminerPlNum "nogle" IndefP ; + SomeDet = mkDeterminerSgGender2 "nogen" "noget" IndefP ; + SomeNumDet = mkDeterminerPlNum "nogle" IndefP ; + ManyDet = mkDeterminerPl "mange" IndefP ; + HowManyDet = mkDeterminerPl ["hvor mange"] IndefP ; + NoDet = mkDeterminerSgGender2 "ingen" "ingen" IndefP ; + NoNumDet = mkDeterminerPlNum "ingen" IndefP ; + WhichNumDet = mkDeterminerPlNum "hvilke" IndefP ; + + UseNumeral i = {s = table {Nom => i.s ; Gen => i.s ++ "s"}} ; --- + + WhichDet = vilkenDet ; + MostDet = mkDeterminerSgGender2 ["den meste"] ["det meste"] (DefP Def) ; + MostsDet = flestaDet ; + MuchDet = mkDeterminerSg (detSgInvar "meget") IndefP ; + + ThisDet = mkDeterminerSgGender2 ["den her"] ["det her"] (DefP Def) ; + ThatDet = mkDeterminerSgGender2 ["den der"] ["det der"] (DefP Def) ; + TheseNumDet = mkDeterminerPlNum ["de her"] (DefP Def) ; + ThoseNumDet = mkDeterminerPlNum ["de der"] (DefP Def) ; + + HowIAdv = ss "hvor" ; + WhenIAdv = ss "hvornår" ; + WhereIAdv = ss "hver" ; + WhyIAdv = ss "hvorfor" ; + + AndConj = ss "og" ** {n = Pl} ; + OrConj = ss "eller" ** {n = Sg} ; + BothAnd = sd2 "både" "og" ** {n = Pl} ; + EitherOr = sd2 "enten" "eller" ** {n = Sg} ; + NeitherNor = sd2 "hverken" "eller" ** {n = Sg} ; + IfSubj = ss "hvis" ; + WhenSubj = ss "når" ; + + PhrYes = ss ["Ja ."] ; + PhrNo = ss ["Nej ."] ; + + VeryAdv = ss "meget" ; + TooAdv = ss "for" ; ---- ? + OtherwiseAdv = ss "anderledes" ; ---- ? + ThereforeAdv = ss "derfor" ; + + EverybodyNP = let alla = table {Nom => "alle" ; Gen => "alles"} in + {s = \\c => alla ! npCase c ; g = Utr ; n = Pl} ; + SomebodyNP = nameNounPhrase (mkProperName "nogen" NUtr) ; + NobodyNP = nameNounPhrase (mkProperName "ingen" NUtr) ; + EverythingNP = nameNounPhrase (mkProperName "alt" NNeutr) ; + SomethingNP = nameNounPhrase (mkProperName "noget" NNeutr) ; + NothingNP = nameNounPhrase (mkProperName "intet" NNeutr) ; + + CanVV = mkVerb "kunne" "kan" nonExist "kunne" "kunnet" nonExist ** {s1 = [] ; isAux = True} ; + CanKnowVV = mkVerb "kunne" "kan" nonExist "kunne" "kunnet" nonExist ** {s1 = [] ; isAux = True} ; + MustVV = mkVerb "måtte" "må" "mås" "måtte" "måttet" "må" ** {s1 = [] ; isAux = True} ; ---- ? + WantVV = mkVerb "ville" "vil" nonExist "ville" "villet" nonExist ** {s1 = [] ; isAux = True} ; --- + + EverywhereNP = advPost "overalt" ; + SomewhereNP = advPost ["et eller andet sted"] ; ---- ? + NowhereNP = advPost "intetsteds" ; + + AlthoughSubj = ss ["selv om"] ; + + AlmostAdv = ss "næsten" ; + QuiteAdv = ss "temmelig" ; + + InPrep = ss "i" ; + OnPrep = ss "på" ; + ToPrep = ss "til" ; + ThroughPrep = ss "igennem" ; + AbovePrep = ss "ovenfor" ; + UnderPrep = ss "under" ; + InFrontPrep = ss "fremfor" ; ---- ? + BehindPrep = ss "bag" ; + BetweenPrep = ss "mellem" ; + FromPrep = ss "fra" ; + BeforePrep = ss "før" ; + DuringPrep = ss "under" ; + AfterPrep = ss "efter" ; + WithPrep = ss "med" ; + WithoutPrep = ss "uden" ; + ByMeansPrep = ss "med" ; + PossessPrep = ss "af" ; + PartPrep = ss "af" ; + AgentPrep = ss "af" ; + +} diff --git a/lib/resource/danish/SyntaxDan.gf b/lib/resource/danish/SyntaxDan.gf new file mode 100644 index 000000000..3bc8db4c4 --- /dev/null +++ b/lib/resource/danish/SyntaxDan.gf @@ -0,0 +1,104 @@ +--# -path=.:../scandinavian:../../prelude + +instance SyntaxDan of SyntaxScand = TypesDan ** + open Prelude, (CO = Coordination), MorphoDan in { + + oper + +------ mkAdjForm + +-- When common nouns are extracted from lexicon, the composite noun form is ignored. + + extCommonNounMasc = extCommNoun ; + + npMan : NounPhrase = nameNounPhrase (mkProperName "man" NUtr) ; + npDet : NounPhrase = nameNounPhrase (mkProperName "det" NNeutr) ; + + + mkAdjForm : Species -> Number -> NounGender -> AdjFormPos = \b,n,g -> + case of { + => Strong (ASg (genNoun g)) ; + => Strong APl ; + => Weak + } ; + + deponentVerb : Verb -> Verb = \finna -> { + s = table { + VF (Pres m _) => finna.s ! VF (Pres m Pass) ; + VF (Pret m _) => finna.s ! VF (Pret m Pass) ; + VI (Inf _) => finna.s ! VI (Inf Pass) ; + VI (Supin _) => finna.s ! VI (Supin Pass) ; + v => finna.s ! v --- Imper ! + } ; + s1 = finna.s1 + } ; + + verbFinnas : Verb = + deponentVerb (mkVerb "finde" "finder" "findes" "fandt" "fundet" "find" ** {s1 = []}) ; + verbVara = mkVerb "være" "er" nonExist "var" "været" "vær" ** {s1 = []} ; + verbHava = mkVerb "have" "har" "haves" "havde" "haft" "hav" ** {s1 = []} ; + + relPronForms : RelCase => GenNum => Str = table { + RNom => \\_ => "som" ; + RAcc => \\_ => variants {"som" ; []} ; + RGen => \\_ => "hvis" ; + RPrep => pronVilken + } ; + + pronVilken = table { + ASg Utr => "hvilken" ; + ASg Neutr => "hvilket" ; + APl => "hvilke" + } ; + + pronSådan = table { + ASg Utr => "sådan" ; + ASg Neutr => "sådant" ; + APl => "sådanne" + } ; + + pronNågon = table { + ASg Utr => "nogen" ; + ASg Neutr => "noget" ; + APl => "nogle" + } ; + + specDefPhrase : Bool -> Species = \b -> + if_then_else Species b Indef Def ; + + superlSpecies = Indef ; + + artIndef = table {Utr => "en" ; Neutr => "et"} ; + + artDef : Bool => GenNum => Str = table { + True => table { + ASg Utr => "den" ; + ASg Neutr => "det" ; -- det gamla huset + APl => variants {"de"} + } ; + False => table {_ => []} -- huset + } ; + + auxHar = "har" ; + auxHade = "havde" ; + auxHa = "have" ; + auxSka = "skal" ; + auxSkulle = "skulle" ; + + infinAtt = "at" ; + + varjeDet : Determiner = mkDeterminerSg (detSgInvar "hver") IndefP ; + allaDet : Determiner = mkDeterminerPl "alle" IndefP ; + flestaDet : Determiner = mkDeterminerPl ["de fleste"] IndefP ; + + prepÄn = "end" ; + negInte = "ikke" ; + + conjOm = "hvis" ; + + pronVars = "hvis" ; + pronVem = "hvem" ; + pronVems = "hvis" ; ---- ?? + pronVad = "hvad" ; + +} \ No newline at end of file diff --git a/lib/resource/danish/TestResourceDan.gf b/lib/resource/danish/TestResourceDan.gf new file mode 100644 index 000000000..971b192b1 --- /dev/null +++ b/lib/resource/danish/TestResourceDan.gf @@ -0,0 +1,50 @@ +--# -path=.:../scandinavian:../abstract:../../prelude + +concrete TestResourceDan of TestResource = RulesDan, StructuralDan ** open MorphoDan, SyntaxDan in { + +flags startcat=Phr ; lexer=text ; unlexer=text ; + +-- a random sample from the lexicon + +lin + Big = mkAdjective "stor" "stort" "store" "større" "størst" ; + Small = mkAdjective "lille" "lille" "små" "mindre" "mindst" ; + Old = mkAdjective "gammel" "gammelt" "gamle" "ældre" "ældst" ; + Young = mkAdjective "ung" "ungt" "unge" "yngre" "yngst" ; + American = extAdjective (aRod "amerikansk") ; + Finnish = extAdjective (aRod "finsk") ; + Happy = aRod "lykkelig" ; + Married = extAdjective (aAbstrakt "gift") ** {s2 = "med"} ; + Man = extCommNoun (mkSubstantive "mand" "manden" "mænd" "mænden" ** {h1 = Utr}) ; + Bar = extCommNoun (nBil "bar") ; ---- ? + Bottle = extCommNoun (nUge "flaske") ; + Woman = extCommNoun (nUge "kvinde") ; + Car = extCommNoun (nBil "bil") ; + House = extCommNoun (nHus "hus") ; + Light = extCommNoun (nHus "lys") ; + Wine = extCommNoun (nHus "vin") ; ---- ? + Walk = mkVerb "gå" "går" "gås" "gik" "gået" "gå" ** {s1 = []} ; + Run = mkVerb "springe" "springer" "springes" "sprang" "sprunget" "spring" ** {s1 = []} ; + Drink = extTransVerb (mkVerb "drikke" "drikker" "drikkes" "drak" "drukket" "drikk" ** {s1 = []}) [] ; + Love = extTransVerb (vNopart (vHusk "ælsk")) [] ; + Send = extTransVerb (vNopart (vSpis "send")) [] ; ---- ? + Wait = extTransVerb (vNopart (vSpis "vent")) "på" ; + Give = extTransVerb (vNopart (mkVerb "give" "giver" "gives" "gav" "givet" "giv")) [] ** {s3 = "til"} ; + Prefer = extTransVerb (vNopart (vSpis "foretrækk")) [] ** {s3 = "for"} ; + + Say = vNopart (mkVerb "sige" "siger" "siges" "sagde" "sagt" "sig") ; + Prove = vNopart (vSpis "bevise") ; + SwitchOn = mkDirectVerb (vHusk "lukk" ** {s1 = "op"}) ; + SwitchOff = mkDirectVerb (vHusk "slukk" ** {s1 = []}) ; + + Mother = mkFun (extCommNoun (mkSubstantive "moder" "moderen" "mødre" + "mødrene" ** {h1 = Utr})) "til" ; ---- ? + Uncle = mkFun (extCommNoun (mkSubstantive "onkel" "onkelen" "onkler" "onklene" ** {h1 = Utr})) "til" ; ---- ? + Connection = mkFun (extCommNoun (nUge "forbindelse")) "fra" ** {s3 = "til"} ; + + Always = advPre "altid" ; + Well = advPost "godt" ; + + John = mkProperName "Johan" NUtr ; + Mary = mkProperName "Maria" NUtr ; +} ; diff --git a/lib/resource/danish/TypesDan.gf b/lib/resource/danish/TypesDan.gf new file mode 100644 index 000000000..9bcd9b3ec --- /dev/null +++ b/lib/resource/danish/TypesDan.gf @@ -0,0 +1,33 @@ +--1 Danish Word Classes and Morphological Parameters +-- +-- This is a resource module for Italian morphology, defining the +-- morphological parameters and word classes of Italian. +-- The morphology is so far only +-- complete w.r.t. the syntax part of the resource grammar. +-- It does not include those parameters that are not needed for +-- analysing individual words: such parameters are defined in syntax modules. + +instance TypesDan of TypesScand = { + +param + NounGender = NUtr | NNeutr ; + +oper + genNoun = \s -> case s of {NUtr => Utr ; NNeutr => Neutr} ; + sexNoun _ = NoMasc ; + gen2nounGen = \s -> case s of {Utr => NUtr ; Neutr => NNeutr} ; + +param + AdjFormPos = Strong GenNum | Weak ; + + VFin = + Pres Mode Voice + | Pret Mode Voice + | Imper ; --- no passive + + VInf = + Inf Voice + | Supin Voice + | PtPret Case ; ---- number and gender + +} diff --git a/lib/resource/scandinavian/CategoriesScand.gf b/lib/resource/scandinavian/CategoriesScand.gf new file mode 100644 index 000000000..f501d7f2c --- /dev/null +++ b/lib/resource/scandinavian/CategoriesScand.gf @@ -0,0 +1,63 @@ +incomplete concrete CategoriesScand of Categories = + open Prelude, SyntaxScand in { + +flags + startcat=Phr ; + lexer=text ; + unlexer=text ; + +lincat + CN = {s : Number => SpeciesP => Case => Str ; g : NounGender ; + p : IsComplexCN} ; + N = CommNoun ; + -- = {s : Number => Species => Case => Str ; g : NounGender} ; + NP = NounPhrase ; + -- = {s : NPForm => Str ; g : Gender ; n : Number} ; + PN = {s : Case => Str ; g : NounGender} ; + Det = {s : NounGender => Str ; n : Number ; b : SpeciesP} ; + N2 = Function ; + -- = CommNoun ** {s2 : Preposition} ; + N3 = Function ** {s3 : Preposition} ; + Num = {s : Case => Str} ; + Prep = {s : Str} ; + + A = Adjective ; + -- = {s : AdjFormPos => Case => Str} ; + A2 = Adjective ** {s2 : Preposition} ; + ADeg = {s : AdjForm => Str} ; + AP = Adjective ** {p : IsPostfixAdj} ; + + V = Verb ; + -- = {s : VerbForm => Str ; s1 : Str} ; + VG = {s : SForm => Str ; s2 : Bool => Str ; s3 : SForm => Gender => Number => Str} ; + VP = {s : SForm => Str ; s2 : Str ; s3 : SForm => Gender => Number => Str} ; + V2 = TransVerb ; + -- = Verb ** {s2 : Preposition} ; + V3 = TransVerb ** {s3 : Preposition} ; + VS = Verb ; + VV = Verb ** {isAux : Bool} ; + + Adv = Adverb ; + -- = {s : Str ; isPost : Bool} ; + PP = Adverb ; + + S = Sentence ; + -- = {s : Order => Str} ; + Cl = Clause ; + -- = {s : Bool => SForm => Order => Str} ; + Slash = Sentence ** {s2 : Preposition} ; + RP = {s : RelCase => GenNum => Str ; g : RelGender} ; + RC = {s : GenNum => Str} ; + IP = NounPhrase ; + Qu = {s : QuestForm => Str} ; + Imp = {s : Number => Str} ; + + Phr = {s : Str} ; + + Conj = {s : Str ; n : Number} ; + ConjD = {s1 : Str ; s2 : Str ; n : Number} ; + + ListS = {s1,s2 : Order => Str} ; + ListAP = {s1,s2 : AdjFormPos => Case => Str ; p : Bool} ; + ListNP = {s1,s2 : NPForm => Str ; g : Gender ; n : Number} ; +} diff --git a/lib/resource/scandinavian/RulesScand.gf b/lib/resource/scandinavian/RulesScand.gf new file mode 100644 index 000000000..5601a78a1 --- /dev/null +++ b/lib/resource/scandinavian/RulesScand.gf @@ -0,0 +1,141 @@ +--# -path=.:../abstract:../../prelude + +incomplete concrete RulesScand of Rules = CategoriesScand ** + open Prelude, SyntaxScand in { + +lin + UseN = noun2CommNounPhrase ; + ModAP = modCommNounPhrase ; + ModGenOne = npGenDet singular noNum ; + ModGenNum = npGenDet plural ; + UsePN = nameNounPhrase ; + UseN2 = funAsCommNounPhrase ; + AppN2 = appFunComm ; + AppN3 = appFun2 ; + UseA = adj2adjPhrase ; + ComplA2 = complAdj ; + PositADeg = positAdjPhrase ; + ComparADeg = comparAdjPhrase ; + SuperlNP = superlNounPhrase ; + + DetNP = detNounPhrase ; + IndefOneNP = indefNounPhrase singular ; + IndefNumNP = indefNounPhraseNum plural ; + DefOneNP = defNounPhrase singular ; + DefNumNP = defNounPhraseNum plural ; + MassNP = detNounPhrase (mkDeterminerSg (detSgInvar []) IndefP) ; + UseInt i = {s = table {Nom => i.s ; Gen => i.s ++ "s"}} ; --- + NoNum = noNum ; + + SymbPN i = {s = \\_ => i.s ; g = NNeutr} ; + SymbCN cn s = + {s = \\a,n,c => cn.s ! a ! n ! c ++ s.s ; + g = cn.g ; + p = cn.p + } ; + IntCN cn s = + {s = \\a,n,c => cn.s ! a ! n ! c ++ s.s ; + g = cn.g ; + p = cn.p + } ; + + CNthatS = nounThatSentence ; + + PredVP = predVerbPhrase ; + + PosVG = predVerbGroup True ; + NegVG = predVerbGroup False ; + + PredVG = predVerbGroupClause ; + + PredV = predVerb ; + PredAP = predAdjective ; + PredSuperl a = predAdjective (superlAdjPhrase a) ; + PredCN = predCommNoun ; + PredV2 = complTransVerb ; + PredV3 = complDitransVerb ; + PredPassV = passVerb ; + PredNP = predNounPhrase ; + PredPP = predAdverb ; + PredVS = complSentVerb ; + PredVV = complVerbVerb ; + VTrans = transAsVerb ; + + AdjAdv a = advPost (a.s ! adverbForm ! Nom) ; + AdvPP p = p ; + PrepNP p = prepPhrase p.s ; --- + AdvVP = adVerbPhrase ; + AdvCN = advCommNounPhrase ; + AdvAP = advAdjPhrase ; + + ThereNP A = predVerbPhrase npDet + (predVerbGroup True + (complTransVerb (mkDirectVerb (deponentVerb verbFinnas)) A)) ; + + PosSlashV2 = slashTransVerb True ; + NegSlashV2 = slashTransVerb False ; + OneVP = predVerbPhrase npMan ; + + IdRP = identRelPron ; + FunRP = funRelPron ; + RelVP = relVerbPhrase ; + RelSlash = relSlash ; + ModRC = modRelClause ; + RelSuch = relSuch ; + + WhoOne = intPronWho singular ; + WhoMany = intPronWho plural ; + WhatOne = intPronWhat singular ; + WhatMany = intPronWhat plural ; + FunIP = funIntPron ; + NounIPOne = nounIntPron singular ; + NounIPMany = nounIntPron plural ; + + QuestVP = questVerbPhrase ; + IntVP = intVerbPhrase ; + IntSlash = intSlash ; + QuestAdv = questAdverbial ; + IsThereNP A = questVerbPhrase npDet + (predVerbGroup True + (complTransVerb (mkDirectVerb (deponentVerb verbFinnas)) A)) ; + + ImperVP = imperVerbPhrase ; + + IndicPhrase = indicUtt ; + QuestPhrase = interrogUtt ; + ImperOne = imperUtterance singular ; + ImperMany = imperUtterance plural ; + + PrepS p = ss (p.s ++ ",") ; + AdvS = advSentence ; + + TwoS = twoSentence ; + ConsS = consSentence ; + ConjS = conjunctSentence ; + ConjDS = conjunctDistrSentence ; + + TwoAP = twoAdjPhrase ; + ConsAP = consAdjPhrase ; + ConjAP = conjunctAdjPhrase ; + ConjDAP = conjunctDistrAdjPhrase ; + + TwoNP = twoNounPhrase ; + ConsNP = consNounPhrase ; + ConjNP = conjunctNounPhrase ; + ConjDNP = conjunctDistrNounPhrase ; + + SubjS = subjunctSentence ; + SubjImper = subjunctImperative ; + SubjQu = subjunctQuestion ; + SubjVP = subjunctVerbPhrase ; + + PhrNP = useNounPhrase ; + PhrOneCN = useCommonNounPhrase singular ; + PhrManyCN = useCommonNounPhrase plural ; + PhrIP ip = ip ; + PhrIAdv ia = ia ; + + OnePhr p = p ; + ConsPhr = cc2 ; + +} ; diff --git a/lib/resource/scandinavian/SyntaxScand.gf b/lib/resource/scandinavian/SyntaxScand.gf new file mode 100644 index 000000000..1dac79430 --- /dev/null +++ b/lib/resource/scandinavian/SyntaxScand.gf @@ -0,0 +1,1278 @@ +--1 A Small Scandinavian Resource Syntax +-- +-- Aarne Ranta 2002 +-- +-- This resource grammar contains definitions needed to construct +-- indicative, interrogative, and imperative sentences in Swedish. +-- +-- The following modules are presupposed: + +interface SyntaxScand = TypesScand ** open Prelude, (CO = Coordination) in { + +--2 Common Nouns +-- +--3 Simple common nouns + +oper + CommNoun : Type = {s : Number => Species => Case => Str ; g : NounGender} ; + +-- When common nouns are extracted from lexicon, the composite noun form is ignored. +-- The latter is only relevant for Swedish. + + extCommNoun : Subst -> CommNoun = \sb -> + {s = \\n,b,c => sb.s ! SF n b c ; + g = gen2nounGen sb.h1 + } ; + + extCommNounMasc : Subst -> CommNoun ; + +-- These constants are used for data abstraction over the parameter type $Num$. + singular = Sg ; + plural = Pl ; + +--3 Common noun phrases + +-- The need for this more complex type comes from the variation in the way in +-- which a modifying adjective is inflected after different determiners: +-- "(en) ful orm" / "(den) fula ormen" / "(min) fula orm". +param + SpeciesP = IndefP | DefP Species ; + +-- We also have to be able to decide if a $CommNounPhrase$ is complex +-- (to form the definite form: "bilen" / "den stora bilen"). + +oper + IsComplexCN : Type = Bool ; + +-- Coercions between simple $Species$ and $SpeciesP$: + unSpeciesP : SpeciesP -> Species = \b -> + case b of {IndefP => Indef ; DefP p => p} ; -- bil/bil/bilen + unSpeciesAdjP : SpeciesP -> Species = \b -> + case b of {IndefP => Indef ; DefP _ => Def} ; -- gammal/gamla/gamla + +-- Here's the type itself. + CommNounPhrase : Type = + {s : Number => SpeciesP => Case => Str ; + g : NounGender ; p : IsComplexCN} ; + +-- To use a $CommNoun$ as $CommNounPhrase$. + noun2CommNounPhrase : CommNoun -> CommNounPhrase = \hus -> + {s = \\n,b,c => hus.s ! n ! unSpeciesP b ! c ; + g = hus.g ; p = False} ; + + n2n = noun2CommNounPhrase ; + + +--2 Noun Phrases +-- +-- The worst case for noun phrases is pronouns, which have inflection +-- in (what is syntactically) their genitive. Most noun phrases can +-- ignore this variation. + +oper + npCase : NPForm -> Case = \c -> case c of {PGen _ => Gen ; _ => Nom} ; + mkNPForm : Case -> NPForm = \c -> case c of {Gen => PGen APl ; _ => PNom} ; + + NounPhrase : Type = {s : NPForm => Str ; g : Gender ; n : Number} ; + +-- Proper names are a simple kind of noun phrases. However, we want to +-- anticipate the rule that proper names can be modified by +-- adjectives, even though noun phrases in general cannot - hence the sex. + + ProperName : Type = {s : Case => Str ; g : NounGender} ; + + mkProperName : Str -> NounGender -> ProperName = \john,g -> + {s = table {Nom => john ; Gen => john + "s"} ; g = g} ; + + nameNounPhrase : ProperName -> NounPhrase = + \john -> {s = table {c => john.s ! npCase c} ; g = genNoun john.g ; n = Sg} ; + + regNameNounPhrase : Str -> NounGender -> NounPhrase = \john,g -> + nameNounPhrase (mkProperName john g) ; + + pronNounPhrase : ProPN -> NounPhrase = \jag -> + {s = jag.s ; g = jag.h1 ; n = jag.h2} ; + +-- The following construction has to be refined for genitive forms: +-- "vi tre", "oss tre" are OK, but "vår tres" is not. + + Numeral : Type = {s : Case => Str} ; + + pronWithNum : ProPN -> Numeral -> ProPN = \we,two -> + {s = \\c => we.s ! c ++ two.s ! npCase c ; + h1 = we.h1 ; + h2 = we.h2 ; + h3 = we.h3 + } ; + + noNum : Numeral = {s = \\_ => []} ; + +-- Formal subjects + + npMan : NounPhrase ; + npDet : NounPhrase ; + +--2 Determiners +-- +-- Determiners are inflected according to noun in gender and sex. +-- The number and species of the noun are determined by the determiner. + + Determiner : Type = {s : NounGender => Str ; n : Number ; b : SpeciesP} ; + + artIndef : Gender => Str ; + + artDef : Bool => GenNum => Str ; + +-- This is the rule for building noun phrases. + + detNounPhrase : Determiner -> CommNounPhrase -> NounPhrase = \en, man -> + {s = table {c => en.s ! man.g ++ man.s ! en.n ! en.b ! npCase c} ; + g = genNoun man.g ; n = en.n} ; + +-- The following macros are sufficient to define most determiners. +-- All $SpeciesP$ values come into question: +-- "en god vän" - "min gode vän" - "den gode vännen". + + DetSg : Type = NounGender => Str ; + DetPl : Type = Str ; + + mkDeterminerSg : DetSg -> SpeciesP -> Determiner = \en, b -> + {s = en ; n = Sg ; b = b} ; + + mkDeterminerPl : DetPl -> SpeciesP -> Determiner = \alla,b -> + mkDeterminerPlNum alla b noNum ; + + mkDeterminerPlNum : DetPl -> SpeciesP -> Numeral -> Determiner = \alla,b,n -> + {s = \\_ => alla ++ n.s ! Nom ; + n = Pl ; + b = b + } ; + + detSgInvar : Str -> DetSg = \varje -> table {_ => varje} ; + +-- A large class of determiners can be built from a gender-dependent table. + + mkDeterminerSgGender : (Gender => Str) -> SpeciesP -> Determiner = \en -> + mkDeterminerSg (\\g => en ! genNoun g) ; + + mkDeterminerSgGender2 : Str -> Str -> SpeciesP -> Determiner = \en,ett -> + mkDeterminerSgGender (table {Utr => en ; Neutr => ett}) ; + +-- Here are some examples. We are in fact doing some ad hoc morphology here, +-- instead of importing the lexicon. + + varjeDet : Determiner ; + allaDet : Determiner ; + enDet : Determiner = mkDeterminerSgGender artIndef IndefP ; + + flestaDet : Determiner ; + vilkenDet : Determiner = + mkDeterminerSgGender + (\\g => pronVilken ! ASg g) IndefP ; + vilkaDet : Determiner = mkDeterminerPl (pronVilken ! APl) IndefP ; + + vilkDet : Number -> Determiner = \n -> case n of { + Sg => vilkenDet ; + Pl => vilkaDet + } ; + + någDet : Number -> Determiner = \n -> case n of { + Sg => mkDeterminerSgGender + (\\g => pronNågon ! ASg g) IndefP ; + Pl => mkDeterminerPl (pronNågon ! APl) IndefP + } ; + + +-- Genitives of noun phrases can be used like determiners, to build noun phrases. +-- The number argument makes the difference between "min bil" - "mina bilar". + + npGenDet : Number -> Numeral -> NounPhrase -> CommNounPhrase -> NounPhrase = + \n,tre,huset,vin -> { + s = \\c => case n of { + Sg => huset.s ! PGen (ASg (genNoun vin.g)) ++ + vin.s ! Sg ! DefP Indef ! npCase c ; + Pl => huset.s ! PGen APl ++ tre.s ! Nom ++ + vin.s ! Pl ! DefP Indef ! npCase c + } ; + g = genNoun vin.g ; + n = n + } ; + +-- *Bare plural noun phrases* like "män", "goda vänner", are built without a +-- determiner word. But a $Numeral$ may occur. + + plurDet : CommNounPhrase -> NounPhrase = plurDetNum noNum ; + + plurDetNum : Numeral -> CommNounPhrase -> NounPhrase = \num,cn -> + {s = \\c => num.s ! Nom ++ cn.s ! Pl ! IndefP ! npCase c ; + g = genNoun cn.g ; + n = Pl + } ; + +-- Definite phrases in Swedish are special, since determiner may be absent +-- depending on if the noun is complex: "bilen" - "den nya bilen". +-- In Danish, "den nye bil". + + denDet : CommNounPhrase -> NounPhrase = \cn -> + detNounPhrase + (mkDeterminerSgGender (table {g => artDef ! cn.p ! ASg g}) + (DefP (specDefPhrase cn.p))) cn ; + deDet : Numeral -> CommNounPhrase -> NounPhrase = \n,cn -> + detNounPhrase + (mkDeterminerPlNum (artDef ! cn.p ! APl) + (DefP (specDefPhrase cn.p)) n) cn ; + +-- This is uniformly $Def$ in Swedish, but in Danish, $Indef$ for +-- compounds with determiner. + + specDefPhrase : Bool -> Species ; + +-- It is useful to have macros for indefinite and definite, singular and plural +-- noun-phrase-like syncategorematic expressions. + + indefNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n -> + indefNounPhraseNum n noNum ; + + indefNounPhraseNum : Number -> Numeral -> CommNounPhrase -> NounPhrase = + \n,num,hus -> + case n of { + Sg => detNounPhrase enDet hus ; + Pl => plurDetNum num hus + } ; + + defNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n -> + defNounPhraseNum n noNum ; + + defNounPhraseNum : Number -> Numeral -> CommNounPhrase -> NounPhrase = + \n,num,hus -> case n of { + Sg => denDet hus ; + Pl => deDet num hus + } ; + + indefNoun : Number -> CommNounPhrase -> Str = \n,man -> case n of { + Sg => artIndef ! genNoun man.g ++ man.s ! Sg ! IndefP ! Nom ; + Pl => man.s ! Pl ! IndefP ! Nom + } ; + +-- Constructions like "tanken att två är jämnt" are formed at the +-- first place as common nouns, so that one can also have "ett förslag att...". + + nounThatSentence : CommNounPhrase -> Sentence -> CommNounPhrase = \tanke,x -> + {s = \\n,d,c => tanke.s ! n ! d ! c ++ infinAtt ++ x.s ! Sub ; + g = tanke.g ; + p = tanke.p + } ; + + +--2 Adjectives +--3 Simple adjectives +-- +-- A special type of adjectives just having positive forms (for semantic reasons) +-- is useful, e.g. "finsk", "trekantig". + + Adjective : Type = {s : AdjFormPos => Case => Str} ; + + extAdjective : Adj -> Adjective = \adj -> + {s = table {f => table {c => adj.s ! AF (Posit f) c}}} ; + +-- Coercions between the compound gen-num type and gender and number: + + gNum : Gender -> Number -> GenNum = \g,n -> + case n of {Sg => ASg g ; Pl => APl} ; + + genGN : GenNum -> Gender = \gn -> + case gn of {ASg g => g ; _ => Utr} ; + numGN : GenNum -> Number = \gn -> + case gn of {ASg _ => Sg ; APl => Pl} ; + +--3 Adjective phrases +-- +-- An adjective phrase may contain a complement, e.g. "yngre än Rolf". +-- Then it is used as postfix in modification, e.g. "en man yngre än Rolf". + + IsPostfixAdj = Bool ; + + AdjPhrase : Type = Adjective ** {p : IsPostfixAdj} ; + +-- Simple adjectives are not postfix: + + adj2adjPhrase : Adjective -> AdjPhrase = \ny -> ny ** {p = False} ; + +--3 Comparison adjectives + +-- We take comparison adjectives directly from +-- the lexicon, which has full adjectives: + + AdjDegr = Adj ; + +-- Each of the comparison forms has a characteristic use: +-- +-- Positive forms are used alone, as adjectival phrases ("ung"). + + positAdjPhrase : AdjDegr -> AdjPhrase = \ung -> + {s = table {a => \\c => ung.s ! AF (Posit a) c} ; + p = False + } ; + +-- Comparative forms are used with an object of comparison, as +-- adjectival phrases ("yngre än Rolf"). + + comparAdjPhrase : AdjDegr -> NounPhrase -> AdjPhrase = \yngre,rolf -> + {s = \\_, c => yngre.s ! AF Compar Nom ++ prepÄn ++ rolf.s ! mkNPForm c ; + p = True + } ; + +-- Superlative forms are used with a modified noun, picking out the +-- maximal representative of a domain ("den yngste mannen"). + + superlNounPhrase : AdjDegr -> CommNounPhrase -> NounPhrase = \yngst,man -> + {s = \\c => let {gn = gNum (genNoun man.g) Sg} in + artDef ! True ! gn ++ + yngst.s ! AF (Super SupWeak) Nom ++ + man.s ! Sg ! DefP superlSpecies ! npCase c ; + g = genNoun man.g ; + n = Sg + } ; + +-- In Danish, however, "den yngste mand" - therefore a parametric species. + + superlSpecies : Species ; + +-- Moreover, superlatives can be used alone as adjectival phrases +-- ("yngst", "den yngste" - in free variation). +-- N.B. the former is only permitted in predicative position. + + superlAdjPhrase : AdjDegr -> AdjPhrase = \ung -> + {s = \\a,c => variants { + --- artDef ! True ! gn ++ yngst.s ! AF (Super SupWeak) c + ung.s ! AF (Super SupStrong) c + } ; + p = False + } ; + +--3 Two-place adjectives +-- +-- A two-place adjective is an adjective with a preposition used before +-- the complement. (Rem. $Preposition = Str$). + + AdjCompl = Adjective ** {s2 : Preposition} ; + + complAdj : AdjCompl -> NounPhrase -> AdjPhrase = \förtjust,dig -> + {s = \\a,c => förtjust.s ! a ! c ++ förtjust.s2 ++ dig.s ! PAcc ; + p = True + } ; + + +--3 Modification of common nouns +-- +-- The two main functions of adjective are in predication ("Johan är ung") +-- and in modification ("en ung man"). Predication will be defined +-- later, in the chapter on verbs. + + modCommNounPhrase : AdjPhrase -> CommNounPhrase -> CommNounPhrase = \God,Nybil -> + {s = \\n, b, c => + let { + god = God.s ! mkAdjForm (unSpeciesAdjP b) n Nybil.g ! Nom ; + nybil = Nybil.s ! n ! b ! c + } in + preOrPost God.p nybil god ; + g = Nybil.g ; + p = True} ; + +-- A special case is modification of a noun that has not yet been modified. +-- But it is simply a special case. + + modCommNoun : Adjective -> CommNoun -> CommNounPhrase = \god,bil -> + modCommNounPhrase (adj2adjPhrase god) (n2n bil) ; + +-- We have used a straightforward +-- method building adjective forms from simple parameters. + + mkAdjForm : Species -> Number -> NounGender -> AdjFormPos ; + +--2 Function expressions + +-- A function expression is a common noun together with the +-- preposition prefixed to its argument ("mor till x"). +-- The type is analogous to two-place adjectives and transitive verbs. + + Function = CommNoun ** {s2 : Preposition} ; + + mkFun : CommNoun -> Preposition -> Function = \f,p -> + f ** {s2 = p} ; + +-- The application of a function gives, in the first place, a common noun: +-- "mor/mödrar till Johan". From this, other rules of the resource grammar +-- give noun phrases, such as "modern till Johan", "mödrarna till Johan", +-- "mödrarna till Johan och Maria", and "modern till Johan och Maria" (the +-- latter two corresponding to distributive and collective functions, +-- respectively). Semantics will eventually tell when each +-- of the readings is meaningful. + + appFunComm : Function -> NounPhrase -> CommNounPhrase = \värde,x -> + noun2CommNounPhrase + {s = \\n,b => table { + Gen => nonExist ; + _ => värde.s ! n ! b ! Nom ++ värde.s2 ++ x.s ! PAcc + } ; + g = värde.g ; + } ; + +-- It is possible to use a function word as a common noun; the semantics is +-- often existential or indexical. + + funAsCommNounPhrase : Function -> CommNounPhrase = + noun2CommNounPhrase ; + +-- The following is an aggregate corresponding to the original function application +-- producing "Johans mor" and "modern till Johan". It does not appear in the +-- resource grammar API any longer. + + appFun : Bool -> Function -> NounPhrase -> NounPhrase = \coll,värde,x -> + let {n = x.n ; nf = if_then_else Number coll Sg n} in + variants { + defNounPhrase nf (appFunComm värde x) ; + npGenDet nf noNum x (noun2CommNounPhrase värde) + } ; + +-- Two-place functions add one argument place. + + Function2 = Function ** {s3 : Preposition} ; + +-- Their application starts by filling the first place. + + appFun2 : Function2 -> NounPhrase -> Function = \flyg, paris -> + {s = \\n,d,c => flyg.s ! n ! d ! c ++ flyg.s2 ++ paris.s ! PAcc ; + g = flyg.g ; + s2 = flyg.s3 + } ; + + +--2 Verbs + +-- Although the Swedish lexicon has full verb inflection, +-- we have limited this first version of the resource syntax to +-- verbs in present tense. Their mode can be infinitive, imperative, and indicative. + + +--3 Verb phrases +-- +-- Sentence forms are tense-mood combinations used in sentences and +-- verb phrases. + +param + Tense = Present | Past ; + Anteriority = Simul | Anter ; + SForm = + VIndic Tense Anteriority + | VFut Anteriority + | VCondit Anteriority + | VImperat + | VInfinit Anteriority ; + +oper + verbSForm : Verbum -> Voice -> SForm -> {fin,inf : Str} = \se,vo,sf -> + let + tense : Tense -> Voice -> VFin = \t,v -> case t of { + Present => Pres Ind v ; + Past => Pret Ind v + } ; + simple : VerbForm -> {fin,inf : Str} = \v -> { + fin = se.s ! v ; + inf = [] + } ; + compound : Str -> Str -> {fin,inf : Str} = \x,y -> { + fin = x ; + inf = y + } ; + see : Voice -> Str = \v -> (se.s ! (VI (Inf v))) ; + sett : Voice -> Str = \v -> (se.s ! (VI (Supin v))) ; + hasett : Voice -> Str = \v -> auxHa ++ sett v + + in case sf of { + VIndic t Simul => simple (VF (tense t vo)) ; + VIndic Present Anter => compound auxHar (sett vo) ; + VIndic Past Anter => compound auxHade (sett vo) ; + VFut Simul => compound auxSka (see vo) ; + VFut Anter => compound auxSka (hasett vo) ; + VCondit Simul => compound auxSkulle (see vo) ; + VCondit Anter => compound auxSkulle (hasett vo) ; + VImperat => simple (VF Imper) ; --- no passive + VInfinit Simul => simple (VI (Inf vo)) ; + VInfinit Anter => compound auxHa (sett vo) + } ; + + useVerb : Verb -> (Gender => Number => Str) -> VerbGroup = \verb,arg -> + let aer = verbSForm verb Act in { + s = \\sf => (aer sf).fin ; + s2 = negation ; + s3 = \\sf,g,n => (aer sf).inf ++ arg ! g ! n + } ; + +-- Verb phrases are discontinuous: the parts of a verb phrase are +-- (s) an inflected verb, (s2) verb adverbials (such as negation), and +-- (s3) complement. This discontinuity is needed in sentence formation +-- to account for word order variations. No particle needs to be retained. + + VerbPhrase : Type = { + s : SForm => Str ; + s2 : Str ; + s3 : SForm => Gender => Number => Str + } ; + VerbGroup : Type = { + s : SForm => Str ; + s2 : Bool => Str ; + s3 : SForm => Gender => Number => Str + } ; + + predVerbGroup : Bool -> VerbGroup -> VerbPhrase = \b,vg -> { + s = vg.s ; + s2 = vg.s2 ! b ; + s3 = vg.s3 + } ; + +-- A simple verb can be made into a verb phrase with an empty complement. +-- There are two versions, depending on if we want to negate the verb. +-- N.B. negation is *not* a function applicable to a verb phrase, since +-- double negations with "inte" are not grammatical. + + predVerb : Verb -> VerbGroup = \se -> useVerb se (\\_,_ => se.s1) ; + + negation : Bool => Str = \\b => if_then_Str b [] negInte ; + +-- Verb phrases can also be formed from adjectives ("är snäll"), +-- common nouns ("är en man"), and noun phrases ("är den yngste mannen"). +-- The third rule is overgenerating: "är varje man" has to be ruled out +-- on semantic grounds. + + vara : (Gender => Number => Str) -> VerbGroup = + useVerb (verbVara ** {s1 = []}) ; + + predAdjective : Adjective -> VerbGroup = \arg -> + vara (\\g,n => arg.s ! predFormAdj g n ! Nom) ; + + predFormAdj : Gender -> Number -> AdjFormPos = \g,n -> + mkAdjForm Indef n (gen2nounGen g) ; + + predCommNoun : CommNounPhrase -> VerbGroup = \man -> + vara (\\_,n => indefNoun n man) ; + + predNounPhrase : NounPhrase -> VerbGroup = \john -> + vara (\\_,_ => john.s ! PNom) ; + + predAdverb : Adverb -> VerbGroup = \ute -> + vara (\\_,_ => ute.s) ; + +--3 Transitive verbs +-- +-- Transitive verbs are verbs with a preposition for the complement, +-- in analogy with two-place adjectives and functions. +-- One might prefer to use the term "2-place verb", since +-- "transitive" traditionally means that the inherent preposition is empty. +-- Such a verb is one with a *direct object*. + + TransVerb : Type = Verb ** {s2 : Preposition} ; + + mkTransVerb : Verb -> Preposition -> TransVerb = \v,p -> + v ** {s2 = p} ; + + mkDirectVerb : Verb -> TransVerb = \v -> + mkTransVerb v nullPrep ; + + nullPrep : Preposition = [] ; + + + extTransVerb : Verbum -> Preposition -> TransVerb = \v,p -> + mkTransVerb (v ** {s1 = []}) p ; + + +-- The rule for using transitive verbs is the complementization rule: + + complTransVerb : TransVerb -> NounPhrase -> VerbGroup = \se,dig -> + useVerb se (\\_,_ => se.s1 ++ se.s2 ++ dig.s ! PAcc) ; + +-- Transitive verbs with accusative objects can be used passively. +-- The function does not check that the verb is transitive. +-- Therefore, the function can also be used for "han löps", etc. +-- The syntax is the same as for active verbs, with the choice of the +-- "s" passive form. + + passVerb : Verb -> VerbGroup = \se -> + let ses = verbSForm se Pass in { + s = \\sf => (ses sf).fin ; + s2 = negation ; + s3 = \\sf,g,n => (ses sf).inf ++ se.s1 + } ; + +-- Transitive verbs can be used elliptically as verbs. The semantics +-- is left to applications. The definition is trivial, due to record +-- subtyping. + + transAsVerb : TransVerb -> Verb = \love -> + love ; + +-- *Ditransitive verbs* are verbs with three argument places. +-- We treat so far only the rule in which the ditransitive +-- verb takes both complements to form a verb phrase. + + DitransVerb = TransVerb ** {s3 : Preposition} ; + + mkDitransVerb : Verb -> Preposition -> Preposition -> DitransVerb = \v,p1,p2 -> + v ** {s2 = p1 ; s3 = p2} ; + + complDitransVerb : + DitransVerb -> NounPhrase -> NounPhrase -> VerbGroup = \ge,dig,vin -> + useVerb + ge + (\\_,_ => ge.s1 ++ ge.s2 ++ dig.s ! PAcc ++ ge.s3 ++ vin.s ! PAcc) ; + + +--2 Adverbs +-- +-- Adverbs that modify verb phrases are either post- or pre-verbal. +-- As a rule of thumb, simple adverbs ("bra","alltid") are pre-verbal, +-- but this is not always the case ("här" is post-verbal). +-- Even prepositional phrases can be both +-- ("att han i alla fall skulle komma"). + + Adverb : Type = SS ** {isPost : Bool} ; + PrepPhrase : Type = Adverb ; + + advPre : Str -> Adverb = \alltid -> ss alltid ** {isPost = False} ; + advPost : Str -> Adverb = \bra -> ss bra ** {isPost = True} ; + + adVerbPhrase : VerbPhrase -> Adverb -> VerbPhrase = \spelar, bra -> + let {postp = bra.isPost} in + { + --- this unfortunately generates VP#2 ::= VP#2 + s = spelar.s ; + s2 = (if_then_else Str postp [] bra.s) ++ spelar.s2 ; + s3 = \\sf,g,n => spelar.s3 ! sf ! g ! n ++ (if_then_else Str postp bra.s []) + } ; + + advAdjPhrase : SS -> AdjPhrase -> AdjPhrase = \mycket, dyr -> + {s = \\a,c => mycket.s ++ dyr.s ! a ! c ; + p = dyr.p + } ; + +-- Adverbials are typically generated by prefixing prepositions. +-- The rule for creating locative noun phrases by the preposition "i" +-- is a little shaky: "i Sverige" but "på Island". + + prepPhrase : Preposition -> NounPhrase -> Adverb = \i,huset -> + advPost (i ++ huset.s ! PAcc) ; + + locativeNounPhrase : NounPhrase -> Adverb = + prepPhrase "i" ; + +-- This is a source of the "mannen med teleskopen" ambiguity, and may produce +-- strange things, like "bilar alltid" (while "bilar idag" is OK). +-- Semantics will have to make finer distinctions among adverbials. + + advCommNounPhrase : CommNounPhrase -> PrepPhrase -> CommNounPhrase = \bil,idag -> + {s = \\n, b, c => bil.s ! n ! b ! c ++ idag.s ; + g = bil.g ; + p = bil.p} ; + + +--2 Sentences +-- +-- Sentences depend on a *word order parameter* selecting between main clause, +-- inverted, and subordinate clause. + +param + Order = Main | Inv | Sub ; + +oper + Sentence : Type = SS1 Order ; + +-- This is the traditional $S -> NP VP$ rule. It takes care of both +-- word order and agreement. + + predVerbPhrase : NounPhrase -> VerbPhrase -> Sentence = + \Jag, serdiginte -> + let { + jag = Jag.s ! PNom ; + t = VIndic Present Simul ; ---- to be made parameter of S + ser = serdiginte.s ! t ; + dig = serdiginte.s3 ! t ! Jag.g ! Jag.n ; + inte = serdiginte.s2 + } in + {s = table { + Main => jag ++ ser ++ inte ++ dig ; + Inv => ser ++ jag ++ inte ++ dig ; + Sub => jag ++ inte ++ ser ++ dig + } + } ; + +param + ClForm = + ClIndic Tense Anteriority Order + | ClFut Anteriority Order + | ClCondit Anteriority Order + | ClInfinit Anteriority -- "naked infinitive" clauses + ; + +oper cl2s : ClForm -> {o : Order ; sf : SForm} = \c -> case c of { + ClIndic t a o => {o = o ; sf = VIndic t a} ; + ClFut a o => {o = o ; sf = VFut a} ; + ClCondit a o => {o = o ; sf = VCondit a} ; + ClInfinit a => {o = Sub ; sf = VInfinit a} -- "jag såg John inte hälsa" + } ; + + Clause = {s : Bool => ClForm => Str} ; + + predVerbGroupClause : NounPhrase -> VerbGroup -> Clause = + \Jag, serdiginte -> { + s = \\b,c => let { + jag = Jag.s ! (case c of {ClInfinit _ => PAcc ; _ => PNom}) ; + osf = cl2s c ; + t = osf.sf ; + o = osf.o ; + ser = serdiginte.s ! t ; + dig = serdiginte.s3 ! t ! Jag.g ! Jag.n ; + inte = serdiginte.s2 ! b + } in + case o of { + Main => jag ++ ser ++ inte ++ dig ; + Inv => ser ++ jag ++ inte ++ dig ; + Sub => jag ++ inte ++ ser ++ dig + } + } ; + + +--3 Sentence-complement verbs +-- +-- Sentence-complement verbs take sentences as complements. + + SentenceVerb : Type = Verb ; + + complSentVerb : SentenceVerb -> Sentence -> VerbGroup = \se,duler -> + useVerb se (\\_,_ => se.s1 ++ optStr infinAtt ++ duler.s ! Main) ; + +--3 Verb-complement verbs +-- +-- Verb-complement verbs take verb phrases as complements. +-- They can be auxiliaries ("kan", "måste") or ordinary verbs +-- ("försöka"); this distinction cannot be done in the multilingual +-- API and leads to some anomalies in Swedish, but less so than in English. + + VerbVerb : Type = Verb ** {isAux : Bool} ; + + complVerbVerb : VerbVerb -> VerbGroup -> VerbGroup = \vilja, simma -> + useVerb vilja + (\\g,n => + vilja.s1 ++ + if_then_Str vilja.isAux [] infinAtt ++ + simma.s ! VInfinit Simul ++ simma.s2 ! True ++ ---- Anter! + simma.s3 ! VInfinit Simul ! g ! n) ; + + +--2 Sentences missing noun phrases +-- +-- This is one instance of Gazdar's *slash categories*, corresponding to his +-- $S/NP$. +-- We cannot have - nor would we want to have - a productive slash-category former. +-- Perhaps a handful more will be needed. +-- +-- Notice that the slash category has the same relation to sentences as +-- transitive verbs have to verbs: it's like a *sentence taking a complement*. + + SentenceSlashNounPhrase : Type = Sentence ** {s2 : Preposition} ; + + slashTransVerb : Bool -> NounPhrase -> TransVerb -> SentenceSlashNounPhrase = + \b, Jag, se -> + let { + jag = Jag.s ! PNom ; + ser = se.s ! VF (Pres Ind Act) ; ---- other tenses + inte = negation ! b ++ se.s1 + } in + {s = table { + Main => jag ++ ser ++ inte ; + Inv => ser ++ jag ++ inte ; + Sub => jag ++ inte ++ ser + } ; + s2 = se.s2 + } ; + + +--2 Relative pronouns and relative clauses +-- +-- Relative pronouns can be nominative, accusative, or genitive, and +-- they depend on gender and number just like adjectives. +-- Moreover they may or may not carry their own genders: for instance, +-- "som" just transmits the gender of a noun ("tal som är primt"), whereas +-- "vars efterföljare" is $Utrum$ independently of the noun +-- ("tal vars efterföljare är prim"). +-- This variation is expressed by the $RelGender$ type. + + RelPron : Type = {s : RelCase => GenNum => Str ; g : RelGender} ; + +param + RelGender = RNoGen | RG Gender ; + +-- The following functions are selectors for relative-specific parameters. + +oper + -- this will be needed in "tal som är jämnt" / "tal vars efterföljare är jämn" + mkGenderRel : RelGender -> Gender -> Gender = \rg,g -> case rg of { + RG gen => gen ; + _ => g + } ; + + relCase : RelCase -> Case = \c -> case c of { + RGen => Gen ; + _ => Nom + } ; + +-- The simplest relative pronoun has no gender of its own. As accusative variant, +-- it has the omission of the pronoun ("mannen (som) jag ser"). + + identRelPron : RelPron = + {s = table { + RNom => \\_ => "som" ; + RAcc => \\_ => variants {"som" ; []} ; + RGen => \\_ => pronVars ; + RPrep => pronVilken + } ; + g = RNoGen + } ; + +-- Composite relative pronouns have the same variation as function +-- applications ("efterföljaren till vilket" - "vars efterföljare"). + + funRelPron : Function -> RelPron -> RelPron = \värde,vilken -> + {s = \\c,gn => + variants { + vilken.s ! RGen ! gn ++ värde.s ! numGN gn ! Indef ! relCase c ; + värde.s ! numGN gn ! Def ! Nom ++ värde.s2 ++ vilken.s ! RPrep ! gn + } ; + g = RG (genNoun värde.g) + } ; + +-- Relative clauses can be formed from both verb phrases ("som sover") and +-- slash expressions ("som jag ser"). The latter has moreover the variation +-- as for the place of the preposition ("som jag talar om" - "om vilken jag talar"). + + RelClause : Type = {s : GenNum => Str} ; + + relVerbPhrase : RelPron -> VerbPhrase -> RelClause = \som,sover -> + {s = \\gn => + som.s ! RNom ! gn ++ sover.s2 ++ sover.s ! VIndic Present Simul + ---- Past and Anter ! + ++ + sover.s3 ! VIndic Present Simul ! mkGenderRel som.g (genGN gn) ! numGN gn + } ; + + relSlash : RelPron -> SentenceSlashNounPhrase -> RelClause = \som,jagTalar -> + {s = \\gn => + let {jagtalar = jagTalar.s ! Sub ; om = jagTalar.s2} in + variants { + som.s ! RAcc ! gn ++ jagtalar ++ om ; + om ++ som.s ! RPrep ! gn ++ jagtalar + } + } ; + +-- A 'degenerate' relative clause is the one often used in mathematics, e.g. +-- "tal x sådant att x är primt". + + relSuch : Sentence -> RelClause = \A -> + {s = \\g => pronSådan ! g ++ infinAtt ++ A.s ! Sub} ; + +-- The main use of relative clauses is to modify common nouns. +-- The result is a common noun, out of which noun phrases can be formed +-- by determiners. + + modRelClause : CommNounPhrase -> RelClause -> CommNounPhrase = \man,somsover -> + {s = \\n,b,c => man.s ! n ! b ! c ++ somsover.s ! gNum (genNoun man.g) n ; + g = man.g ; + p = False + } ; + +-- N.B. we do not get the determinative pronoun +-- construction "den man som sover" in this way, but only "mannen som sover". +-- Thus we need an extra rule: + + detRelClause : Number -> CommNounPhrase -> RelClause -> NounPhrase = + \n,man,somsover -> + {s = \\c => let {gn = gNum (genNoun man.g) n} in + artDef ! True ! gn ++ + man.s ! n ! DefP Indef ! npCase c ++ somsover.s ! gn ; + g = genNoun man.g ; + n = n + } ; + + +--2 Interrogative pronouns +-- +-- If relative pronouns are adjective-like, interrogative pronouns are +-- noun-phrase-like. Actually we can use the very same type! + + IntPron : Type = NounPhrase ; + +-- In analogy with relative pronouns, we have a rule for applying a function +-- to a relative pronoun to create a new one. We can reuse the rule applying +-- functions to noun phrases! + + funIntPron : Function -> IntPron -> IntPron = + appFun False ; + +-- There is a variety of simple interrogative pronouns: +-- "vilken bil", "vem", "vad". + + nounIntPron : Number -> CommNounPhrase -> IntPron = \n -> + detNounPhrase (vilkDet n) ; + + intPronWho : Number -> IntPron = \num -> { + s = table { + PGen _ => pronVems ; + _ => pronVem + } ; + g = Utr ; + n = num + } ; + + intPronWhat : Number -> IntPron = \num -> { + s = table { + PGen _ => nonExist ; --- + _ => "hvad" + } ; + n = num ; + g = Neutr + } ; + +--2 Utterances + +-- By utterances we mean whole phrases, such as +-- 'can be used as moves in a language game': indicatives, questions, imperative, +-- and one-word utterances. The rules are far from complete. +-- +-- N.B. we have not included rules for texts, which we find we cannot say much +-- about on this level. In semantically rich GF grammars, texts, dialogues, etc, +-- will of course play an important role as categories not reducible to utterances. +-- An example is proof texts, whose semantics show a dependence between premises +-- and conclusions. Another example is intersentential anaphora. + + Utterance = SS ; + + indicUtt : Sentence -> Utterance = \x -> postfixSS "." (defaultSentence x) ; + interrogUtt : Question -> Utterance = \x -> postfixSS "?" (defaultQuestion x) ; + + +--2 Questions +-- +-- Questions are either direct ("vem tog bollen") or indirect +-- ("vem som tog bollen"). + +param + QuestForm = DirQ | IndirQ ; + +oper + Question = SS1 QuestForm ; + +--3 Yes-no questions +-- +-- Yes-no questions are used both independently ("tog du bollen") +-- and after interrogative adverbials ("varför tog du bollen"). +-- It is economical to handle with these two cases by the one +-- rule, $questVerbPhrase'$. The only difference is if "om" appears +-- in the indirect form. + + questVerbPhrase : NounPhrase -> VerbPhrase -> Question = + questVerbPhrase' False ; + + questVerbPhrase' : Bool -> NounPhrase -> VerbPhrase -> Question = + \adv,du,sover -> + let {dusover = (predVerbPhrase du sover).s} in + {s = table { + DirQ => dusover ! Inv ; + IndirQ => (if_then_else Str adv [] conjOm) ++ dusover ! Sub + } + } ; + +--3 Wh-questions +-- +-- Wh-questions are of two kinds: ones that are like $NP - VP$ sentences, +-- others that are line $S/NP - NP$ sentences. + + intVerbPhrase : IntPron -> VerbPhrase -> Question = \vem,sover -> + let {vemsom : NounPhrase = + {s = \\c => vem.s ! c ++ "som" ; g = vem.g ; n = vem.n} + } in + {s = table { + DirQ => (predVerbPhrase vem sover).s ! Main ; + IndirQ => (predVerbPhrase vemsom sover).s ! Sub + } + } ; + + intSlash : IntPron -> SentenceSlashNounPhrase -> Question = \Vem, jagTalar -> + let { + vem = Vem.s ! PAcc ; + jagtalar = jagTalar.s ! Sub ; + talarjag = jagTalar.s ! Inv ; + om = jagTalar.s2 + } in + {s = table { + DirQ => variants { + vem ++ talarjag ++ om ; + om ++ vem ++ talarjag + } ; + IndirQ => variants { + vem ++ jagtalar ++ om ; + om ++ vem ++ jagtalar + } + } + } ; + +--3 Interrogative adverbials +-- +-- These adverbials will be defined in the lexicon: they include +-- "när", "var", "hur", "varför", etc, which are all invariant one-word +-- expressions. In addition, they can be formed by adding prepositions +-- to interrogative pronouns, in the same way as adverbials are formed +-- from noun phrases. N.B. we rely on record subtyping when ignoring the +-- position component. + + IntAdverb = SS ; + + prepIntAdverb : Preposition -> IntPron -> IntAdverb = + prepPhrase ; + +-- A question adverbial can be applied to anything, and whether this makes +-- sense is a semantic question. + + questAdverbial : IntAdverb -> NounPhrase -> VerbPhrase -> Question = + \hur, du, mår -> + {s = \\q => hur.s ++ (questVerbPhrase' True du mår).s ! q} ; + + +--2 Imperatives +-- +-- We only consider second-person imperatives. + + Imperative = SS1 Number ; + + imperVerbPhrase : VerbPhrase -> Imperative = \titta -> + {s = \\n => titta.s ! VImperat ++ titta.s2 ++ titta.s3 ! VImperat ! Utr ! n} ; + + imperUtterance : Number -> Imperative -> Utterance = \n,I -> + ss (I.s ! n ++ "!") ; + +--2 Sentence adverbials +-- +-- This class covers adverbials such as "annars", "därför", which are prefixed +-- to a sentence to form a phrase. + + advSentence : SS -> Sentence -> Utterance = \annars,soverhan -> + ss (annars.s ++ soverhan.s ! Inv ++ ".") ; + + +--2 Coordination +-- +-- Coordination is to some extent orthogonal to the rest of syntax, and +-- has been treated in a generic way in the module $CO$ in the file +-- $coordination.gf$. The overall structure is independent of category, +-- but there can be differences in parameter dependencies. +-- +--3 Conjunctions +-- +-- Coordinated phrases are built by using conjunctions, which are either +-- simple ("och", "eller") or distributed ("både - och", "antingen - eller"). +-- +-- The conjunction has an inherent number, which is used when conjoining +-- noun phrases: "John och Mary är rika" vs. "John eller Mary är rik"; in the +-- case of "eller", the result is however plural if any of the disjuncts is. + + Conjunction = CO.Conjunction ** {n : Number} ; + ConjunctionDistr = CO.ConjunctionDistr ** {n : Number} ; + + +--3 Coordinating sentences +-- +-- We need a category of lists of sentences. It is a discontinuous +-- category, the parts corresponding to 'init' and 'last' segments +-- (rather than 'head' and 'tail', because we have to keep track of the slot between +-- the last two elements of the list). A list has at least two elements. + + ListSentence : Type = {s1,s2 : Order => Str} ; + + twoSentence : (_,_ : Sentence) -> ListSentence = + CO.twoTable Order ; + + consSentence : ListSentence -> Sentence -> ListSentence = + CO.consTable Order CO.comma ; + +-- To coordinate a list of sentences by a simple conjunction, we place +-- it between the last two elements; commas are put in the other slots, +-- e.g. "månen lyser, solen skiner och stjärnorna blinkar". + + conjunctSentence : Conjunction -> ListSentence -> Sentence = + CO.conjunctTable Order ; + + conjunctOrd : Bool -> Conjunction -> CO.ListTable Order -> {s : Order => Str} = + \b,or,xs -> + {s = \\p => xs.s1 ! p ++ or.s ++ xs.s2 ! p} ; + + +-- To coordinate a list of sentences by a distributed conjunction, we place +-- the first part (e.g. "antingen") in front of the first element, the second +-- part ("eller") between the last two elements, and commas in the other slots. +-- For sentences this is really not used. + + conjunctDistrSentence : ConjunctionDistr -> ListSentence -> Sentence = + CO.conjunctDistrTable Order ; + +--3 Coordinating adjective phrases +-- +-- The structure is the same as for sentences. The result is a prefix adjective +-- if and only if all elements are prefix. + + ListAdjPhrase : Type = + {s1,s2 : AdjFormPos => Case => Str ; p : Bool} ; + + twoAdjPhrase : (_,_ : AdjPhrase) -> ListAdjPhrase = \x,y -> + CO.twoTable2 AdjFormPos Case x y ** {p = andB x.p y.p} ; + consAdjPhrase : ListAdjPhrase -> AdjPhrase -> ListAdjPhrase = \xs,x -> + CO.consTable2 AdjFormPos Case CO.comma xs x ** {p = andB xs.p x.p} ; + + conjunctAdjPhrase : Conjunction -> ListAdjPhrase -> AdjPhrase = \c,xs -> + CO.conjunctTable2 AdjFormPos Case c xs ** {p = xs.p} ; + + conjunctDistrAdjPhrase : ConjunctionDistr -> ListAdjPhrase -> AdjPhrase = \c,xs -> + CO.conjunctDistrTable2 AdjFormPos Case c xs ** {p = xs.p} ; + + +--3 Coordinating noun phrases +-- +-- The structure is the same as for sentences. The result is either always plural +-- or plural if any of the components is, depending on the conjunction. +-- The gender is neuter if any of the components is. + + ListNounPhrase : Type = {s1,s2 : NPForm => Str ; g : Gender ; n : Number} ; + + twoNounPhrase : (_,_ : NounPhrase) -> ListNounPhrase = \x,y -> + CO.twoTable NPForm x y ** {n = conjNumber x.n y.n ; g = conjGender x.g y.g} ; + + consNounPhrase : ListNounPhrase -> NounPhrase -> ListNounPhrase = \xs,x -> + CO.consTable NPForm CO.comma xs x ** + {n = conjNumber xs.n x.n ; g = conjGender xs.g x.g} ; + + conjunctNounPhrase : Conjunction -> ListNounPhrase -> NounPhrase = \c,xs -> + CO.conjunctTable NPForm c xs ** {n = conjNumber c.n xs.n ; g = xs.g} ; + + conjunctDistrNounPhrase : ConjunctionDistr -> ListNounPhrase -> NounPhrase = + \c,xs -> + CO.conjunctDistrTable NPForm c xs ** {n = conjNumber c.n xs.n ; g = xs.g} ; + +-- We hve to define a calculus of numbers of genders. For numbers, +-- it is like the conjunction with $Pl$ corresponding to $False$. For genders, +-- $Neutr$ corresponds to $False$. + + conjNumber : Number -> Number -> Number = \m,n -> case of { + => Sg ; + _ => Pl + } ; + + conjGender : Gender -> Gender -> Gender = \m,n -> case of { + => Utr ; + _ => Neutr + } ; + + +--2 Subjunction +-- +-- Subjunctions ("om", "när", etc) +-- are a different way to combine sentences than conjunctions. +-- The main clause can be a sentences, an imperatives, or a question, +-- but the subjoined clause must be a sentence. +-- +-- There are uniformly two variant word orders, e.g. "om du sover kommer björnen" +-- and "björnen kommer om du sover". + + Subjunction = SS ; + + subjunctSentence : Subjunction -> Sentence -> Sentence -> Sentence = \if, A, B -> + let {As = A.s ! Sub} in + {s = table { + Main => variants {if.s ++ As ++ "," ++ B.s ! Inv ; + B.s ! Main ++ "," ++ if.s ++ As} ; + o => B.s ! o ++ "," ++ if.s ++ As + } + } ; + + subjunctImperative : Subjunction -> Sentence -> Imperative -> Imperative = + \if, A, B -> + {s = \\n => subjunctVariants if A (B.s ! n)} ; + + subjunctQuestion : Subjunction -> Sentence -> Question -> Question = \if, A, B -> + {s = \\q => subjunctVariants if A (B.s ! q)} ; + + subjunctVariants : Subjunction -> Sentence -> Str -> Str = \if,A,B -> + let {As = A.s ! Sub} in + variants {if.s ++ As ++ "," ++ B ; B ++ "," ++ if.s ++ As} ; + + subjunctVerbPhrase : VerbPhrase -> Subjunction -> Sentence -> VerbPhrase = + \V, if, A -> + adVerbPhrase V (advPost (if.s ++ A.s ! Sub)) ; + +--2 One-word utterances +-- +-- An utterance can consist of one phrase of almost any category, +-- the limiting case being one-word utterances. These +-- utterances are often (but not always) in what can be called the +-- default form of a category, e.g. the nominative. +-- This list is far from exhaustive. + + useNounPhrase : NounPhrase -> Utterance = \john -> + postfixSS "." (defaultNounPhrase john) ; + useCommonNounPhrase : Number -> CommNounPhrase -> Utterance = \n,car -> + useNounPhrase (indefNounPhrase n car) ; + +-- Here are some default forms. + + defaultNounPhrase : NounPhrase -> SS = \john -> + ss (john.s ! PNom) ; + + defaultQuestion : Question -> SS = \whoareyou -> + ss (whoareyou.s ! DirQ) ; + + defaultSentence : Sentence -> Utterance = \x -> ss (x.s ! Main) ; + +----------- changes when parametrizing 20/1/2005 + +---- moved from Morphology + +-- Prepositions are just strings. + Preposition = Str ; + +-- Relative pronouns have a special case system. $RPrep$ is the form used +-- after a preposition (e.g. "det hus i vilket jag bor"). +param + RelCase = RNom | RAcc | RGen | RPrep ; +-- A simplified verb category: present tense only (no more!). + +oper + relPronForms : RelCase => GenNum => Str ; + + pronVilken : GenNum => Str ; + + pronSådan : GenNum => Str ; + + pronNågon : GenNum => Str ; + + deponentVerb : Verb -> Verb ; + + verbFinnas : Verb ; + verbVara : Verb ; + verbHava : Verb ; + + auxHar, auxHade, auxHa, auxSka, auxSkulle : Str ; + + infinAtt : Str ; + prepÄn : Str ; + negInte : Str ; + conjOm : Str ; + + pronVars, pronVem, pronVems : Str ; + +} ; diff --git a/lib/resource/scandinavian/TypesScand.gf b/lib/resource/scandinavian/TypesScand.gf new file mode 100644 index 000000000..b14333d54 --- /dev/null +++ b/lib/resource/scandinavian/TypesScand.gf @@ -0,0 +1,151 @@ +--1 Scandinavian Word Classes and Morphological Parameters +-- +-- This is a resource module for Swedish morphology, defining the +-- morphological parameters and word classes of Swedish. It is aimed +-- to be complete w.r.t. the description of word forms. +-- However, it does not include those parameters that are not needed for +-- analysing individual words: such parameters are defined in syntax modules. +-- +-- This GF grammar was obtained from the functional morphology file TypesSw.hs +-- semi-automatically. The GF inflection engine obtained was obtained automatically. + +interface TypesScand = { + +-- + +--2 Enumerated parameter types +-- +-- These types are the ones found in school grammars. +-- Their parameter values are atomic. + +param + Gender = Utr | Neutr ; + Number = Sg | Pl ; + Species = Indef | Def ; + Case = Nom | Gen ; + Sex = NoMasc | Masc ; + Mode = Ind | Cnj ; + Voice = Act | Pass ; + Degree = Pos | Comp | Sup ; + Person = P1 | P2 | P3 ; + +--2 Word classes and hierarchical parameter types +-- +-- Real parameter types (i.e. ones on which words and phrases depend) +-- are mostly hierarchical. The alternative would be cross-products of +-- simple parameters, but this would usually overgenerate. +-- + +--3 Substantives +-- +-- Substantives (= common nouns) have a parameter of type SubstForm. + +param SubstForm = SF Number Species Case ; + +-- Substantives moreover have an inherent gender. + +oper Subst : Type = {s : SubstForm => Str ; h1 : Gender} ; + +--3 Adjectives +-- +-- Adjectives are a very complex class, and the full table has as many as +-- 18 different forms. The major division is between the comparison degrees; +-- the comparative has only the 2 case forms, whereas the positive has 12 forms. + +param + AdjForm = AF AdjFormGrad Case ; + +-- The positive strong forms depend on gender: "en stor bil" - "ett stort hus". +-- But the weak forms depend on sex: "den stora bilen" - "den store mannen". +-- The plural never makes a gender-sex distinction. + + GenNum = ASg Gender | APl ; + SexNum = AxSg Sex | AxPl ; + +-- This parameter is different from $Gender$ only for Swedish. + +param + NounGender ; + +oper + genNoun : NounGender -> Gender ; + sexNoun : NounGender -> Sex ; + gen2nounGen : Gender -> NounGender ; + +param + AdjFormPos ; + AdjFormSup = SupStrong | SupWeak ; + + AdjFormGrad = + Posit AdjFormPos + | Compar + | Super AdjFormSup ; + +oper + Adj : Type = {s : AdjForm => Str} ; + + adverbForm : AdjFormPos = Strong (ASg Neutr) ; + +--3 Verbs +-- +-- Verbs have 9 finite forms and as many as 18 infinite forms; the large number +-- of the latter comes from adjectives. + +oper Verbum : Type = {s : VerbForm => Str} ; + +param + VFin ; + + VInf ; + + VerbForm = + VF VFin + | VI VInf ; + +-- However, the syntax only needs a simplified verb category, with +-- present tense only. Such a verb can be extracted from the full verb, +-- and a choice can be made between an active and a passive (deponent) verb. +-- Active verbs continue to have passive forms. But we add an extra field $s1$ +-- for a verb particle, as e.g. in "se upp". + +oper + Verb : Type = {s : VerbForm => Str ; s1 : Str} ; + + vNopart : Verbum -> Verb = \v -> v ** {s1 = []} ; + +--3 Other open classes +-- +-- Proper names, adverbs (Adv having comparison forms and AdvIn not having them), +-- and interjections are the remaining open classes. + +oper + PNm : Type = {s : Case => Str ; h1 : Gender} ; + Adv : Type = {s : Degree => Str} ; + AdvInv : Type = {s : Str} ; + Interj : Type = {s : Str} ; + +--3 Closed classes +-- +-- The rest of the Swedish word classes are closed, i.e. not extensible by new +-- lexical entries. Thus we don't have to know how to build them, but only +-- how to use them, i.e. which parameters they have. +-- +-- The most important distinction is between proper-name-like pronouns and +-- adjective-like pronouns, which are inflected in completely different parameters. + +param + NPForm = PNom | PAcc | PGen GenNum ; + AdjPronForm = APron GenNum Case ; + AuxVerbForm = AuxInf | AuxPres | AuxPret | AuxSup ; + +oper + ProPN : Type = {s : NPForm => Str ; h1 : Gender ; h2 : Number ; h3 : Person} ; + ProAdj : Type = {s : AdjPronForm => Str} ; + Prep : Type = {s : Str} ; + Conjunct : Type = {s : Str} ; + Subjunct : Type = {s : Str} ; + Art : Type = {s : GenNum => Str} ; + Part : Type = {s : Str} ; + Infin : Type = {s : Str} ; + VAux : Type = {s : AuxVerbForm => Str} ; +} diff --git a/lib/resource/swedish/CategoriesSwe.gf b/lib/resource/swedish/CategoriesSwe.gf index 254a23e36..06cf676d2 100644 --- a/lib/resource/swedish/CategoriesSwe.gf +++ b/lib/resource/swedish/CategoriesSwe.gf @@ -1,83 +1,4 @@ ---# -path=.:../abstract:../../prelude +--# -path=.:../scandinavian:../abstract:../../prelude ---1 The Top-Level Swedish Resource Grammar: Combination Rules --- --- Aarne Ranta 2002 -- 2003 --- --- This is the Swedish concrete syntax of the multilingual resource --- grammar. Most of the work is done in the file $SyntaxSwe.gf$. --- However, for the purpose of documentation, we make here explicit the --- linearization types of each category, so that their structures and --- dependencies can be seen. --- Another substantial part are the linearization rules of some --- structural words. --- --- The users of the resource grammar should not look at this file for the --- linearization rules, which are in fact hidden in the document version. --- They should use $resource.Abs.gf$ to access the syntactic rules. --- This file can be consulted in those, hopefully rare, occasions in which --- one has to know how the syntactic categories are --- implemented. The parameter types are defined in $TypesSwe.gf$. - -concrete CategoriesSwe of Categories = open Prelude, SyntaxSwe in { - -flags - startcat=Phr ; - lexer=text ; - unlexer=text ; - -lincat - CN = {s : Number => SpeciesP => Case => Str ; g : Gender ; x : Sex ; - p : IsComplexCN} ; - N = CommNoun ; - -- = {s : Number => Species => Case => Str ; g : Gender ; x : Sex} ; - NP = NounPhrase ; - -- = {s : NPForm => Str ; g : Gender ; n : Number} ; - PN = {s : Case => Str ; g : Gender ; x : Sex} ; - Det = {s : Gender => Sex => Str ; n : Number ; b : SpeciesP} ; - N2 = Function ; - -- = CommNoun ** {s2 : Preposition} ; - N3 = Function ** {s3 : Preposition} ; - Num = {s : Case => Str} ; - Prep = {s : Str} ; - - A = Adjective ; - -- = {s : AdjFormPos => Case => Str} ; - A2 = Adjective ** {s2 : Preposition} ; - ADeg = {s : AdjForm => Str} ; - AP = Adjective ** {p : IsPostfixAdj} ; - - V = Verb ; - -- = {s : VerbForm => Str ; s1 : Str} ; - VG = {s : SForm => Str ; s2 : Bool => Str ; s3 : SForm => Gender => Number => Str} ; - VP = {s : SForm => Str ; s2 : Str ; s3 : SForm => Gender => Number => Str} ; - V2 = TransVerb ; - -- = Verb ** {s2 : Preposition} ; - V3 = TransVerb ** {s3 : Preposition} ; - VS = Verb ; - VV = Verb ** {isAux : Bool} ; - - Adv = Adverb ; - -- = {s : Str ; isPost : Bool} ; - PP = Adverb ; - - S = Sentence ; - -- = {s : Order => Str} ; - Cl = Clause ; - -- = {s : Bool => SForm => Order => Str} ; - Slash = Sentence ** {s2 : Preposition} ; - RP = {s : RelCase => GenNum => Str ; g : RelGender} ; - RC = {s : GenNum => Str} ; - IP = NounPhrase ; - Qu = {s : QuestForm => Str} ; - Imp = {s : Number => Str} ; - - Phr = {s : Str} ; - - Conj = {s : Str ; n : Number} ; - ConjD = {s1 : Str ; s2 : Str ; n : Number} ; - - ListS = {s1,s2 : Order => Str} ; - ListAP = {s1,s2 : AdjFormPos => Case => Str ; p : Bool} ; - ListNP = {s1,s2 : NPForm => Str ; g : Gender ; n : Number} ; -} +concrete CategoriesSwe of Categories = + CategoriesScand with (SyntaxScand=SyntaxSwe) ; diff --git a/lib/resource/swedish/MorphoSwe.gf b/lib/resource/swedish/MorphoSwe.gf index 42c989548..1c791bab2 100644 --- a/lib/resource/swedish/MorphoSwe.gf +++ b/lib/resource/swedish/MorphoSwe.gf @@ -10,45 +10,7 @@ resource MorphoSwe = TypesSwe ** open Prelude in { --- The indefinite and definite article oper - artIndef = table {Utr => "en" ; Neutr => "ett"} ; - - artDef : Bool => GenNum => Str = table { - True => table { - ASg Utr => "den" ; - ASg Neutr => "det" ; -- det gamla huset - APl => variants {"de" ; "dom"} - } ; - False => table {_ => []} -- huset - } ; - --- A simplified verb category: present tense only (no more!). - -oper - verbVara = vara_1200 ; - verbHava = hava_1198 ; - - verbFinnas : Verb = vFinna "finn" "fann" "funn" ** {s1 = []} ; - - deponentVerb : Verb -> Verb = \finna -> { - s = table { - VF (Pres m _) => finna.s ! VF (Pres m Pass) ; - VF (Pret m _) => finna.s ! VF (Pret m Pass) ; - VI (Inf _) => finna.s ! VI (Inf Pass) ; - VI (Supin _) => finna.s ! VI (Supin Pass) ; - v => finna.s ! v --- Imper ! - } ; - s1 = finna.s1 - } ; - -{- deprecated - - verbFinnas = mkVerb "finnas" "finns" "finns" ; - --- A simplified conjugation takes three forms in the worst case, plus a particle. --} - mkVerbPart : (supa,super,sup,söp,supit,supen,upp : Str) -> Verb = \finna,finner,finn,fann,funnit,funnen,upp -> let funn = ptPretForms funnen in diff --git a/lib/resource/swedish/RulesSwe.gf b/lib/resource/swedish/RulesSwe.gf index adc85ffca..480bb8c21 100644 --- a/lib/resource/swedish/RulesSwe.gf +++ b/lib/resource/swedish/RulesSwe.gf @@ -1,140 +1,4 @@ -concrete RulesSwe of Rules = CategoriesSwe ** open Prelude, SyntaxSwe in { +--# -path=.:../scandinavian:../abstract:../../prelude -lin - UseN = noun2CommNounPhrase ; - ModAP = modCommNounPhrase ; - ModGenOne = npGenDet singular noNum ; - ModGenNum = npGenDet plural ; - UsePN = nameNounPhrase ; - UseN2 = funAsCommNounPhrase ; - AppN2 = appFunComm ; - AppN3 = appFun2 ; - UseA = adj2adjPhrase ; - ComplA2 = complAdj ; - PositADeg = positAdjPhrase ; - ComparADeg = comparAdjPhrase ; - SuperlNP = superlNounPhrase ; - - DetNP = detNounPhrase ; - IndefOneNP = indefNounPhrase singular ; - IndefNumNP = indefNounPhraseNum plural ; - DefOneNP = defNounPhrase singular ; - DefNumNP = defNounPhraseNum plural ; - MassNP = detNounPhrase (mkDeterminerSg (detSgInvar []) IndefP) ; - UseInt i = {s = table {Nom => i.s ; Gen => i.s ++ "s"}} ; --- - NoNum = noNum ; - - SymbPN i = {s = \\_ => i.s ; g = Neutr ; x = NoMasc} ; - SymbCN cn s = - {s = \\a,n,c => cn.s ! a ! n ! c ++ s.s ; - g = cn.g ; - x = cn.x ; - p = cn.p - } ; - IntCN cn s = - {s = \\a,n,c => cn.s ! a ! n ! c ++ s.s ; - g = cn.g ; - x = cn.x ; - p = cn.p - } ; - - CNthatS = nounThatSentence ; - - PredVP = predVerbPhrase ; - - PosVG = predVerbGroup True ; - NegVG = predVerbGroup False ; - - PredVG = predVerbGroupClause ; - - PredV = predVerb ; - PredAP = predAdjective ; - PredSuperl a = predAdjective (superlAdjPhrase a) ; - PredCN = predCommNoun ; - PredV2 = complTransVerb ; - PredV3 = complDitransVerb ; - PredPassV = passVerb ; - PredNP = predNounPhrase ; - PredPP = predAdverb ; - PredVS = complSentVerb ; - PredVV = complVerbVerb ; - VTrans = transAsVerb ; - - AdjAdv a = advPost (a.s ! adverbForm ! Nom) ; - AdvPP p = p ; - PrepNP p = prepPhrase p.s ; --- - AdvVP = adVerbPhrase ; - AdvCN = advCommNounPhrase ; - AdvAP = advAdjPhrase ; - - ThereNP A = predVerbPhrase npDet - (predVerbGroup True - (complTransVerb (mkDirectVerb (deponentVerb verbFinnas)) A)) ; - - PosSlashV2 = slashTransVerb True ; - NegSlashV2 = slashTransVerb False ; - OneVP = predVerbPhrase npMan ; - - IdRP = identRelPron ; - FunRP = funRelPron ; - RelVP = relVerbPhrase ; - RelSlash = relSlash ; - ModRC = modRelClause ; - RelSuch = relSuch ; - - WhoOne = intPronWho singular ; - WhoMany = intPronWho plural ; - WhatOne = intPronWhat singular ; - WhatMany = intPronWhat plural ; - FunIP = funIntPron ; - NounIPOne = nounIntPron singular ; - NounIPMany = nounIntPron plural ; - - QuestVP = questVerbPhrase ; - IntVP = intVerbPhrase ; - IntSlash = intSlash ; - QuestAdv = questAdverbial ; - IsThereNP A = questVerbPhrase npDet - (predVerbGroup True - (complTransVerb (mkDirectVerb (deponentVerb verbFinnas)) A)) ; - - ImperVP = imperVerbPhrase ; - - IndicPhrase = indicUtt ; - QuestPhrase = interrogUtt ; - ImperOne = imperUtterance singular ; - ImperMany = imperUtterance plural ; - - PrepS p = ss (p.s ++ ",") ; - AdvS = advSentence ; - - TwoS = twoSentence ; - ConsS = consSentence ; - ConjS = conjunctSentence ; - ConjDS = conjunctDistrSentence ; - - TwoAP = twoAdjPhrase ; - ConsAP = consAdjPhrase ; - ConjAP = conjunctAdjPhrase ; - ConjDAP = conjunctDistrAdjPhrase ; - - TwoNP = twoNounPhrase ; - ConsNP = consNounPhrase ; - ConjNP = conjunctNounPhrase ; - ConjDNP = conjunctDistrNounPhrase ; - - SubjS = subjunctSentence ; - SubjImper = subjunctImperative ; - SubjQu = subjunctQuestion ; - SubjVP = subjunctVerbPhrase ; - - PhrNP = useNounPhrase ; - PhrOneCN = useCommonNounPhrase singular ; - PhrManyCN = useCommonNounPhrase plural ; - PhrIP ip = ip ; - PhrIAdv ia = ia ; - - OnePhr p = p ; - ConsPhr = cc2 ; - -} ; +concrete RulesSwe of Rules = + RulesScand with (SyntaxScand=SyntaxSwe) ; diff --git a/lib/resource/swedish/StructuralSwe.gf b/lib/resource/swedish/StructuralSwe.gf index 1956a7d96..64eb10b45 100644 --- a/lib/resource/swedish/StructuralSwe.gf +++ b/lib/resource/swedish/StructuralSwe.gf @@ -1,11 +1,11 @@ ---# -path=.:../abstract:../../prelude +--# -path=.:../abstract:../scandinavian:../../prelude --1 The Top-Level Swedish Resource Grammar: Structural Words -- -- Aarne Ranta 2002 -- 2004 -- concrete StructuralSwe of Structural = - CategoriesSwe, NumeralsSwe ** open Prelude, SyntaxSwe in { + CategoriesSwe, NumeralsSwe ** open Prelude, MorphoSwe, SyntaxSwe in { lin INP = pronNounPhrase jag_32 ; @@ -20,8 +20,8 @@ concrete StructuralSwe of Structural = YouNP = let {ni = pronNounPhrase ni_37 } in {s = ni.s ; g = ni.g ; n = Sg} ; ItNP = pronNounPhrase det_40 ; ---- - ThisNP = regNameNounPhrase ["det här"] Neutr NoMasc ; - ThatNP = regNameNounPhrase ["det där"] Neutr NoMasc ; + ThisNP = regNameNounPhrase ["det här"] NNeutr ; + ThatNP = regNameNounPhrase ["det där"] NNeutr ; TheseNumNP n = {s = \\c => ["de här"] ++ n.s ! npCase c ; g = Neutr ; n = Pl} ; ThoseNumNP n = @@ -75,11 +75,11 @@ concrete StructuralSwe of Structural = EverybodyNP = let alla = table {Nom => "alla" ; Gen => "allas"} in {s = \\c => alla ! npCase c ; g = Utr ; n = Pl} ; - SomebodyNP = nameNounPhrase (mkProperName "någon" Utr Masc) ; - NobodyNP = nameNounPhrase (mkProperName "ingen" Utr Masc) ; - EverythingNP = nameNounPhrase (mkProperName "allting" Neutr NoMasc) ; - SomethingNP = nameNounPhrase (mkProperName "någonting" Neutr NoMasc) ; - NothingNP = nameNounPhrase (mkProperName "ingenting" Neutr NoMasc) ; + SomebodyNP = nameNounPhrase (mkProperName "någon" (NUtr Masc)) ; + NobodyNP = nameNounPhrase (mkProperName "ingen" (NUtr Masc)) ; + EverythingNP = nameNounPhrase (mkProperName "allting" NNeutr) ; + SomethingNP = nameNounPhrase (mkProperName "någonting" NNeutr) ; + NothingNP = nameNounPhrase (mkProperName "ingenting" NNeutr) ; CanVV = mkVerb "kunna" "kan" "kunn" "kunde" "kunnat" "kunnen" ** {isAux = True} ; CanKnowVV = mkVerb "kunna" "kan" "kunn" "kunde" "kunnat" "kunnen" ** {isAux = True} ; diff --git a/lib/resource/swedish/SyntaxSwe.gf b/lib/resource/swedish/SyntaxSwe.gf index 8385498a2..9a5960382 100644 --- a/lib/resource/swedish/SyntaxSwe.gf +++ b/lib/resource/swedish/SyntaxSwe.gf @@ -1,1229 +1,108 @@ +--# -path=.:../scandinavian:../../prelude + --1 A Small Swedish Resource Syntax -- --- Aarne Ranta 2002 +-- Aarne Ranta 2002 - 2005 -- --- This resource grammar contains definitions needed to construct --- indicative, interrogative, and imperative sentences in Swedish. --- --- The following modules are presupposed: +instance SyntaxSwe of SyntaxScand = TypesSwe ** + open Prelude, (CO = Coordination), MorphoSwe in { -resource SyntaxSwe = MorphoSwe ** open Prelude, (CO = Coordination) in { + oper ---2 Common Nouns --- ---3 Simple common nouns - -oper - CommNoun : Type = {s : Number => Species => Case => Str ; g : Gender ; x : Sex} ; - --- When common nouns are extracted from lexicon, the composite noun form is ignored. --- But we have to indicate a sex. - extCommNoun : Sex -> Subst -> CommNoun = \x,sb -> + extCommNounMasc : Subst -> CommNoun = \sb -> {s = \\n,b,c => sb.s ! SF n b c ; - g = sb.h1 ; - x = x} ; - --- These constants are used for data abstraction over the parameter type $Num$. - singular = Sg ; - plural = Pl ; - ---3 Common noun phrases - --- The need for this more complex type comes from the variation in the way in --- which a modifying adjective is inflected after different determiners: --- "(en) ful orm" / "(den) fula ormen" / "(min) fula orm". -param - SpeciesP = IndefP | DefP Species ; - --- We also have to be able to decide if a $CommNounPhrase$ is complex --- (to form the definite form: "bilen" / "den stora bilen"). - -oper - IsComplexCN : Type = Bool ; - --- Coercions between simple $Species$ and $SpeciesP$: - unSpeciesP : SpeciesP -> Species = \b -> - case b of {IndefP => Indef ; DefP p => p} ; -- bil/bil/bilen - unSpeciesAdjP : SpeciesP -> Species = \b -> - case b of {IndefP => Indef ; DefP _ => Def} ; -- gammal/gamla/gamla - --- Here's the type itself. - CommNounPhrase : Type = - {s : Number => SpeciesP => Case => Str ; - g : Gender ; x : Sex ; p : IsComplexCN} ; - --- To use a $CommNoun$ as $CommNounPhrase$. - noun2CommNounPhrase : CommNoun -> CommNounPhrase = \hus -> - {s = \\n,b,c => hus.s ! n ! unSpeciesP b ! c ; - g = hus.g ; x = hus.x ; p = False} ; - - n2n = noun2CommNounPhrase ; - - ---2 Noun Phrases --- --- The worst case for noun phrases is pronouns, which have inflection --- in (what is syntactically) their genitive. Most noun phrases can --- ignore this variation. - -oper - npCase : NPForm -> Case = \c -> case c of {PGen _ => Gen ; _ => Nom} ; - mkNPForm : Case -> NPForm = \c -> case c of {Gen => PGen APl ; _ => PNom} ; - - NounPhrase : Type = {s : NPForm => Str ; g : Gender ; n : Number} ; - --- Proper names are a simple kind of noun phrases. However, we want to --- anticipate the rule that proper names can be modified by --- adjectives, even though noun phrases in general cannot - hence the sex. - - ProperName : Type = {s : Case => Str ; g : Gender ; x : Sex} ; - - mkProperName : Str -> Gender -> Sex -> ProperName = \john,g,x -> - {s = table {Nom => john ; Gen => john + "s"} ; g = g ; x = x} ; - - nameNounPhrase : ProperName -> NounPhrase = - \john -> {s = table {c => john.s ! npCase c} ; g = john.g ; n = Sg} ; - - regNameNounPhrase : Str -> Gender -> Sex -> NounPhrase = \john,g,x -> - nameNounPhrase (mkProperName john g x) ; - - pronNounPhrase : ProPN -> NounPhrase = \jag -> - {s = jag.s ; g = jag.h1 ; n = jag.h2} ; - --- The following construction has to be refined for genitive forms: --- "vi tre", "oss tre" are OK, but "vår tres" is not. - - Numeral : Type = {s : Case => Str} ; - - pronWithNum : ProPN -> Numeral -> ProPN = \we,two -> - {s = \\c => we.s ! c ++ two.s ! npCase c ; - h1 = we.h1 ; - h2 = we.h2 ; - h3 = we.h3 + g = NUtr Masc } ; - noNum : Numeral = {s = \\_ => []} ; + npMan : NounPhrase = nameNounPhrase (mkProperName "man" (NUtr Masc)) ; + npDet : NounPhrase = nameNounPhrase (mkProperName "det" NNeutr) ; --- Formal subjects - npMan = nameNounPhrase (mkProperName "man" Utr Masc) ; - npDet = nameNounPhrase (mkProperName "det" Neutr NoMasc) ; - ---2 Determiners --- --- Determiners are inflected according to noun in gender and sex. --- The number and species of the noun are determined by the determiner. - - Determiner : Type = {s : Gender => Sex => Str ; n : Number ; b : SpeciesP} ; - --- This is the rule for building noun phrases. - - detNounPhrase : Determiner -> CommNounPhrase -> NounPhrase = \en, man -> - {s = table {c => en.s ! man.g ! man.x ++ man.s ! en.n ! en.b ! npCase c} ; - g = man.g ; n = en.n} ; - --- The following macros are sufficient to define most determiners. --- All $SpeciesP$ values come into question: --- "en god vän" - "min gode vän" - "den gode vännen". - - DetSg : Type = Gender => Sex => Str ; - DetPl : Type = Str ; - - mkDeterminerSg : DetSg -> SpeciesP -> Determiner = \en, b -> - {s = en ; n = Sg ; b = b} ; - - mkDeterminerPl : DetPl -> SpeciesP -> Determiner = \alla,b -> - mkDeterminerPlNum alla b noNum ; - - mkDeterminerPlNum : DetPl -> SpeciesP -> Numeral -> Determiner = \alla,b,n -> - {s = \\_,_ => alla ++ n.s ! Nom ; - n = Pl ; - b = b - } ; - - detSgInvar : Str -> DetSg = \varje -> table {_ => table {_ => varje}} ; - --- A large class of determiners can be built from a gender-dependent table. - - mkDeterminerSgGender : (Gender => Str) -> SpeciesP -> Determiner = \en -> - mkDeterminerSg (table {g => table {_ => en ! g}}) ; - - mkDeterminerSgGender2 : Str -> Str -> SpeciesP -> Determiner = \en,ett -> - mkDeterminerSgGender (table {Utr => en ; Neutr => ett}) ; - --- Here are some examples. We are in fact doing some ad hoc morphology here, --- instead of importing the lexicon. - - varjeDet = mkDeterminerSg (detSgInvar "varje") IndefP ; - allaDet = mkDeterminerPl "alla" IndefP ; - enDet = mkDeterminerSgGender artIndef IndefP ; - - flestaDet = mkDeterminerPl ["de flesta"] IndefP ; - vilkenDet = mkDeterminerSgGender - (table {Utr => "vilken" ; Neutr => "vilket"}) IndefP ; - vilkaDet = mkDeterminerPl "vilka" IndefP ; - - vilkDet : Number -> Determiner = \n -> case n of { - Sg => vilkenDet ; - Pl => vilkaDet - } ; - - någDet : Number -> Determiner = \n -> case n of { - Sg => mkDeterminerSgGender - (table {Utr => "någon" ; Neutr => "något"}) IndefP ; - Pl => mkDeterminerPl "några" IndefP - } ; - - --- Genitives of noun phrases can be used like determiners, to build noun phrases. --- The number argument makes the difference between "min bil" - "mina bilar". - - npGenDet : Number -> Numeral -> NounPhrase -> CommNounPhrase -> NounPhrase = - \n,tre,huset,vin -> { - s = \\c => case n of { - Sg => huset.s ! PGen (ASg vin.g) ++ - vin.s ! Sg ! DefP Indef ! npCase c ; - Pl => huset.s ! PGen APl ++ tre.s ! Nom ++ - vin.s ! Pl ! DefP Indef ! npCase c - } ; - g = vin.g ; - n = n - } ; - --- *Bare plural noun phrases* like "män", "goda vänner", are built without a --- determiner word. But a $Numeral$ may occur. - - plurDet : CommNounPhrase -> NounPhrase = plurDetNum noNum ; - - plurDetNum : Numeral -> CommNounPhrase -> NounPhrase = \num,cn -> - {s = \\c => num.s ! Nom ++ cn.s ! Pl ! IndefP ! npCase c ; - g = cn.g ; - n = Pl - } ; - --- Definite phrases in Swedish are special, since determiner may be absent --- depending on if the noun is complex: "bilen" - "den nya bilen". - - denDet : CommNounPhrase -> NounPhrase = \cn -> - detNounPhrase - (mkDeterminerSgGender (table {g => artDef ! cn.p ! ASg g}) (DefP Def)) cn ; - deDet : Numeral -> CommNounPhrase -> NounPhrase = \n,cn -> - detNounPhrase (mkDeterminerPlNum (artDef ! cn.p ! APl) (DefP Def) n) cn ; - --- It is useful to have macros for indefinite and definite, singular and plural --- noun-phrase-like syncategorematic expressions. - - indefNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n -> - indefNounPhraseNum n noNum ; - - indefNounPhraseNum : Number -> Numeral -> CommNounPhrase -> NounPhrase = - \n,num,hus -> - case n of { - Sg => detNounPhrase enDet hus ; - Pl => plurDetNum num hus - } ; - - defNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n -> - defNounPhraseNum n noNum ; - - defNounPhraseNum : Number -> Numeral -> CommNounPhrase -> NounPhrase = - \n,num,hus -> case n of { - Sg => denDet hus ; - Pl => deDet num hus - } ; - - indefNoun : Number -> CommNounPhrase -> Str = \n,man -> case n of { - Sg => artIndef ! man.g ++ man.s ! Sg ! IndefP ! Nom ; - Pl => man.s ! Pl ! IndefP ! Nom - } ; - --- Constructions like "tanken att två är jämnt" are formed at the --- first place as common nouns, so that one can also have "ett förslag att...". - - nounThatSentence : CommNounPhrase -> Sentence -> CommNounPhrase = \tanke,x -> - {s = \\n,d,c => tanke.s ! n ! d ! c ++ "att" ++ x.s ! Sub ; - g = tanke.g ; - x = tanke.x ; - p = tanke.p - } ; - - ---2 Adjectives ---3 Simple adjectives --- --- A special type of adjectives just having positive forms (for semantic reasons) --- is useful, e.g. "finsk", "trekantig". - - Adjective : Type = {s : AdjFormPos => Case => Str} ; - - extAdjective : Adj -> Adjective = \adj -> - {s = table {f => table {c => adj.s ! AF (Posit f) c}}} ; - --- Coercions between the compound gen-num type and gender and number: - - gNum : Gender -> Number -> GenNum = \g,n -> - case n of {Sg => ASg g ; Pl => APl} ; - - genGN : GenNum -> Gender = \gn -> - case gn of {ASg g => g ; _ => Utr} ; - numGN : GenNum -> Number = \gn -> - case gn of {ASg _ => Sg ; APl => Pl} ; - ---3 Adjective phrases --- --- An adjective phrase may contain a complement, e.g. "yngre än Rolf". --- Then it is used as postfix in modification, e.g. "en man yngre än Rolf". - - IsPostfixAdj = Bool ; - - AdjPhrase : Type = Adjective ** {p : IsPostfixAdj} ; - --- Simple adjectives are not postfix: - - adj2adjPhrase : Adjective -> AdjPhrase = \ny -> ny ** {p = False} ; - ---3 Comparison adjectives - --- We take comparison adjectives directly from --- the lexicon, which has full adjectives: - - AdjDegr = Adj ; - --- Each of the comparison forms has a characteristic use: --- --- Positive forms are used alone, as adjectival phrases ("ung"). - - positAdjPhrase : AdjDegr -> AdjPhrase = \ung -> - {s = table {a => \\c => ung.s ! AF (Posit a) c} ; - p = False - } ; - --- Comparative forms are used with an object of comparison, as --- adjectival phrases ("yngre än Rolf"). - - comparAdjPhrase : AdjDegr -> NounPhrase -> AdjPhrase = \yngre,rolf -> - {s = \\_, c => yngre.s ! AF Compar Nom ++ "än" ++ rolf.s ! mkNPForm c ; - p = True - } ; - --- Superlative forms are used with a modified noun, picking out the --- maximal representative of a domain ("den yngste mannen"). - - superlNounPhrase : AdjDegr -> CommNounPhrase -> NounPhrase = \yngst,man -> - {s = \\c => let {gn = gNum man.g Sg} in - artDef ! True ! gn ++ - yngst.s ! AF (Super SupWeak) Nom ++ - man.s ! Sg ! DefP Def ! npCase c ; - g = man.g ; - n = Sg - } ; - --- Moreover, superlatives can be used alone as adjectival phrases --- ("yngst", "den yngste" - in free variation). --- N.B. the former is only permitted in predicative position. - - superlAdjPhrase : AdjDegr -> AdjPhrase = \ung -> - {s = \\a,c => variants { - --- artDef ! True ! gn ++ yngst.s ! AF (Super SupWeak) c - ung.s ! AF (Super SupStrong) c - } ; - p = False - } ; - ---3 Two-place adjectives --- --- A two-place adjective is an adjective with a preposition used before --- the complement. (Rem. $Preposition = Str$). - - AdjCompl = Adjective ** {s2 : Preposition} ; - - complAdj : AdjCompl -> NounPhrase -> AdjPhrase = \förtjust,dig -> - {s = \\a,c => förtjust.s ! a ! c ++ förtjust.s2 ++ dig.s ! PAcc ; - p = True - } ; - - ---3 Modification of common nouns --- --- The two main functions of adjective are in predication ("Johan är ung") --- and in modification ("en ung man"). Predication will be defined --- later, in the chapter on verbs. - - modCommNounPhrase : AdjPhrase -> CommNounPhrase -> CommNounPhrase = \God,Nybil -> - {s = \\n, b, c => - let { - god = God.s ! mkAdjForm (unSpeciesAdjP b) n Nybil.g Nybil.x ! Nom ; - nybil = Nybil.s ! n ! b ! c - } in - preOrPost God.p nybil god ; - g = Nybil.g ; - x = Nybil.x ; - p = True} ; - --- A special case is modification of a noun that has not yet been modified. --- But it is simply a special case. - - modCommNoun : Adjective -> CommNoun -> CommNounPhrase = \god,bil -> - modCommNounPhrase (adj2adjPhrase god) (n2n bil) ; - --- We have used a straightforward --- method building adjective forms from simple parameters. - - mkAdjForm : Species -> Number -> Gender -> Sex -> AdjFormPos = \b,n,g,x -> + mkAdjForm : Species -> Number -> NounGender -> AdjFormPos = \b,n,g -> case of { - => Strong (ASg g) ; + => Strong (ASg (genNoun g)) ; => Strong APl ; - => Weak (AxSg x) ; ---- add masc! + => Weak (AxSg (sexNoun g)) ; => Weak AxPl } ; - ---2 Function expressions - --- A function expression is a common noun together with the --- preposition prefixed to its argument ("mor till x"). --- The type is analogous to two-place adjectives and transitive verbs. - - Function = CommNoun ** {s2 : Preposition} ; - - mkFun : CommNoun -> Preposition -> Function = \f,p -> - f ** {s2 = p} ; - --- The application of a function gives, in the first place, a common noun: --- "mor/mödrar till Johan". From this, other rules of the resource grammar --- give noun phrases, such as "modern till Johan", "mödrarna till Johan", --- "mödrarna till Johan och Maria", and "modern till Johan och Maria" (the --- latter two corresponding to distributive and collective functions, --- respectively). Semantics will eventually tell when each --- of the readings is meaningful. - - appFunComm : Function -> NounPhrase -> CommNounPhrase = \värde,x -> - noun2CommNounPhrase - {s = \\n,b => table { - Gen => nonExist ; - _ => värde.s ! n ! b ! Nom ++ värde.s2 ++ x.s ! PAcc - } ; - g = värde.g ; - x = värde.x - } ; - --- It is possible to use a function word as a common noun; the semantics is --- often existential or indexical. - - funAsCommNounPhrase : Function -> CommNounPhrase = - noun2CommNounPhrase ; - --- The following is an aggregate corresponding to the original function application --- producing "Johans mor" and "modern till Johan". It does not appear in the --- resource grammar API any longer. - - appFun : Bool -> Function -> NounPhrase -> NounPhrase = \coll,värde,x -> - let {n = x.n ; nf = if_then_else Number coll Sg n} in - variants { - defNounPhrase nf (appFunComm värde x) ; - npGenDet nf noNum x (noun2CommNounPhrase värde) - } ; - --- Two-place functions add one argument place. - - Function2 = Function ** {s3 : Preposition} ; - --- Their application starts by filling the first place. - - appFun2 : Function2 -> NounPhrase -> Function = \flyg, paris -> - {s = \\n,d,c => flyg.s ! n ! d ! c ++ flyg.s2 ++ paris.s ! PAcc ; - g = flyg.g ; - x = flyg.x ; - s2 = flyg.s3 - } ; - - ---2 Verbs - --- Although the Swedish lexicon has full verb inflection, --- we have limited this first version of the resource syntax to --- verbs in present tense. Their mode can be infinitive, imperative, and indicative. - - ---3 Verb phrases --- --- Sentence forms are tense-mood combinations used in sentences and --- verb phrases. - -param - Tense = Present | Past ; - Anteriority = Simul | Anter ; - SForm = - VIndic Tense Anteriority - | VFut Anteriority - | VCondit Anteriority - | VImperat - | VInfinit Anteriority ; - -oper - verbSForm : Verbum -> Voice -> SForm -> {fin,inf : Str} = \se,vo,sf -> - let - tense : Tense -> Voice -> VFin = \t,v -> case t of { - Present => Pres Ind v ; - Past => Pret Ind v - } ; - simple : VerbForm -> {fin,inf : Str} = \v -> { - fin = se.s ! v ; - inf = [] - } ; - compound : Str -> Str -> {fin,inf : Str} = \x,y -> { - fin = x ; - inf = y - } ; - see : Voice -> Str = \v -> (se.s ! (VI (Inf v))) ; - sett : Voice -> Str = \v -> (se.s ! (VI (Supin v))) ; - hasett : Voice -> Str = \v -> "ha" ++ sett v - - in case sf of { - VIndic t Simul => simple (VF (tense t vo)) ; - VIndic Present Anter => compound "har" (sett vo) ; - VIndic Past Anter => compound "hade" (sett vo) ; - VFut Simul => compound "ska" (see vo) ; - VFut Anter => compound "ska" (hasett vo) ; - VCondit Simul => compound "skulle" (see vo) ; - VCondit Anter => compound "skulle" (hasett vo) ; - VImperat => simple (VF Imper) ; --- no passive - VInfinit Simul => simple (VI (Inf vo)) ; - VInfinit Anter => compound "ha" (sett vo) - } ; - - useVerb : Verb -> (Gender => Number => Str) -> VerbGroup = \verb,arg -> - let aer = verbSForm verb Act in { - s = \\sf => (aer sf).fin ; - s2 = negation ; - s3 = \\sf,g,n => (aer sf).inf ++ arg ! g ! n - } ; - --- Verb phrases are discontinuous: the parts of a verb phrase are --- (s) an inflected verb, (s2) verb adverbials (such as negation), and --- (s3) complement. This discontinuity is needed in sentence formation --- to account for word order variations. No particle needs to be retained. - - VerbPhrase : Type = { - s : SForm => Str ; - s2 : Str ; - s3 : SForm => Gender => Number => Str - } ; - VerbGroup : Type = { - s : SForm => Str ; - s2 : Bool => Str ; - s3 : SForm => Gender => Number => Str - } ; - - predVerbGroup : Bool -> VerbGroup -> VerbPhrase = \b,vg -> { - s = vg.s ; - s2 = vg.s2 ! b ; - s3 = vg.s3 - } ; - --- A simple verb can be made into a verb phrase with an empty complement. --- There are two versions, depending on if we want to negate the verb. --- N.B. negation is *not* a function applicable to a verb phrase, since --- double negations with "inte" are not grammatical. - - predVerb : Verb -> VerbGroup = \se -> useVerb se (\\_,_ => se.s1) ; - - negation : Bool => Str = \\b => if_then_Str b [] "inte" ; - --- Verb phrases can also be formed from adjectives ("är snäll"), --- common nouns ("är en man"), and noun phrases ("är den yngste mannen"). --- The third rule is overgenerating: "är varje man" has to be ruled out --- on semantic grounds. - - vara : (Gender => Number => Str) -> VerbGroup = - useVerb (verbVara ** {s1 = []}) ; - - predAdjective : Adjective -> VerbGroup = \arg -> - vara (\\g,n => arg.s ! mkAdjForm Indef n g NoMasc ! Nom) ; - - predCommNoun : CommNounPhrase -> VerbGroup = \man -> - vara (\\_,n => indefNoun n man) ; - - predNounPhrase : NounPhrase -> VerbGroup = \john -> - vara (\\_,_ => john.s ! PNom) ; - - predAdverb : Adverb -> VerbGroup = \ute -> - vara (\\_,_ => ute.s) ; - ---3 Transitive verbs --- --- Transitive verbs are verbs with a preposition for the complement, --- in analogy with two-place adjectives and functions. --- One might prefer to use the term "2-place verb", since --- "transitive" traditionally means that the inherent preposition is empty. --- Such a verb is one with a *direct object*. - - TransVerb : Type = Verb ** {s2 : Preposition} ; - - mkTransVerb : Verb -> Preposition -> TransVerb = \v,p -> - v ** {s2 = p} ; - - mkDirectVerb : Verb -> TransVerb = \v -> - mkTransVerb v nullPrep ; - - nullPrep : Preposition = [] ; - - - extTransVerb : Verbum -> Preposition -> TransVerb = \v,p -> - mkTransVerb (v ** {s1 = []}) p ; - - --- The rule for using transitive verbs is the complementization rule: - - complTransVerb : TransVerb -> NounPhrase -> VerbGroup = \se,dig -> - useVerb se (\\_,_ => se.s1 ++ se.s2 ++ dig.s ! PAcc) ; - --- Transitive verbs with accusative objects can be used passively. --- The function does not check that the verb is transitive. --- Therefore, the function can also be used for "han löps", etc. --- The syntax is the same as for active verbs, with the choice of the --- "s" passive form. - - passVerb : Verb -> VerbGroup = \se -> - let ses = verbSForm se Pass in { - s = \\sf => (ses sf).fin ; - s2 = negation ; - s3 = \\sf,g,n => (ses sf).inf ++ se.s1 - } ; - --- Transitive verbs can be used elliptically as verbs. The semantics --- is left to applications. The definition is trivial, due to record --- subtyping. - - transAsVerb : TransVerb -> Verb = \love -> - love ; - --- *Ditransitive verbs* are verbs with three argument places. --- We treat so far only the rule in which the ditransitive --- verb takes both complements to form a verb phrase. - - DitransVerb = TransVerb ** {s3 : Preposition} ; - - mkDitransVerb : Verb -> Preposition -> Preposition -> DitransVerb = \v,p1,p2 -> - v ** {s2 = p1 ; s3 = p2} ; - - complDitransVerb : - DitransVerb -> NounPhrase -> NounPhrase -> VerbGroup = \ge,dig,vin -> - useVerb - ge - (\\_,_ => ge.s1 ++ ge.s2 ++ dig.s ! PAcc ++ ge.s3 ++ vin.s ! PAcc) ; - - ---2 Adverbs --- --- Adverbs that modify verb phrases are either post- or pre-verbal. --- As a rule of thumb, simple adverbs ("bra","alltid") are pre-verbal, --- but this is not always the case ("här" is post-verbal). --- Even prepositional phrases can be both --- ("att han i alla fall skulle komma"). - - Adverb : Type = SS ** {isPost : Bool} ; - PrepPhrase : Type = Adverb ; - - advPre : Str -> Adverb = \alltid -> ss alltid ** {isPost = False} ; - advPost : Str -> Adverb = \bra -> ss bra ** {isPost = True} ; - - adVerbPhrase : VerbPhrase -> Adverb -> VerbPhrase = \spelar, bra -> - let {postp = bra.isPost} in - { - --- this unfortunately generates VP#2 ::= VP#2 - s = spelar.s ; - s2 = (if_then_else Str postp [] bra.s) ++ spelar.s2 ; - s3 = \\sf,g,n => spelar.s3 ! sf ! g ! n ++ (if_then_else Str postp bra.s []) - } ; - - advAdjPhrase : SS -> AdjPhrase -> AdjPhrase = \mycket, dyr -> - {s = \\a,c => mycket.s ++ dyr.s ! a ! c ; - p = dyr.p - } ; - --- Adverbials are typically generated by prefixing prepositions. --- The rule for creating locative noun phrases by the preposition "i" --- is a little shaky: "i Sverige" but "på Island". - - prepPhrase : Preposition -> NounPhrase -> Adverb = \i,huset -> - advPost (i ++ huset.s ! PAcc) ; - - locativeNounPhrase : NounPhrase -> Adverb = - prepPhrase "i" ; - --- This is a source of the "mannen med teleskopen" ambiguity, and may produce --- strange things, like "bilar alltid" (while "bilar idag" is OK). --- Semantics will have to make finer distinctions among adverbials. - - advCommNounPhrase : CommNounPhrase -> PrepPhrase -> CommNounPhrase = \bil,idag -> - {s = \\n, b, c => bil.s ! n ! b ! c ++ idag.s ; - g = bil.g ; - x = bil.x ; - p = bil.p} ; - - ---2 Sentences --- --- Sentences depend on a *word order parameter* selecting between main clause, --- inverted, and subordinate clause. - -param - Order = Main | Inv | Sub ; - -oper - Sentence : Type = SS1 Order ; - --- This is the traditional $S -> NP VP$ rule. It takes care of both --- word order and agreement. - - predVerbPhrase : NounPhrase -> VerbPhrase -> Sentence = - \Jag, serdiginte -> - let { - jag = Jag.s ! PNom ; - t = VIndic Present Simul ; ---- to be made parameter of S - ser = serdiginte.s ! t ; - dig = serdiginte.s3 ! t ! Jag.g ! Jag.n ; - inte = serdiginte.s2 - } in - {s = table { - Main => jag ++ ser ++ inte ++ dig ; - Inv => ser ++ jag ++ inte ++ dig ; - Sub => jag ++ inte ++ ser ++ dig - } - } ; - -param - ClForm = - ClIndic Tense Anteriority Order - | ClFut Anteriority Order - | ClCondit Anteriority Order - | ClInfinit Anteriority -- "naked infinitive" clauses - ; - -oper cl2s : ClForm -> {o : Order ; sf : SForm} = \c -> case c of { - ClIndic t a o => {o = o ; sf = VIndic t a} ; - ClFut a o => {o = o ; sf = VFut a} ; - ClCondit a o => {o = o ; sf = VCondit a} ; - ClInfinit a => {o = Sub ; sf = VInfinit a} -- "jag såg John inte hälsa" - } ; - - Clause = {s : Bool => ClForm => Str} ; - - predVerbGroupClause : NounPhrase -> VerbGroup -> Clause = - \Jag, serdiginte -> { - s = \\b,c => let { - jag = Jag.s ! (case c of {ClInfinit _ => PAcc ; _ => PNom}) ; - osf = cl2s c ; - t = osf.sf ; - o = osf.o ; - ser = serdiginte.s ! t ; - dig = serdiginte.s3 ! t ! Jag.g ! Jag.n ; - inte = serdiginte.s2 ! b - } in - case o of { - Main => jag ++ ser ++ inte ++ dig ; - Inv => ser ++ jag ++ inte ++ dig ; - Sub => jag ++ inte ++ ser ++ dig - } - } ; - - ---3 Sentence-complement verbs --- --- Sentence-complement verbs take sentences as complements. - - SentenceVerb : Type = Verb ; - - complSentVerb : SentenceVerb -> Sentence -> VerbGroup = \se,duler -> - useVerb se (\\_,_ => se.s1 ++ optStr "att" ++ duler.s ! Main) ; - ---3 Verb-complement verbs --- --- Verb-complement verbs take verb phrases as complements. --- They can be auxiliaries ("kan", "måste") or ordinary verbs --- ("försöka"); this distinction cannot be done in the multilingual --- API and leads to some anomalies in Swedish, but less so than in English. - - VerbVerb : Type = Verb ** {isAux : Bool} ; - - complVerbVerb : VerbVerb -> VerbGroup -> VerbGroup = \vilja, simma -> - useVerb vilja - (\\g,n => - vilja.s1 ++ - if_then_Str vilja.isAux [] "att" ++ - simma.s ! VInfinit Simul ++ simma.s2 ! True ++ ---- Anter! - simma.s3 ! VInfinit Simul ! g ! n) ; - - ---2 Sentences missing noun phrases --- --- This is one instance of Gazdar's *slash categories*, corresponding to his --- $S/NP$. --- We cannot have - nor would we want to have - a productive slash-category former. --- Perhaps a handful more will be needed. --- --- Notice that the slash category has the same relation to sentences as --- transitive verbs have to verbs: it's like a *sentence taking a complement*. - - SentenceSlashNounPhrase : Type = Sentence ** {s2 : Preposition} ; - - slashTransVerb : Bool -> NounPhrase -> TransVerb -> SentenceSlashNounPhrase = - \b, Jag, se -> - let { - jag = Jag.s ! PNom ; - ser = se.s ! VF (Pres Ind Act) ; ---- other tenses - inte = negation ! b ++ se.s1 - } in - {s = table { - Main => jag ++ ser ++ inte ; - Inv => ser ++ jag ++ inte ; - Sub => jag ++ inte ++ ser - } ; - s2 = se.s2 - } ; - - ---2 Relative pronouns and relative clauses --- --- Relative pronouns can be nominative, accusative, or genitive, and --- they depend on gender and number just like adjectives. --- Moreover they may or may not carry their own genders: for instance, --- "som" just transmits the gender of a noun ("tal som är primt"), whereas --- "vars efterföljare" is $Utrum$ independently of the noun --- ("tal vars efterföljare är prim"). --- This variation is expressed by the $RelGender$ type. - - RelPron : Type = {s : RelCase => GenNum => Str ; g : RelGender} ; - -param - RelGender = RNoGen | RG Gender ; - --- The following functions are selectors for relative-specific parameters. - -oper - -- this will be needed in "tal som är jämnt" / "tal vars efterföljare är jämn" - mkGenderRel : RelGender -> Gender -> Gender = \rg,g -> case rg of { - RG gen => gen ; - _ => g - } ; - - relCase : RelCase -> Case = \c -> case c of { - RGen => Gen ; - _ => Nom - } ; - --- The simplest relative pronoun has no gender of its own. As accusative variant, --- it has the omission of the pronoun ("mannen (som) jag ser"). - - identRelPron : RelPron = - {s = table { - RNom => \\_ => "som" ; - RAcc => \\_ => variants {"som" ; []} ; - RGen => \\_ => "vars" ; - RPrep => pronVilken - } ; - g = RNoGen - } ; - --- Composite relative pronouns have the same variation as function --- applications ("efterföljaren till vilket" - "vars efterföljare"). - - funRelPron : Function -> RelPron -> RelPron = \värde,vilken -> - {s = \\c,gn => - variants { - vilken.s ! RGen ! gn ++ värde.s ! numGN gn ! Indef ! relCase c ; - värde.s ! numGN gn ! Def ! Nom ++ värde.s2 ++ vilken.s ! RPrep ! gn - } ; - g = RG värde.g - } ; - --- Relative clauses can be formed from both verb phrases ("som sover") and --- slash expressions ("som jag ser"). The latter has moreover the variation --- as for the place of the preposition ("som jag talar om" - "om vilken jag talar"). - - RelClause : Type = {s : GenNum => Str} ; - - relVerbPhrase : RelPron -> VerbPhrase -> RelClause = \som,sover -> - {s = \\gn => - som.s ! RNom ! gn ++ sover.s2 ++ sover.s ! VIndic Present Simul - ---- Past and Anter ! - ++ - sover.s3 ! VIndic Present Simul ! mkGenderRel som.g (genGN gn) ! numGN gn - } ; - - relSlash : RelPron -> SentenceSlashNounPhrase -> RelClause = \som,jagTalar -> - {s = \\gn => - let {jagtalar = jagTalar.s ! Sub ; om = jagTalar.s2} in - variants { - som.s ! RAcc ! gn ++ jagtalar ++ om ; - om ++ som.s ! RPrep ! gn ++ jagtalar - } - } ; - --- A 'degenerate' relative clause is the one often used in mathematics, e.g. --- "tal x sådant att x är primt". - - relSuch : Sentence -> RelClause = \A -> - {s = \\g => pronSådan ! g ++ "att" ++ A.s ! Sub} ; - --- The main use of relative clauses is to modify common nouns. --- The result is a common noun, out of which noun phrases can be formed --- by determiners. - - modRelClause : CommNounPhrase -> RelClause -> CommNounPhrase = \man,somsover -> - {s = \\n,b,c => man.s ! n ! b ! c ++ somsover.s ! gNum man.g n ; - g = man.g ; - x = man.x ; - p = False - } ; - --- N.B. we do not get the determinative pronoun --- construction "den man som sover" in this way, but only "mannen som sover". --- Thus we need an extra rule: - - detRelClause : Number -> CommNounPhrase -> RelClause -> NounPhrase = - \n,man,somsover -> - {s = \\c => let {gn = gNum man.g n} in - artDef ! True ! gn ++ - man.s ! n ! DefP Indef ! npCase c ++ somsover.s ! gn ; - g = man.g ; - n = n - } ; - - ---2 Interrogative pronouns --- --- If relative pronouns are adjective-like, interrogative pronouns are --- noun-phrase-like. Actually we can use the very same type! - - IntPron : Type = NounPhrase ; - --- In analogy with relative pronouns, we have a rule for applying a function --- to a relative pronoun to create a new one. We can reuse the rule applying --- functions to noun phrases! - - funIntPron : Function -> IntPron -> IntPron = - appFun False ; - --- There is a variety of simple interrogative pronouns: --- "vilken bil", "vem", "vad". - - nounIntPron : Number -> CommNounPhrase -> IntPron = \n -> - detNounPhrase (vilkDet n) ; - - intPronWho : Number -> IntPron = \num -> { + deponentVerb : Verb -> Verb = \finna -> { s = table { - PGen _ => "vems" ; - _ => "vem" + VF (Pres m _) => finna.s ! VF (Pres m Pass) ; + VF (Pret m _) => finna.s ! VF (Pret m Pass) ; + VI (Inf _) => finna.s ! VI (Inf Pass) ; + VI (Supin _) => finna.s ! VI (Supin Pass) ; + v => finna.s ! v --- Imper ! } ; - g = Utr ; - n = num - } ; + s1 = finna.s1 + } ; - intPronWhat : Number -> IntPron = \num -> { - s = table { - PGen _ => nonExist ; --- - _ => "vad" - } ; - n = num ; - g = Neutr - } ; + verbVara = vara_1200 ** {s1 = []} ; + verbHava = hava_1198 ** {s1 = []}; ---2 Utterances + verbFinnas : Verb = deponentVerb (vFinna "finn" "fann" "funn" ** {s1 = []}) ; --- By utterances we mean whole phrases, such as --- 'can be used as moves in a language game': indicatives, questions, imperative, --- and one-word utterances. The rules are far from complete. --- --- N.B. we have not included rules for texts, which we find we cannot say much --- about on this level. In semantically rich GF grammars, texts, dialogues, etc, --- will of course play an important role as categories not reducible to utterances. --- An example is proof texts, whose semantics show a dependence between premises --- and conclusions. Another example is intersentential anaphora. - - Utterance = SS ; + relPronForms : RelCase => GenNum => Str = table { + RNom => \\_ => "som" ; + RAcc => \\_ => variants {"som" ; []} ; + RGen => \\_ => "vars" ; + RPrep => pronVilken + } ; - indicUtt : Sentence -> Utterance = \x -> postfixSS "." (defaultSentence x) ; - interrogUtt : Question -> Utterance = \x -> postfixSS "?" (defaultQuestion x) ; + pronVilken = table { + ASg Utr => "vilken" ; + ASg Neutr => "vilket" ; + APl => "vilka" + } ; + pronSådan = table { + ASg Utr => "sådan" ; + ASg Neutr => "sådant" ; + APl => "sådana" + } ; ---2 Questions --- --- Questions are either direct ("vem tog bollen") or indirect --- ("vem som tog bollen"). + pronNågon = table { + ASg Utr => "någon" ; + ASg Neutr => "något" ; + APl => "några" + } ; -param - QuestForm = DirQ | IndirQ ; + specDefPhrase : Bool -> Species = \b -> + Def ; -oper - Question = SS1 QuestForm ; + superlSpecies = Def ; ---3 Yes-no questions --- --- Yes-no questions are used both independently ("tog du bollen") --- and after interrogative adverbials ("varför tog du bollen"). --- It is economical to handle with these two cases by the one --- rule, $questVerbPhrase'$. The only difference is if "om" appears --- in the indirect form. + artIndef = table {Utr => "en" ; Neutr => "ett"} ; - questVerbPhrase : NounPhrase -> VerbPhrase -> Question = - questVerbPhrase' False ; - - questVerbPhrase' : Bool -> NounPhrase -> VerbPhrase -> Question = - \adv,du,sover -> - let {dusover = (predVerbPhrase du sover).s} in - {s = table { - DirQ => dusover ! Inv ; - IndirQ => (if_then_else Str adv [] "om") ++ dusover ! Sub - } + artDef : Bool => GenNum => Str = table { + True => table { + ASg Utr => "den" ; + ASg Neutr => "det" ; -- det gamla huset + APl => variants {"de" ; "dom"} + } ; + False => table {_ => []} -- huset } ; ---3 Wh-questions --- --- Wh-questions are of two kinds: ones that are like $NP - VP$ sentences, --- others that are line $S/NP - NP$ sentences. + auxHar = "har" ; + auxHade = "hade" ; + auxHa = "ha" ; + auxSka = "ska" ; + auxSkulle = "skulle" ; - intVerbPhrase : IntPron -> VerbPhrase -> Question = \vem,sover -> - let {vemsom : NounPhrase = - {s = \\c => vem.s ! c ++ "som" ; g = vem.g ; n = vem.n} - } in - {s = table { - DirQ => (predVerbPhrase vem sover).s ! Main ; - IndirQ => (predVerbPhrase vemsom sover).s ! Sub - } - } ; + infinAtt = "att" ; - intSlash : IntPron -> SentenceSlashNounPhrase -> Question = \Vem, jagTalar -> - let { - vem = Vem.s ! PAcc ; - jagtalar = jagTalar.s ! Sub ; - talarjag = jagTalar.s ! Inv ; - om = jagTalar.s2 - } in - {s = table { - DirQ => variants { - vem ++ talarjag ++ om ; - om ++ vem ++ talarjag - } ; - IndirQ => variants { - vem ++ jagtalar ++ om ; - om ++ vem ++ jagtalar - } - } - } ; + varjeDet : Determiner = mkDeterminerSg (detSgInvar "varje") IndefP ; + allaDet : Determiner = mkDeterminerPl "alla" IndefP ; + flestaDet : Determiner = mkDeterminerPl ["de flesta"] IndefP ; ---3 Interrogative adverbials --- --- These adverbials will be defined in the lexicon: they include --- "när", "var", "hur", "varför", etc, which are all invariant one-word --- expressions. In addition, they can be formed by adding prepositions --- to interrogative pronouns, in the same way as adverbials are formed --- from noun phrases. N.B. we rely on record subtyping when ignoring the --- position component. + prepÄn = "än" ; + negInte = "inte" ; - IntAdverb = SS ; + conjOm = "om" ; - prepIntAdverb : Preposition -> IntPron -> IntAdverb = - prepPhrase ; + pronVars = "vars" ; + pronVem = "vem" ; + pronVems = "vems" ; + pronVad = "vad" ; --- A question adverbial can be applied to anything, and whether this makes --- sense is a semantic question. - - questAdverbial : IntAdverb -> NounPhrase -> VerbPhrase -> Question = - \hur, du, mår -> - {s = \\q => hur.s ++ (questVerbPhrase' True du mår).s ! q} ; - - ---2 Imperatives --- --- We only consider second-person imperatives. - - Imperative = SS1 Number ; - - imperVerbPhrase : VerbPhrase -> Imperative = \titta -> - {s = \\n => titta.s ! VImperat ++ titta.s2 ++ titta.s3 ! VImperat ! Utr ! n} ; - - imperUtterance : Number -> Imperative -> Utterance = \n,I -> - ss (I.s ! n ++ "!") ; - ---2 Sentence adverbials --- --- This class covers adverbials such as "annars", "därför", which are prefixed --- to a sentence to form a phrase. - - advSentence : SS -> Sentence -> Utterance = \annars,soverhan -> - ss (annars.s ++ soverhan.s ! Inv ++ ".") ; - - ---2 Coordination --- --- Coordination is to some extent orthogonal to the rest of syntax, and --- has been treated in a generic way in the module $CO$ in the file --- $coordination.gf$. The overall structure is independent of category, --- but there can be differences in parameter dependencies. --- ---3 Conjunctions --- --- Coordinated phrases are built by using conjunctions, which are either --- simple ("och", "eller") or distributed ("både - och", "antingen - eller"). --- --- The conjunction has an inherent number, which is used when conjoining --- noun phrases: "John och Mary är rika" vs. "John eller Mary är rik"; in the --- case of "eller", the result is however plural if any of the disjuncts is. - - Conjunction = CO.Conjunction ** {n : Number} ; - ConjunctionDistr = CO.ConjunctionDistr ** {n : Number} ; - - ---3 Coordinating sentences --- --- We need a category of lists of sentences. It is a discontinuous --- category, the parts corresponding to 'init' and 'last' segments --- (rather than 'head' and 'tail', because we have to keep track of the slot between --- the last two elements of the list). A list has at least two elements. - - ListSentence : Type = {s1,s2 : Order => Str} ; - - twoSentence : (_,_ : Sentence) -> ListSentence = - CO.twoTable Order ; - - consSentence : ListSentence -> Sentence -> ListSentence = - CO.consTable Order CO.comma ; - --- To coordinate a list of sentences by a simple conjunction, we place --- it between the last two elements; commas are put in the other slots, --- e.g. "månen lyser, solen skiner och stjärnorna blinkar". - - conjunctSentence : Conjunction -> ListSentence -> Sentence = - CO.conjunctTable Order ; - - conjunctOrd : Bool -> Conjunction -> CO.ListTable Order -> {s : Order => Str} = - \b,or,xs -> - {s = \\p => xs.s1 ! p ++ or.s ++ xs.s2 ! p} ; - - --- To coordinate a list of sentences by a distributed conjunction, we place --- the first part (e.g. "antingen") in front of the first element, the second --- part ("eller") between the last two elements, and commas in the other slots. --- For sentences this is really not used. - - conjunctDistrSentence : ConjunctionDistr -> ListSentence -> Sentence = - CO.conjunctDistrTable Order ; - ---3 Coordinating adjective phrases --- --- The structure is the same as for sentences. The result is a prefix adjective --- if and only if all elements are prefix. - - ListAdjPhrase : Type = - {s1,s2 : AdjFormPos => Case => Str ; p : Bool} ; - - twoAdjPhrase : (_,_ : AdjPhrase) -> ListAdjPhrase = \x,y -> - CO.twoTable2 AdjFormPos Case x y ** {p = andB x.p y.p} ; - consAdjPhrase : ListAdjPhrase -> AdjPhrase -> ListAdjPhrase = \xs,x -> - CO.consTable2 AdjFormPos Case CO.comma xs x ** {p = andB xs.p x.p} ; - - conjunctAdjPhrase : Conjunction -> ListAdjPhrase -> AdjPhrase = \c,xs -> - CO.conjunctTable2 AdjFormPos Case c xs ** {p = xs.p} ; - - conjunctDistrAdjPhrase : ConjunctionDistr -> ListAdjPhrase -> AdjPhrase = \c,xs -> - CO.conjunctDistrTable2 AdjFormPos Case c xs ** {p = xs.p} ; - - ---3 Coordinating noun phrases --- --- The structure is the same as for sentences. The result is either always plural --- or plural if any of the components is, depending on the conjunction. --- The gender is neuter if any of the components is. - - ListNounPhrase : Type = {s1,s2 : NPForm => Str ; g : Gender ; n : Number} ; - - twoNounPhrase : (_,_ : NounPhrase) -> ListNounPhrase = \x,y -> - CO.twoTable NPForm x y ** {n = conjNumber x.n y.n ; g = conjGender x.g y.g} ; - - consNounPhrase : ListNounPhrase -> NounPhrase -> ListNounPhrase = \xs,x -> - CO.consTable NPForm CO.comma xs x ** - {n = conjNumber xs.n x.n ; g = conjGender xs.g x.g} ; - - conjunctNounPhrase : Conjunction -> ListNounPhrase -> NounPhrase = \c,xs -> - CO.conjunctTable NPForm c xs ** {n = conjNumber c.n xs.n ; g = xs.g} ; - - conjunctDistrNounPhrase : ConjunctionDistr -> ListNounPhrase -> NounPhrase = - \c,xs -> - CO.conjunctDistrTable NPForm c xs ** {n = conjNumber c.n xs.n ; g = xs.g} ; - --- We hve to define a calculus of numbers of genders. For numbers, --- it is like the conjunction with $Pl$ corresponding to $False$. For genders, --- $Neutr$ corresponds to $False$. - - conjNumber : Number -> Number -> Number = \m,n -> case of { - => Sg ; - _ => Pl - } ; - - conjGender : Gender -> Gender -> Gender = \m,n -> case of { - => Utr ; - _ => Neutr - } ; - - ---2 Subjunction --- --- Subjunctions ("om", "när", etc) --- are a different way to combine sentences than conjunctions. --- The main clause can be a sentences, an imperatives, or a question, --- but the subjoined clause must be a sentence. --- --- There are uniformly two variant word orders, e.g. "om du sover kommer björnen" --- and "björnen kommer om du sover". - - Subjunction = SS ; - - subjunctSentence : Subjunction -> Sentence -> Sentence -> Sentence = \if, A, B -> - let {As = A.s ! Sub} in - {s = table { - Main => variants {if.s ++ As ++ "," ++ B.s ! Inv ; - B.s ! Main ++ "," ++ if.s ++ As} ; - o => B.s ! o ++ "," ++ if.s ++ As - } - } ; - - subjunctImperative : Subjunction -> Sentence -> Imperative -> Imperative = - \if, A, B -> - {s = \\n => subjunctVariants if A (B.s ! n)} ; - - subjunctQuestion : Subjunction -> Sentence -> Question -> Question = \if, A, B -> - {s = \\q => subjunctVariants if A (B.s ! q)} ; - - subjunctVariants : Subjunction -> Sentence -> Str -> Str = \if,A,B -> - let {As = A.s ! Sub} in - variants {if.s ++ As ++ "," ++ B ; B ++ "," ++ if.s ++ As} ; - - subjunctVerbPhrase : VerbPhrase -> Subjunction -> Sentence -> VerbPhrase = - \V, if, A -> - adVerbPhrase V (advPost (if.s ++ A.s ! Sub)) ; - ---2 One-word utterances --- --- An utterance can consist of one phrase of almost any category, --- the limiting case being one-word utterances. These --- utterances are often (but not always) in what can be called the --- default form of a category, e.g. the nominative. --- This list is far from exhaustive. - - useNounPhrase : NounPhrase -> Utterance = \john -> - postfixSS "." (defaultNounPhrase john) ; - useCommonNounPhrase : Number -> CommNounPhrase -> Utterance = \n,car -> - useNounPhrase (indefNounPhrase n car) ; - --- Here are some default forms. - - defaultNounPhrase : NounPhrase -> SS = \john -> - ss (john.s ! PNom) ; - - defaultQuestion : Question -> SS = \whoareyou -> - ss (whoareyou.s ! DirQ) ; - - defaultSentence : Sentence -> Utterance = \x -> ss (x.s ! Main) ; -} ; +} diff --git a/lib/resource/swedish/TestResourceSwe.gf b/lib/resource/swedish/TestResourceSwe.gf index 9d8ec6acb..2a14525dc 100644 --- a/lib/resource/swedish/TestResourceSwe.gf +++ b/lib/resource/swedish/TestResourceSwe.gf @@ -1,4 +1,4 @@ ---# -path=.:../abstract:../../prelude +--# -path=.:../scandinavian:../abstract:../../prelude concrete TestResourceSwe of TestResource = RulesSwe, StructuralSwe ** open MorphoSwe, SyntaxSwe in { @@ -15,14 +15,14 @@ lin Finnish = extAdjective (aFin "finsk") ; Happy = aFin "lycklig" ; Married = extAdjective (aAbstrakt "gift") ** {s2 = "med"} ; - Man = extCommNoun Masc man_1144 ; - Bar = extCommNoun NoMasc (sSak "bar") ; - Bottle = extCommNoun NoMasc (sApa "flask") ; - Woman = extCommNoun NoMasc (sApa "kvinn") ; - Car = extCommNoun NoMasc (sBil "bil") ; - House = extCommNoun NoMasc (sHus "hus") ; - Light = extCommNoun NoMasc (sHus "ljus") ; - Wine = extCommNoun NoMasc (sParti "vin") ; + Man = extCommNounMasc man_1144 ; + Bar = extCommNoun (sSak "bar") ; + Bottle = extCommNoun (sApa "flask") ; + Woman = extCommNoun (sApa "kvinn") ; + Car = extCommNoun (sBil "bil") ; + House = extCommNoun (sHus "hus") ; + Light = extCommNoun (sHus "ljus") ; + Wine = extCommNoun (sParti "vin") ; Walk = vNopart gå_1174 ; Run = vNopart (vFinna "spring" "sprang" "sprung") ; Drink = extTransVerb (vFinna "drick" "drack" "druck") [] ; @@ -38,14 +38,14 @@ lin SwitchOn = mkDirectVerb (vFinna "sätt" "satte" "satt" ** {s1 = "på"}) ; SwitchOff = mkDirectVerb (vLeka "stäng" ** {s1 = "av"}) ; - Mother = mkFun (extCommNoun NoMasc mor_1) "till" ; - Uncle = mkFun (extCommNoun Masc farbror_8) "till" ; - Connection = mkFun (extCommNoun NoMasc (sVarelse "förbindelse")) "från" ** + Mother = mkFun (extCommNoun mor_1) "till" ; + Uncle = mkFun (extCommNounMasc farbror_8) "till" ; + Connection = mkFun (extCommNoun (sVarelse "förbindelse")) "från" ** {s3 = "till"} ; Always = advPre "alltid" ; Well = advPost "bra" ; - John = mkProperName "Johan" Utr Masc ; - Mary = mkProperName "Maria" Utr NoMasc ; + John = mkProperName "Johan" (NUtr Masc) ; + Mary = mkProperName "Maria" (NUtr NoMasc) ; } ; diff --git a/lib/resource/swedish/TypesSwe.gf b/lib/resource/swedish/TypesSwe.gf index d47049b4b..cd9d2f9a2 100644 --- a/lib/resource/swedish/TypesSwe.gf +++ b/lib/resource/swedish/TypesSwe.gf @@ -1,88 +1,25 @@ --1 Swedish Word Classes and Morphological Parameters -- -- This is a resource module for Swedish morphology, defining the --- morphological parameters and word classes of Swedish. It is aimed --- to be complete w.r.t. the description of word forms. --- However, it does not include those parameters that are not needed for +-- morphological parameters and word classes of Italian. +-- The morphology is so far only +-- complete w.r.t. the syntax part of the resource grammar. +-- It does not include those parameters that are not needed for -- analysing individual words: such parameters are defined in syntax modules. --- --- This GF grammar was obtained from the functional morphology file TypesSw.hs --- semi-automatically. The GF inflection engine obtained was obtained automatically. -resource TypesSwe = open Prelude in { - --- - ---2 Enumerated parameter types --- --- These types are the ones found in school grammars. --- Their parameter values are atomic. +instance TypesSwe of TypesScand = { param - Gender = Utr | Neutr ; - Number = Sg | Pl ; - Species = Indef | Def ; - Case = Nom | Gen ; - Sex = NoMasc | Masc ; - Mode = Ind | Cnj ; - Voice = Act | Pass ; - Degree = Pos | Comp | Sup ; - Person = P1 | P2 | P3 ; + NounGender = NUtr Sex | NNeutr ; ---2 Word classes and hierarchical parameter types --- --- Real parameter types (i.e. ones on which words and phrases depend) --- are mostly hierarchical. The alternative would be cross-products of --- simple parameters, but this would usually overgenerate. --- - ---3 Substantives --- --- Substantives (= common nouns) have a parameter of type SubstForm. - -param SubstForm = SF Number Species Case ; - --- Substantives moreover have an inherent gender. - -oper Subst : Type = {s : SubstForm => Str ; h1 : Gender} ; - ---3 Adjectives --- --- Adjectives are a very complex class, and the full table has as many as --- 18 different forms. The major division is between the comparison degrees; --- the comparative has only the 2 case forms, whereas the positive has 12 forms. +oper + genNoun = \s -> case s of {NUtr _ => Utr ; NNeutr => Neutr} ; + sexNoun = \s -> case s of {NUtr x => x ; NNeutr => NoMasc} ; + gen2nounGen = \s -> case s of {Utr => NUtr NoMasc ; Neutr => NNeutr} ; param - AdjForm = AF AdjFormGrad Case ; - --- The positive strong forms depend on gender: "en stor bil" - "ett stort hus". --- But the weak forms depend on sex: "den stora bilen" - "den store mannen". --- The plural never makes a gender-sex distinction. - - GenNum = ASg Gender | APl ; - SexNum = AxSg Sex | AxPl ; - AdjFormPos = Strong GenNum | Weak SexNum ; - AdjFormSup = SupStrong | SupWeak ; - AdjFormGrad = - Posit AdjFormPos - | Compar - | Super AdjFormSup ; - -oper - Adj : Type = {s : AdjForm => Str} ; - - adverbForm : AdjFormPos = Strong (ASg Neutr) ; - ---3 Verbs --- --- Verbs have 9 finite forms and as many as 18 infinite forms; the large number --- of the latter comes from adjectives. - -oper Verbum : Type = {s : VerbForm => Str} ; - -param VFin = Pres Mode Voice | Pret Mode Voice @@ -93,73 +30,4 @@ param | Supin Voice | PtPres Case | PtPret AdjFormPos Case ; - - VerbForm = - VF VFin - | VI VInf ; - --- However, the syntax only needs a simplified verb category, with --- present tense only. Such a verb can be extracted from the full verb, --- and a choice can be made between an active and a passive (deponent) verb. --- Active verbs continue to have passive forms. But we add an extra field $s1$ --- for a verb particle, as e.g. in "se upp". - -param - VMode = Infinit | Indicat | Imperat ; - VForm = VPres VMode Voice ; - -oper - Verb : Type = {s : VerbForm => Str ; s1 : Str} ; - - vNopart : Verbum -> Verb = \v -> v ** {s1 = []} ; - -{- deprecated - extVerbPart : Voice -> Verbum -> Str -> Verb = \v,verb,upp -> {s = table { - VPres Infinit v => verb.s ! VI (Inf v) ; - VPres Indicat v => verb.s ! VF (Pres Ind v) ; - VPres Imperat Act => verb.s ! VF Imper ; - VPres Imperat Pass => verb.s ! VF (Pres Ind Pass) --- no passive in Verbum - } ; - s1 = upp - } ; - - extVerb : Voice -> Verbum -> Verb = \v,verb -> - extVerbPart v verb [] ; --} - ---3 Other open classes --- --- Proper names, adverbs (Adv having comparison forms and AdvIn not having them), --- and interjections are the remaining open classes. - -oper - PNm : Type = {s : Case => Str ; h1 : Gender} ; - Adv : Type = {s : Degree => Str} ; - AdvInv : Type = {s : Str} ; - Interj : Type = {s : Str} ; - ---3 Closed classes --- --- The rest of the Swedish word classes are closed, i.e. not extensible by new --- lexical entries. Thus we don't have to know how to build them, but only --- how to use them, i.e. which parameters they have. --- --- The most important distinction is between proper-name-like pronouns and --- adjective-like pronouns, which are inflected in completely different parameters. - -param - NPForm = PNom | PAcc | PGen GenNum ; - AdjPronForm = APron GenNum Case ; - AuxVerbForm = AuxInf | AuxPres | AuxPret | AuxSup ; - -oper - ProPN : Type = {s : NPForm => Str ; h1 : Gender ; h2 : Number ; h3 : Person} ; - ProAdj : Type = {s : AdjPronForm => Str} ; - Prep : Type = {s : Str} ; - Conjunct : Type = {s : Str} ; - Subjunct : Type = {s : Str} ; - Art : Type = {s : GenNum => Str} ; - Part : Type = {s : Str} ; - Infin : Type = {s : Str} ; - VAux : Type = {s : AuxVerbForm => Str} ; }