From 259eb4c86688db70b0beb76721e7df79164d4e5e Mon Sep 17 00:00:00 2001 From: aarne Date: Thu, 20 Nov 2003 15:53:22 +0000 Subject: [PATCH] Resource with extended API --- grammars/database/DatabaseEng.gf | 6 +- grammars/resource/nabstract/Combinations.gf | 29 ++-- grammars/resource/nabstract/Structural.gf | 23 ++- grammars/resource/nabstract/TestResource.gf | 6 +- grammars/resource/nabstract/additions.txt | 136 ++++++++++------- grammars/resource/nenglish/CombinationsEng.gf | 31 ++-- grammars/resource/nenglish/MorphoEng.gf | 59 +++++-- grammars/resource/nenglish/ParadigmsEng.gf | 11 +- grammars/resource/nenglish/StructuralEng.gf | 31 ++-- grammars/resource/nenglish/SyntaxEng.gf | 144 +++++++++++++----- grammars/resource/nenglish/TestResourceEng.gf | 13 +- grammars/resource/nenglish/TypesEng.gf | 9 +- grammars/resource/swedish/MorphoSwe.gf | 1 + grammars/resource/swedish/SyntaxSwe.gf | 80 +++++++--- grammars/resource/swedish/TypesSwe.gf | 2 + 15 files changed, 404 insertions(+), 177 deletions(-) diff --git a/grammars/database/DatabaseEng.gf b/grammars/database/DatabaseEng.gf index 9abc21879..d8d232e00 100644 --- a/grammars/database/DatabaseEng.gf +++ b/grammars/database/DatabaseEng.gf @@ -35,9 +35,9 @@ lin Individual = UsePN ; - AllN = DetNP AllDet ; - MostN = DetNP MostDet ; + AllN = DetNP (AllsDet NoNum) ; + MostN = DetNP MostsDet ; EveryN = DetNP EveryDet ; - Any = DetNP AnysDet ; + Any = DetNP (AnysDet NoNum) ; } ; diff --git a/grammars/resource/nabstract/Combinations.gf b/grammars/resource/nabstract/Combinations.gf index e97a507ba..1679bbd0e 100644 --- a/grammars/resource/nabstract/Combinations.gf +++ b/grammars/resource/nabstract/Combinations.gf @@ -48,6 +48,7 @@ cat Det ; -- determiner, e.g. "every", "all" Fun ; -- function word, e.g. "mother (of)" Fun2 ; -- two-place function, e.g. "flight (from) (to)" + Num ; -- numeral, e.g. "three", "879" --3 Adjectives and adjectival phrases -- @@ -64,6 +65,7 @@ cat TV ; -- two-place verb, e.g. "love", "wait (for)", "switch on" V3 ; -- three-place verb, e.g. "give", "prefer (stg) (to stg)" VS ; -- sentence-compl. verb, e.g. "say", "prove" +--- VV ; -- verb-compl. verb, e.g. "can", "want" VP ; -- verb phrase, e.g. "switch the light on" --3 Adverbials @@ -124,16 +126,19 @@ fun ModAdj : AP -> CN -> CN ; -- "red car" DetNP : Det -> CN -> NP ; -- "every car" MassNP : CN -> NP ; -- "wine" - IntNP : Int -> CN -> NP ; -- "86 houses" --- assumes i > 1 - DefIntNP : Int -> CN -> NP ; -- "the 86 houses" --- assumes i > 1 - IndefOneNP, IndefManyNP : CN -> NP ; -- "a car", "cars" - DefOneNP, DefManyNP : CN -> NP ; -- "the car", "the cars" - ModGenOne, ModGenMany : NP -> CN -> NP ; -- "John's car", "John's cars" + IndefOneNP : CN -> NP ; -- "a car", "cars" + IndefManyNP : Num -> CN -> NP ; -- "houses", "86 houses" + DefOneNP : CN -> NP ; -- "the car" + DefManyNP : Num -> CN -> NP ; -- "the cars", "the 86 cars" + ModGenOne : NP -> CN -> NP ; -- "John's car" + ModGenMany : Num -> NP -> CN -> NP ; -- "John's cars", "John's 86 cars" UsePN : PN -> NP ; -- "John" UseFun : Fun -> CN ; -- "successor" AppFun : Fun -> NP -> CN ; -- "successor of zero" AppFun2 : Fun2 -> NP -> Fun ; -- "flight from Paris" CNthatS : CN -> S -> CN ; -- "idea that the Earth is flat" + UseInt : Int -> Num ; -- "32" --- assumes i > 1 + NoNum : Num ; -- no numeral modifier --3 Adjectives and adjectival phrases -- @@ -153,17 +158,21 @@ fun PosTV, NegTV : TV -> NP -> VP ; -- "sees John", "doesn't see John" PosPassV, NegPassV : V -> VP ; -- "is seen", "is not seen" PosNP, NegNP : NP -> VP ; -- "is John", "is not John" + PosAdV, NegAdV : AdV -> VP ; -- "is everywhere", "is not in France" PosVS, NegVS : VS -> S -> VP ; -- "says that I run", "doesn't say..." +--- PosVV, NegVV : VV -> VP -> VP ; -- "can run", "can't run", "tries to run" PosV3, NegV3 : V3 -> NP -> NP -> VP ; -- "prefers wine to beer" VTrans : TV -> V ; -- "loves" --3 Adverbials -- +-- Here is how complex adverbials can be formed and used. + + AdjAdv : AP -> AdV ; -- "freely", "more consciously than you" + PrepNP : Prep -> NP -> AdV ; -- "in London", "after the war" AdvVP : VP -> AdV -> VP ; -- "always walks", "walks in the park" - PrepNP : Prep -> NP -> AdV ; -- "in London", "after the war" AdvCN : CN -> AdV -> CN ; -- "house in London", "house today" - AdvAP : AdA -> AP -> AP ; -- "very good" @@ -173,7 +182,8 @@ fun PredVP : NP -> VP -> S ; -- "John walks" PosSlashTV, NegSlashTV : NP -> TV -> Slash ; -- "John sees", "John doesn's see" OneVP : VP -> S ; -- "one walks" - ThereIsCN, ThereAreCN : CN -> S ; -- "there is a car", "there are cars" + ThereIsCN : CN -> S ; -- "there is a bar" + ThereAreCN : Num -> CN -> S ; -- "there are 86 bars" IdRP : RP ; -- "which" FunRP : Fun -> RP -> RP ; -- "the successor of which" @@ -194,7 +204,8 @@ fun IntVP : IP -> VP -> Qu ; -- "who walks" IntSlash : IP -> Slash -> Qu ; -- "whom does John see" QuestAdv : IAdv -> NP -> VP -> Qu ; -- "why do you walk" - IsThereCN, AreThereCN : CN -> Qu ; -- "is there a bar", "are there bars" + IsThereCN : CN -> Qu ; -- "is there a bar" + AreThereCN : Num -> CN -> Qu ; -- "are there (86) bars" ImperVP : VP -> Imp ; -- "be a man" diff --git a/grammars/resource/nabstract/Structural.gf b/grammars/resource/nabstract/Structural.gf index 536f01985..5ac998f96 100644 --- a/grammars/resource/nabstract/Structural.gf +++ b/grammars/resource/nabstract/Structural.gf @@ -8,16 +8,26 @@ abstract Structural = Combinations ** { fun - EveryDet, AllDet, WhichDet, MostDet : Det ; -- every, all, which, most - SomeDet, SomesDet, AnyDet, AnysDet, NoDet, -- sg/pl some, any, no - NosDet, ManyDet, MuchDet : Det ; -- many, much - ThisDet, TheseDet, ThatDet, ThoseDet : Det ;-- (this, these, that, those) car(s) - ThisNP, TheseNP, ThatNP, ThoseNP : NP ; -- this, these, that, those + EveryDet, WhichDet, AllDet, -- every, sg which, sg all + SomeDet, AnyDet, NoDet, -- sg some, any, no + MostDet, MostsDet, ManyDet, MuchDet : Det ; -- sg most, pl most, many, much + ThisDet, ThatDet : Det ; -- this, that + +-- Many plural determiners can take a numeral modifier. + + AllsDet, WhichsDet, -- pl all, which (86) + SomesDet, AnysDet, NosDet, -- pl some, any, no + TheseDet, ThoseDet : Num -> Det ; -- these, those (86) + ThisNP, ThatNP : NP ; -- this, that + TheseNP, ThoseNP : Num -> NP ; -- these, those (86) INP, ThouNP, HeNP, SheNP, ItNP : NP ; -- personal pronouns in singular - WeNP, YeNP, TheyNP : NP ; -- personal pronouns in plural + WeNP, YeNP : Num -> NP ; -- these pronouns can take numeral + TheyNP : NP ; -- personal pronouns in plural YouNP : NP ; -- the polite you EverybodyNP, SomebodyNP, NobodyNP, -- everybody, somebody, nobody EverythingNP, SomethingNP, NothingNP : NP ; -- everything, something, nothing +--- CanVV, CanKnowVV, MustVV : VV ; -- can (pouvoir/savoir), must +--- WantVV : VV ; -- want (to do) WhenIAdv,WhereIAdv,WhyIAdv,HowIAdv : IAdv ; -- when, where, why, how EverywhereNP, SomewhereNP, NowhereNP : AdV ;-- everywhere, somewhere, nowhere AndConj, OrConj : Conj ; -- and, or @@ -32,5 +42,6 @@ fun InFrontPrep, BehindPrep, BetweenPrep : Prep ; BeforePrep, DuringPrep, AfterPrep : Prep ; -- temporal relations WithPrep, WithoutPrep, ByMeansPrep : Prep ; -- some other relations + PartPrep : Prep ; -- partitive "of" ("bottle of wine") AgentPrep : Prep ; -- agent "by" in passive constructions } diff --git a/grammars/resource/nabstract/TestResource.gf b/grammars/resource/nabstract/TestResource.gf index d1764aa3d..adafdcfbc 100644 --- a/grammars/resource/nabstract/TestResource.gf +++ b/grammars/resource/nabstract/TestResource.gf @@ -3,12 +3,12 @@ abstract TestResource = Structural ** { -- a random sample of lexicon to test resource grammar with fun - Big, Small, Old, Young : AdjDeg ; + Big, Happy, Small, Old, Young : AdjDeg ; American, Finnish : Adj1 ; Married : Adj2 ; - Man, Woman, Car, House, Light : N ; + Man, Woman, Car, House, Light, Bar, Bottle, Wine : N ; Walk, Run : V ; - Send, Wait, Love, SwitchOn, SwitchOff : TV ; + Send, Wait, Love, Drink, SwitchOn, SwitchOff : TV ; Give, Prefer : V3 ; Say, Prove : VS ; Mother, Uncle : Fun ; diff --git a/grammars/resource/nabstract/additions.txt b/grammars/resource/nabstract/additions.txt index 7f63bd81c..cbb5646ce 100644 --- a/grammars/resource/nabstract/additions.txt +++ b/grammars/resource/nabstract/additions.txt @@ -2,58 +2,82 @@ -- Combinations.gf cat - Prep ; -- pre/postposition and/or case + Prep ; -- pre/postposition and/or case e.g. + Num ; -- numeral, e.g. "three", "879" +--- VV ; -- verb-compl. verb, e.g. "can", "want" + fun - ThereIsCN, ThereAreCN : CN -> S ; -- "there is a bar", "there are bars" + ThereIsCN : CN -> S ; -- "there is a bar", "there are bars" + ThereAreCN : Num -> CN -> S ; -- "there are 86 bars" PrepNP : Prep -> NP -> AdV ; -- "in London", "after the war" (replace LocNP) MassNP : CN -> NP ; -- "wine" - IntNP : Int -> CN -> NP ; -- "86 houses" --- assumes i > 1 - DefIntNP : Int -> CN -> NP ; -- "the 86 houses" --- assumes i > 1 +--- PosVV, NegVV : VV -> VP -> VP ; -- "can run", "can't run", "tries to run" + PosAdV, NegAdV : AdV -> VP ; -- "is everywhere", "is not in France" + AdjAdv : AP -> AdV ; -- "freely", "more consciously than you" IsThereCN, AreThereCN : CN -> Qu ;-- "is there a bar", "are there bars" -Warning: no linearization of AdvAP -checking module ResFra -Warning: no linearization of AdvS -checking module ResFra -Warning: no linearization of AppFun2 -checking module ResFra -Warning: no linearization of CNthatS -checking module ResFra -Warning: no linearization of ConsPhr -checking module ResFra -Warning: no linearization of ItNP -checking module ResFra -Warning: no linearization of NegPassV -checking module ResFra -Warning: no linearization of NegV3 -checking module ResFra -Warning: no linearization of OnePhr -checking module ResFra -Warning: no linearization of OneVP -checking module ResFra -Warning: no linearization of OtherwiseAdv -checking module ResFra -Warning: no linearization of PosPassV -checking module ResFra -Warning: no linearization of PosV3 -checking module ResFra -Warning: no linearization of SubjVP -checking module ResFra -Warning: no linearization of ThereforeAdv -checking module ResFra -Warning: no linearization of TooAdv -checking module ResFra -Warning: no linearization of VTrans -checking module ResFra -Warning: no linearization of VeryAdv + + -- changed type signatures: added Num + IndefManyNP : Num -> CN -> NP ; -- "houses", "86 houses" + DefManyNP : Num -> CN -> NP ; -- "the cars", "the 86 cars" + ModGenMany : Num -> NP -> CN -> NP ; -- "John's cars", "John's 86 cars" + + UseInt : Int -> Num ; -- "32" --- assumes i > 1 + NoNum : Num ; -- no numeral modifier + + IsThereCN, AreThereCN : CN -> Qu ;-- "is there a bar", "are there bars" + +-- from Hajo's work + +AdvAP + +AdvS + +AppFun2 + +CNthatS + +ConsPhr + +ItNP + +NegPassV + +NegV3 + +OnePhr + +OneVP + +OtherwiseAdv + +PosPassV + +PosV3 + +SubjVP + +ThereforeAdv + +TooAdv + +VTrans + +VeryAdv -- Structural.gf - SomeDet, SomesDet, AnyDet, AnysDet, NoDet, -- sg/pl some, any, no - NosDet, ManyDet, MuchDet : Det ; -- many, much - ThisDet, TheseDet, ThatDet, ThoseDet : Det ;-- this, these, that, those - ThisNP, TheseNP, ThatNP, ThoseNP : NP ; -- this, these, that, those +-- Some of these are just changes to Num -> Det|NP. + AllDet : Det ; -- sg all + AllsDet, WhichsDet, -- pl all, which (86) + SomesDet, AnysDet, NosDet, -- pl some, any, no + TheseDet, ThoseDet : Num -> Det ; -- these, those (86) + ThisNP, TheseNP : NP ; -- this, that + TheseNP, ThoseNP : Num -> NP ; -- these, those (86) + INP, ThouNP, HeNP, SheNP, ItNP : NP ; -- personal pronouns in singular + WeNP, YeNP : Num -> NP ; -- these pronouns can take numeral + EverybodyNP, SomebodyNP, NobodyNP, -- everybody, somebody, nobody EverythingNP, SomethingNP, NothingNP : NP ; -- everything, something, nothing EverywhereNP, SomewhereNP, NowhereNP : Adv ;-- everywhere, somewhere, nowhere @@ -64,18 +88,20 @@ Warning: no linearization of VeryAdv InFrontPrep, BehindPrep, BetweenPrep : Prep ; BeforePrep, DuringPrep, AfterPrep : Prep ; -- temporal relations WithPrep, WithoutPrep, ByMeansPrep : Prep ; -- some other relations + PartPrep : Prep ; -- partitive "of" ("bottle of wine") AgentPrep : Prep ; -- agent "by" in passive constructions -checking module TestFra -Warning: no linearization of American -checking module TestFra -Warning: no linearization of Connection -checking module TestFra -Warning: no linearization of Finnish -checking module TestFra -Warning: no linearization of Give -checking module TestFra -Warning: no linearization of Married -checking module TestFra -Warning: no linearization of Prefer + +American + +Connection + +Finnish + +Give + +Married + +Prefer + diff --git a/grammars/resource/nenglish/CombinationsEng.gf b/grammars/resource/nenglish/CombinationsEng.gf index 41cba4831..74974a2fb 100644 --- a/grammars/resource/nenglish/CombinationsEng.gf +++ b/grammars/resource/nenglish/CombinationsEng.gf @@ -37,11 +37,12 @@ lincat Fun = Function ; -- = CommNounPhrase ** {s2 : Preposition} ; Fun2 = Function ** {s3 : Preposition} ; + Num = {s : Case => Str} ; Adj1 = Adjective ; - -- = {s : Str} + -- = {s : AForm => Str} Adj2 = Adjective ** {s2 : Preposition} ; - AdjDeg = {s : Degree => Str} ; + AdjDeg = {s : Degree => AForm => Str} ; AP = Adjective ** {p : Bool} ; V = Verb ; @@ -51,6 +52,7 @@ lincat -- = Verb ** {s3 : Preposition} ; V3 = TransVerb ** {s4 : Preposition} ; VS = Verb ; + VV = Verb ** {isAux : Bool} ; AdV = {s : Str ; p : Bool} ; @@ -69,7 +71,7 @@ lincat ConjD = {s1 : Str ; s2 : Str ; n : Number} ; ListS = {s1 : Str ; s2 : Str} ; - ListAP = {s1 : Str ; s2 : Str ; p : Bool} ; + ListAP = {s1,s2 : AForm => Str ; p : Bool} ; ListNP = {s1,s2 : NPForm => Str ; n : Number ; p : Person} ; --. @@ -77,7 +79,7 @@ lincat lin UseN = noun2CommNounPhrase ; ModAdj = modCommNounPhrase ; - ModGenOne = npGenDet singular ; + ModGenOne = npGenDet singular noNum ; ModGenMany = npGenDet plural ; UsePN = nameNounPhrase ; UseFun = funAsCommNounPhrase ; @@ -91,14 +93,14 @@ lin DetNP = detNounPhrase ; IndefOneNP = indefNounPhrase singular ; - IndefManyNP = indefNounPhrase plural ; + IndefManyNP = indefNounPhraseNum plural ; DefOneNP = defNounPhrase singular ; - DefManyNP = defNounPhrase plural ; + DefManyNP = defNounPhraseNum plural ; MassNP = detNounPhrase (mkDeterminer Sg []) ; - IntNP n = detNounPhrase (mkDeterminer Pl n.s) ; - DefIntNP n = detNounPhrase (mkDeterminer Pl ("the" ++ n.s)) ; CNthatS = nounThatSentence ; + UseInt i = {s = table {Nom => i.s ; Gen => i.s ++ "'s"}} ; --- + NoNum = noNum ; PredVP = predVerbPhrase ; PosV = predVerb True ; @@ -115,12 +117,17 @@ lin NegPassV = passVerb False ; PosNP = predNounPhrase True ; NegNP = predNounPhrase False ; + PosAdV = predAdverb True ; + NegAdV = predAdverb False ; PosVS = complSentVerb True ; NegVS = complSentVerb False ; +--- PosVV = complVerbVerb True ; +--- NegVV = complVerbVerb False ; VTrans = transAsVerb ; - AdvVP = adVerbPhrase ; + AdjAdv a = advPost (a.s ! AAdv) ; PrepNP p = prepPhrase p.s ; --- + AdvVP = adVerbPhrase ; AdvCN = advCommNounPhrase ; AdvAP = advAdjPhrase ; @@ -129,8 +136,8 @@ lin OneVP = predVerbPhrase (nameNounPhrase (nameReg "one")) ; ThereIsCN A = prefixSS ["there is"] --- (defaultNounPhrase (indefNounPhrase singular A)) ; - ThereAreCN A = prefixSS ["there are"] - (defaultNounPhrase (indefNounPhrase plural A)) ; + ThereAreCN n A = prefixSS ["there are"] + (defaultNounPhrase (indefNounPhraseNum plural n A)) ; IdRP = identRelPron ; FunRP = funRelPron ; @@ -151,7 +158,7 @@ lin IntVP = intVerbPhrase ; IntSlash = intSlash ; QuestAdv = questAdverbial ; - IsThereCN = isThere singular ; + IsThereCN = isThere singular noNum ; AreThereCN = isThere plural ; ImperVP = imperVerbPhrase ; diff --git a/grammars/resource/nenglish/MorphoEng.gf b/grammars/resource/nenglish/MorphoEng.gf index dc7c5cce2..54dbdeb2a 100644 --- a/grammars/resource/nenglish/MorphoEng.gf +++ b/grammars/resource/nenglish/MorphoEng.gf @@ -1,3 +1,5 @@ +--# -path=.:../../prelude + --1 A Simple English Resource Morphology -- -- Aarne Ranta 2002 @@ -7,7 +9,7 @@ -- -- We use the parameter types and word classes defined in $Types.gf$. -resource MorphoEng = TypesEng ** open Prelude in { +resource MorphoEng = TypesEng ** open Prelude, (Predef=Predef) in { --2 Nouns -- @@ -90,25 +92,58 @@ oper --2 Adjectives -- --- For the comparison of adjectives, three forms are needed in the worst case. +-- To form the adjectival and the adverbial forms, two strings are needed +-- in the worst case. - mkAdjDegr : (_,_,_ : Str) -> AdjDegr = \good,better,best -> - {s = table {Pos => good ; Comp => better ; Sup => best}} ; + mkAdjective : Str -> Str -> Adjective = \free,freely -> { + s = table { + AAdj => free ; + AAdv => freely + } + } ; + +-- However, the ending "iy" is sufficient for most cases. This function +-- automatically changes the word-final "y" to "i" ("happy" - "happily"). +-- N.B. this is not correct for "shy", but $mkAdjective$ has to be used. - adjDegrReg : Str -> AdjDegr = \long -> - mkAdjDegr long (long + "er") (long + "est") ; + regAdjective : Str -> Adjective = \free -> + let + y = Predef.dp 1 free + in mkAdjective + free + (ifTok Str y "y" (Predef.tk 1 free + ("ily")) (free + "ly")) ; - adjDegrY : Str -> AdjDegr = \lovel -> - mkAdjDegr (lovel + "y") (lovel + "ier") (lovel + "iest") ; +-- For the comparison of adjectives, six forms are needed to cover all cases. +-- But there is no adjective that actually needs all these. + + mkAdjDegrWorst : (_,_,_,_,_,_ : Str) -> AdjDegr = + \good,well,better,betterly,best,bestly -> + {s = table { + Pos => (mkAdjective good well).s ; + Comp => (mkAdjective better betterly).s ; + Sup => (mkAdjective best bestly).s + } + } ; + +-- What is usually needed for irregular comparisons are just three forms, +-- since the adverbial form is the same (in comparative or superlative) +-- or formed in the regular way (positive). + + adjDegrIrreg : (_,_,_ : Str) -> AdjDegr = \bad,worse,worst -> + let badly = (regAdjective bad).s ! AAdv + in mkAdjDegrWorst bad badly worse worse worst worst ; + +-- Like above, the regular formation takes account of final "y". + + adjDegrReg : Str -> AdjDegr = \happy -> + let happi = ifTok Str (Predef.dp 1 happy) "y" (Predef.tk 1 happy + "i") happy + in adjDegrIrreg happy (happi + "er") (happi + "est") ; -- Many adjectives are 'inflected' by adding a comparison word. adjDegrLong : Str -> AdjDegr = \ridiculous -> - mkAdjDegr ridiculous ("more" ++ ridiculous) ("most" ++ ridiculous) ; + adjDegrIrreg ridiculous ("more" ++ ridiculous) ("most" ++ ridiculous) ; --- simple adjectives are just strings - - simpleAdj : Str -> Adjective = ss ; --3 Verbs -- diff --git a/grammars/resource/nenglish/ParadigmsEng.gf b/grammars/resource/nenglish/ParadigmsEng.gf index 40b5fafc0..967c7ec56 100644 --- a/grammars/resource/nenglish/ParadigmsEng.gf +++ b/grammars/resource/nenglish/ParadigmsEng.gf @@ -92,12 +92,12 @@ oper mkAdj2 : (divisible, by : Str) -> Adj2 ; -- Comparison adjectives have three forms. The common irregular --- cases are ones ending with "y" and a consonant that is duplicated. +-- cases are ones ending with "y" and a consonant that is duplicated; +-- the "y" ending is recognized by the function $aReg$. mkAdjDeg : (good,better,best : Str) -> AdjDeg ; aReg : (long : Str) -> AdjDeg ; -- long, longer, longest - aHappy : (happy : Str) -> AdjDeg ; -- happy, happier, happiest aFat : (fat : Str) -> AdjDeg ; -- fat, fatter, fattest aRidiculous : (ridiculous : Str) -> AdjDeg ; -- -/more/most ridiculous @@ -197,11 +197,10 @@ oper addGenN : (Str -> CommonNoun) -> Str -> Gender -> N = \f -> \s,g -> f s ** {g = g ; lock_N = <>} ; - mkAdj1 a = simpleAdj a ** {lock_Adj1 = <>} ; - mkAdj2 = \s,p -> simpleAdj s ** {s2 = p} ** {lock_Adj2 = <>} ; - mkAdjDeg a b c = mkAdjDegr a b c ** {lock_AdjDeg = <>} ; + mkAdj1 a = regAdjective a ** {lock_Adj1 = <>} ; + mkAdj2 = \s,p -> regAdjective s ** {s2 = p} ** {lock_Adj2 = <>} ; + mkAdjDeg a b c = adjDegrIrreg a b c ** {lock_AdjDeg = <>} ; aReg a = adjDegrReg a ** {lock_AdjDeg = <>} ; - aHappy = \happy -> adjDegrY (Predef.tk 1 happy) ** {lock_AdjDeg = <>} ; aFat = \fat -> let {fatt = fat + Predef.dp 1 fat} in mkAdjDeg fat (fatt + "er") (fatt + "est") ; aRidiculous a = adjDegrLong a ** {lock_AdjDeg = <>} ; diff --git a/grammars/resource/nenglish/StructuralEng.gf b/grammars/resource/nenglish/StructuralEng.gf index 25f44cf71..c43a291e0 100644 --- a/grammars/resource/nenglish/StructuralEng.gf +++ b/grammars/resource/nenglish/StructuralEng.gf @@ -12,32 +12,35 @@ concrete StructuralEng of Structural = HeNP = pronHe ; SheNP = pronShe ; ItNP = pronIt ; - WeNP = pronWe ; - YeNP = pronYouPl ; + WeNP = pronWithNum pronWe ; + YeNP = pronWithNum pronYouPl ; YouNP = pronYouSg ; TheyNP = pronThey ; EveryDet = everyDet ; - AllDet = allDet ; + AllDet = mkDeterminer Sg "all" ; --- all the missing + AllsDet = mkDeterminerNum Pl "all" ; WhichDet = whichDet ; - MostDet = mostDet ; + WhichsDet = mkDeterminerNum Pl "which" ; + MostsDet = mostDet ; + MostDet = mkDeterminer Sg "most" ; SomeDet = mkDeterminer Sg "some" ; - SomesDet = mkDeterminer Pl "some" ; + SomesDet = mkDeterminerNum Pl "some" ; AnyDet = mkDeterminer Sg "any" ; - AnysDet = mkDeterminer Pl "any" ; + AnysDet = mkDeterminerNum Pl "any" ; NoDet = mkDeterminer Sg "no" ; - NosDet = mkDeterminer Pl "no" ; + NosDet = mkDeterminerNum Pl "no" ; ManyDet = mkDeterminer Sg "many" ; MuchDet = mkDeterminer Sg ["a lot of"] ; --- ThisDet = mkDeterminer Sg "this" ; - TheseDet = mkDeterminer Pl "these" ; + TheseDet = mkDeterminerNum Pl "these" ; ThatDet = mkDeterminer Sg "that" ; - ThoseDet = mkDeterminer Pl "those" ; + ThoseDet = mkDeterminerNum Pl "those" ; ThisNP = nameNounPhrase (nameReg "this") ; - TheseNP = nameNounPhrase (nameReg "these") ; ThatNP = nameNounPhrase (nameReg "that") ; - ThoseNP = nameNounPhrase (nameReg "those") ; + TheseNP n = nameNounPhrase {s = \\c => "these" ++ n.s ! c} ; + ThoseNP n = nameNounPhrase {s = \\c => "those" ++ n.s ! c} ; EverybodyNP = nameNounPhrase (nameReg "everybody") ; SomebodyNP = nameNounPhrase (nameReg "somebody") ; @@ -46,6 +49,11 @@ concrete StructuralEng of Structural = SomethingNP = nameNounPhrase (nameReg "something") ; NothingNP = nameNounPhrase (nameReg "nothing") ; +--- CanVV = vvCan ; +--- CanKnowVV = vvCan ; +--- MustVV = vvMust ; +--- WantVV = verbNoPart (regVerbP3 "want") ** {isAux = False} ; + HowIAdv = ss "how" ; WhenIAdv = ss "when" ; WhereIAdv = ss "where" ; @@ -89,6 +97,7 @@ concrete StructuralEng of Structural = WithPrep = ss "with" ; WithoutPrep = ss "without" ; ByMeansPrep = ss "by" ; + PartPrep = ss "of" ; AgentPrep = ss "by" ; } diff --git a/grammars/resource/nenglish/SyntaxEng.gf b/grammars/resource/nenglish/SyntaxEng.gf index 9c031c343..45e576c59 100644 --- a/grammars/resource/nenglish/SyntaxEng.gf +++ b/grammars/resource/nenglish/SyntaxEng.gf @@ -1,3 +1,5 @@ +--# -path=.:../../prelude + --1 A Small English Resource Syntax -- -- Aarne Ranta 2002 @@ -45,10 +47,21 @@ oper nameNounPhrase : ProperName -> NounPhrase = \john -> {s = \\c => john.s ! toCase c ; n = Sg ; p = P3} ; +-- The following construction has to be refined for genitive forms: +-- "we two", "us two" are OK, but "our two" is not. + + Numeral : Type = {s : Case => Str} ; + + pronWithNum : Pronoun -> Numeral -> Pronoun = \we,two -> + {s = \\c => we.s ! c ++ two.s ! toCase c ; n = we.n ; p = we.p} ; + + noNum : Numeral = {s = \\_ => []} ; + --2 Determiners -- -- Determiners are inflected according to the nouns they determine. -- The determiner is not inflected. + Determiner : Type = {s : Str ; n : Number} ; detNounPhrase : Determiner -> CommNounPhrase -> NounPhrase = \every, man -> @@ -57,50 +70,63 @@ oper p = P3 } ; - mkDeterminer : Number -> Str -> Determiner = \n,det -> - {s = det ; + mkDeterminer : Number -> Str -> Determiner = \n,the -> + mkDeterminerNum n the noNum ; + + mkDeterminerNum : Number -> Str -> Numeral -> Determiner = \n,det,two -> + {s = det ++ two.s ! Nom ; n = n } ; everyDet = mkDeterminer Sg "every" ; - allDet = mkDeterminer Pl "all" ; + allDet = mkDeterminerNum Pl "all" ; mostDet = mkDeterminer Pl "most" ; aDet = mkDeterminer Sg artIndef ; - plDet = mkDeterminer Pl [] ; + plDet = mkDeterminerNum Pl [] ; theSgDet = mkDeterminer Sg "the" ; - thePlDet = mkDeterminer Pl "the" ; + thePlDet = mkDeterminerNum Pl "the" ; anySgDet = mkDeterminer Sg "any" ; - anyPlDet = mkDeterminer Pl "any" ; + anyPlDet = mkDeterminerNum Pl "any" ; whichSgDet = mkDeterminer Sg "which" ; - whichPlDet = mkDeterminer Pl "which" ; + whichPlDet = mkDeterminerNum Pl "which" ; whichDet = whichSgDet ; --- API indefNoun : Number -> CommNoun -> Str = \n,man -> (indefNounPhrase n man).s ! NomP ; - indefNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n,man -> + indefNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n -> + indefNounPhraseNum n noNum ; + + indefNounPhraseNum : Number -> Numeral ->CommNounPhrase -> NounPhrase = + \n,two,man -> {s = \\c => case n of { - Sg => artIndef ++ man.s ! n ! toCase c ; - Pl => man.s ! n ! toCase c + Sg => artIndef ++ two.s ! Nom ++ man.s ! n ! toCase c ; + Pl => two.s ! Nom ++ man.s ! n ! toCase c } ; n = n ; p = P3 } ; - defNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n,car -> - {s = \\c => artDef ++ car.s ! n ! toCase c ; n = n ; p = P3} ; + defNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n -> + defNounPhraseNum n noNum ; + defNounPhraseNum : Number -> Numeral -> CommNounPhrase -> NounPhrase = + \n,two,car -> + {s = \\c => artDef ++ two.s ! Nom ++ car.s ! n ! toCase c ; + n = n ; + p = P3 + } ; -- Genitives of noun phrases can be used like determiners, to build noun phrases. -- The number argument makes the difference between "my house" - "my houses". -- -- We have the variation "the car of John / the car of John's / John's car" - npGenDet : Number -> NounPhrase -> CommNounPhrase -> NounPhrase = - \n,john,car -> + npGenDet : Number -> Numeral -> NounPhrase -> CommNounPhrase -> NounPhrase = + \n,two,john,car -> {s = \\c => variants { - artDef ++ car.s ! n ! Nom ++ "of" ++ john.s ! GenSP ; - john.s ! GenP ++ car.s ! n ! toCase c + artDef ++ two.s ! Nom ++ car.s ! n ! Nom ++ "of" ++ john.s ! GenSP ; + john.s ! GenP ++ two.s ! Nom ++ car.s ! n ! toCase c } ; n = n ; p = P3 @@ -134,7 +160,7 @@ oper adj2adjPhrase : Adjective -> AdjPhrase = \new -> new ** {p = True} ; simpleAdjPhrase : Str -> AdjPhrase = \French -> - adj2adjPhrase (simpleAdj French) ; + adj2adjPhrase (regAdjective French) ; --3 Comparison adjectives @@ -144,13 +170,13 @@ oper -- Positive forms are used alone, as adjectival phrases ("big"). positAdjPhrase : AdjDegr -> AdjPhrase = \big -> - adj2adjPhrase (ss (big.s ! Pos)) ; + adj2adjPhrase {s = big.s ! Pos} ; -- Comparative forms are used with an object of comparison, as -- adjectival phrases ("bigger then you"). comparAdjPhrase : AdjDegr -> NounPhrase -> AdjPhrase = \big, you -> - {s = big.s ! Comp ++ "than" ++ you.s ! NomP ; + {s = \\a => big.s ! Comp ! a ++ "than" ++ you.s ! NomP ; p = False } ; @@ -158,7 +184,7 @@ oper -- maximal representative of a domain ("the biggest house"). superlNounPhrase : AdjDegr -> CommNoun -> NounPhrase = \big, house -> - {s = \\c => "the" ++ big.s ! Sup ++ house.s ! Sg ! toCase c ; + {s = \\c => "the" ++ big.s ! Sup ! AAdj ++ house.s ! Sg ! toCase c ; n = Sg ; p = P3 } ; @@ -174,7 +200,7 @@ oper AdjCompl = Adjective ** {s2 : Preposition} ; complAdj : AdjCompl -> NounPhrase -> AdjPhrase = \related,john -> - {s = related.s ++ related.s2 ++ john.s ! AccP ; + {s = \\a => related.s ! a ++ related.s2 ++ john.s ! AccP ; p = False } ; @@ -190,8 +216,8 @@ oper modCommNounPhrase : AdjPhrase -> CommNounPhrase -> CommNounPhrase = \big, car -> {s = \\n => if_then_else (Case => Str) big.p - (\\c => big.s ++ car.s ! n ! c) - (table {Nom => car.s ! n ! Nom ++ big.s ; Gen => variants {}}) ; + (\\c => big.s ! AAdj ++ car.s ! n ! c) + (table {Nom => car.s ! n ! Nom ++ big.s ! AAdj ; Gen => variants {}}) ; g = car.g } ; @@ -234,7 +260,7 @@ oper let {n = john.n ; nf = if_then_else Number coll Sg n} in variants { defNounPhrase nf (appFunComm mother john) ; - npGenDet nf john mother + npGenDet nf noNum john mother } ; -- The commonest case is functions with the preposition "of". @@ -305,7 +331,7 @@ oper predAdjective : Bool -> Adjective -> VerbPhrase = \b,old -> {s = beOrNotBe b ; - s2 = \\_ => old.s ; + s2 = \\_ => old.s ! AAdj ; isAux = True } ; @@ -321,6 +347,12 @@ oper isAux = True } ; + predAdverb : Bool -> Adverb -> VerbPhrase = \b,elsewhere -> + {s = beOrNotBe b ; + s2 = \\_ => elsewhere.s ; + isAux = True + } ; + -- We use an auxiliary giving all forms of "be". beOrNotBe : Bool -> (VForm => Str) = \b -> @@ -376,7 +408,7 @@ oper -- The syntax is the same as for adjectival predication. passVerb : Bool -> Verb -> VerbPhrase = \b,love -> - predAdjective b (adj2adjPhrase (ss (love.s ! PPart))) ; + predAdjective b (adj2adjPhrase (regAdjective (love.s ! PPart))) ; -- Transitive verbs can be used elliptically as verbs. The semantics -- is left to applications. The definition is trivial, due to record @@ -434,7 +466,7 @@ oper } ; advAdjPhrase : SS -> AdjPhrase -> AdjPhrase = \very, good -> - {s = very.s ++ good.s ; + {s = \\a => very.s ++ good.s ! a ; p = good.p } ; @@ -504,6 +536,50 @@ oper s2 = \\_ => say.s ! InfImp ++ thatjohnruns ; isAux = True} ; +--3 Verb-complement verbs +-- +-- Sentence-complement verbs take verb phrases as complements. +-- They can be auxiliaries ("can", "must") or ordinary verbs +-- ("try"); this distinction cannot be done in the multilingual +-- API and leads to some anomalies in English, such as the necessity +-- to create the infinitive form "to be able to" for "can" so that +-- the construction can be iterated, and the corresponding complication +-- in the parameter structure. + + VerbVerb : Type = Verb ** {isAux : Bool} ; + +-- To generate "can walk"/"can't walk"; "tries to walk"/"does not try to walk": +-- The contraction of "not" is not provided, since it would require changing +-- the verb parameter type. + + complVerbVerb : Bool -> VerbVerb -> VerbPhrase -> VerbPhrase = \b,try,run -> + let to = if_then_else Str try.isAux [] "to" + in + if_then_else VerbPhrase b + {s = \\v => try.s ! v ++ try.s1 ++ to ++ run.s ! InfImp ; + s2 = run.s2 ; + isAux = try.isAux + } + {s = \\v => try.s ! v ++ "not" ; + s2 = \\n => run.s ! InfImp ++ run.s2 ! n ; + isAux = True + } ; + +-- The three most important example auxiliaries. + + mkVerbAux : (_,_,_,_: Str) -> VerbVerb = \beable, can, could, beenable -> + {s = table { + InfImp => beable ; + Indic _ => can ; + Past _ => could ; + PPart => beenable + } ; + s1 = [] ; + isAux = True + } ; + + vvCan : VerbVerb = mkVerbAux ["be able to"] "can" "could" ["been able to"] ; + vvMust : VerbVerb = mkVerbAux ["have to"] "must" ["had to"] ["had to"] ; --2 Sentences missing noun phrases -- @@ -687,13 +763,13 @@ oper } } ; - isThere : Number -> CommNounPhrase -> Question = \n,bar -> + isThere : Number -> Numeral -> CommNounPhrase -> Question = \n,num,bar -> questVerbPhrase (case n of { Sg => nameNounPhrase (nameReg "there") ; Pl => {s = \\_ => "there" ; n = Pl ; p = P3} }) - (predNounPhrase True (indefNounPhrase n bar)) ; + (predNounPhrase True (indefNounPhraseNum n num bar)) ; --3 Wh-questions @@ -815,20 +891,20 @@ oper -- The structure is the same as for sentences. The result is a prefix adjective -- if and only if all elements are prefix. - ListAdjPhrase : Type = SD2 ** {p : Bool} ; + ListAdjPhrase : Type = {s1,s2 : AForm => Str ; p : Bool} ; twoAdjPhrase : (_,_ : AdjPhrase) -> ListAdjPhrase = \x,y -> - CO.twoStr x.s y.s ** {p = andB x.p y.p} ; + CO.twoTable AForm x y ** {p = andB x.p y.p} ; consAdjPhrase : ListAdjPhrase -> AdjPhrase -> ListAdjPhrase = \xs,x -> - CO.consStr CO.comma xs x.s ** {p = andB xs.p x.p} ; + CO.consTable AForm CO.comma xs x ** {p = andB xs.p x.p} ; conjunctAdjPhrase : Conjunction -> ListAdjPhrase -> AdjPhrase = \c,xs -> - ss (CO.conjunctX c xs) ** {p = xs.p} ; + CO.conjunctTable AForm c xs ** {p = xs.p} ; conjunctDistrAdjPhrase : ConjunctionDistr -> ListAdjPhrase -> AdjPhrase = \c,xs -> - ss (CO.conjunctDistrX c xs) ** {p = xs.p} ; + CO.conjunctDistrTable AForm c xs ** {p = xs.p} ; --3 Coordinating noun phrases diff --git a/grammars/resource/nenglish/TestResourceEng.gf b/grammars/resource/nenglish/TestResourceEng.gf index a674b1a4d..eaad5f941 100644 --- a/grammars/resource/nenglish/TestResourceEng.gf +++ b/grammars/resource/nenglish/TestResourceEng.gf @@ -8,18 +8,22 @@ flags startcat=Phr ; lexer=literals ; parser=chart ; unlexer=text ; -- a random sample from the lexicon lin - Big = mkAdjDegr "big" "bigger" "biggest"; + Big = adjDegrIrreg "big" "bigger" "biggest"; + Happy = adjDegrReg "happy" ; Small = adjDegrReg "small" ; Old = adjDegrReg "old" ; Young = adjDegrReg "young" ; - American = simpleAdj "American" ; - Finnish = simpleAdj "Finnish" ; - Married = simpleAdj "married" ** {s2 = "to"} ; + American = regAdjective "American" ; + Finnish = regAdjective "Finnish" ; + Married = regAdjective "married" ** {s2 = "to"} ; Man = cnHum (mkNoun "man" "men" "man's" "men's") ; Woman = cnHum (mkNoun "woman" "women" "woman's" "women's") ; Car = cnNoHum (nounReg "car") ; House = cnNoHum (nounReg "house") ; Light = cnNoHum (nounReg "light") ; + Bar = cnNoHum (nounReg "bar") ; + Bottle = cnNoHum (nounReg "bottle") ; + Wine = cnNoHum (nounReg "wine") ; Walk = verbNoPart (regVerbP3 "walk") ; Run = verbNoPart (mkVerb "run" "ran" "run") ; Say = verbNoPart (mkVerb "say" "said" "said") ; @@ -27,6 +31,7 @@ lin Send = mkTransVerbDir (verbNoPart (mkVerb "send" "sent" "sent")) ; Love = mkTransVerbDir (verbNoPart (verbP3e "love")) ; Wait = mkTransVerb (verbNoPart (regVerbP3 "wait")) "for" ; + Drink = mkTransVerbDir (verbNoPart (mkVerb "drink" "drank" "drunk")) ; Give = mkDitransVerb (verbNoPart (mkVerb "give" "gave" "given")) [] [] ; Prefer = mkDitransVerb (verbNoPart (mkVerb "prefer" "preferred" "preferred")) [] "to" ; diff --git a/grammars/resource/nenglish/TypesEng.gf b/grammars/resource/nenglish/TypesEng.gf index c1125494b..61682c14f 100644 --- a/grammars/resource/nenglish/TypesEng.gf +++ b/grammars/resource/nenglish/TypesEng.gf @@ -48,10 +48,13 @@ oper -- -- The major division is between the comparison degrees, but it -- is also good to leave room for adjectives that cannon be compared. --- Such adjectives are simply strings. +-- It is, however, productive to form an adverbial from any adjective. - Adjective : Type = SS ; - AdjDegr = SS1 Degree ; +param AForm = AAdj | AAdv ; + +oper + Adjective : Type = SS1 AForm ; + AdjDegr = {s : Degree => AForm => Str} ; --3 Verbs -- diff --git a/grammars/resource/swedish/MorphoSwe.gf b/grammars/resource/swedish/MorphoSwe.gf index 12d15ac27..b742fe455 100644 --- a/grammars/resource/swedish/MorphoSwe.gf +++ b/grammars/resource/swedish/MorphoSwe.gf @@ -27,6 +27,7 @@ oper oper verbVara = extVerb Act vara_1200 ; verbHava = extVerb Act hava_1198 ; + verbFinnas = mkVerb "finnas" "finns" "finns" ; -- A simplified conjugation takes three forms in the worst case. diff --git a/grammars/resource/swedish/SyntaxSwe.gf b/grammars/resource/swedish/SyntaxSwe.gf index 9b9897ee1..d46bfa174 100644 --- a/grammars/resource/swedish/SyntaxSwe.gf +++ b/grammars/resource/swedish/SyntaxSwe.gf @@ -87,6 +87,25 @@ oper 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 = nameNounPhrase (mkProperName "man" Utr Masc) ; + npDet = nameNounPhrase (mkProperName "det" Neutr NoMasc) ; + --2 Determiners -- -- Determiners are inflected according to noun in gender and sex. @@ -110,8 +129,14 @@ oper mkDeterminerSg : DetSg -> SpeciesP -> Determiner = \en, b -> {s = en ; n = Sg ; b = b} ; - mkDeterminerPl : DetPl -> SpeciesP -> Determiner = \alla, b -> - {s = table {_ => table {_ => alla}} ; n = Pl ; b = b} ; + mkDeterminerPl : DetPl -> SpeciesP -> Determiner = \alla -> + mkDeterminerPlNum alla noNum ; + + mkDeterminerPlNum : DetPl -> Numeral -> SpeciesP -> Determiner = \alla,n,b -> + {s = \\_,_ => alla ++ n.s ! Nom ; + n = Pl ; + b = b + } ; detSgInvar : Str -> DetSg = \varje -> table {_ => table {_ => varje}} ; @@ -147,12 +172,12 @@ oper -- 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 -> NounPhrase -> CommNounPhrase -> NounPhrase = - \n,huset,vin -> { + 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 ++ + Pl => huset.s ! PGen APl ++ tre.s ! Nom ++ vin.s ! Pl ! DefP Indef ! npCase c } ; g = vin.g ; @@ -160,10 +185,12 @@ oper } ; -- *Bare plural noun phrases* like "män", "goda vänner", are built without a --- determiner word. +-- determiner word. But a $Numeral$ may occur. - plurDet : CommNounPhrase -> NounPhrase = \cn -> - {s = \\c => cn.s ! Pl ! IndefP ! npCase c ; + 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 } ; @@ -174,21 +201,30 @@ oper denDet : CommNounPhrase -> NounPhrase = \cn -> detNounPhrase (mkDeterminerSgGender (table {g => artDef ! cn.p ! ASg g}) (DefP Def)) cn ; - deDet : CommNounPhrase -> NounPhrase = \cn -> - detNounPhrase (mkDeterminerPl (artDef ! cn.p ! APl) (DefP Def)) cn ; + deDet : Numeral -> CommNounPhrase -> NounPhrase = \n,cn -> + detNounPhrase (mkDeterminerPlNum (artDef ! cn.p ! APl) n (DefP Def)) cn ; -- It is useful to have macros for indefinite and definite, singular and plural -- noun-phrase-like syncategorematic expressions. - indefNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n,hus -> case n of { - Sg => detNounPhrase enDet hus ; - Pl => plurDet hus - } ; + indefNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n -> + indefNounPhraseNum n noNum ; - defNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n,hus -> case n of { - Sg => denDet hus ; - Pl => deDet hus - } ; + 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 ; @@ -379,7 +415,7 @@ oper let {n = x.n ; nf = if_then_else Number coll Sg n} in variants { defNounPhrase nf (appFunComm värde x) ; - npGenDet nf x (noun2CommNounPhrase värde) + npGenDet nf noNum x (noun2CommNounPhrase värde) } ; -- Two-place functions add one argument place. @@ -452,6 +488,12 @@ oper s3 = \\_,_ => john.s ! PNom } ; + predAdverb : Bool -> Adverb -> VerbPhrase = \b,ute -> + verbVara ** { + s2 = negation b ; + s3 = \\_,_ => ute.s + } ; + --3 Transitive verbs -- -- Transitive verbs are verbs with a preposition for the complement, diff --git a/grammars/resource/swedish/TypesSwe.gf b/grammars/resource/swedish/TypesSwe.gf index 3f50ace66..beead9489 100644 --- a/grammars/resource/swedish/TypesSwe.gf +++ b/grammars/resource/swedish/TypesSwe.gf @@ -73,6 +73,8 @@ param 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