From 027539d4e22d8498d09f85b3537bcaacca9555ae Mon Sep 17 00:00:00 2001 From: aarne Date: Tue, 18 Jan 2005 16:16:29 +0000 Subject: [PATCH] English complete (but needs more testing) --- lib/resource/english/AllResourceEng.gf | 1 + lib/resource/english/CategoriesEng.gf | 8 +- lib/resource/english/MorphoEng.gf | 10 + lib/resource/english/NumeralsEng.gf | 31 +++ lib/resource/english/ParadigmsEng.gf | 301 ++++++++++++++++++++++++ lib/resource/english/ResourceEng.gf | 3 + lib/resource/english/RulesEng.gf | 21 +- lib/resource/english/StructuralEng.gf | 7 +- lib/resource/english/SyntaxEng.gf | 156 +++++++----- lib/resource/english/TestResourceEng.gf | 5 +- 10 files changed, 464 insertions(+), 79 deletions(-) create mode 100644 lib/resource/english/AllResourceEng.gf create mode 100644 lib/resource/english/NumeralsEng.gf create mode 100644 lib/resource/english/ParadigmsEng.gf create mode 100644 lib/resource/english/ResourceEng.gf diff --git a/lib/resource/english/AllResourceEng.gf b/lib/resource/english/AllResourceEng.gf new file mode 100644 index 000000000..ce3e6857d --- /dev/null +++ b/lib/resource/english/AllResourceEng.gf @@ -0,0 +1 @@ +concrete AllResourceEng of AllResource = RulesEng, StructuralEng ** {} ; diff --git a/lib/resource/english/CategoriesEng.gf b/lib/resource/english/CategoriesEng.gf index 231b8368d..0181ff91a 100644 --- a/lib/resource/english/CategoriesEng.gf +++ b/lib/resource/english/CategoriesEng.gf @@ -50,23 +50,23 @@ lincat -- = {s : VForm => Str ; s1 : Particle} VG = {s,s2 : Bool => VPForm => Str ; s3 : Number => Str ; isAux : Bool} ; VP = {s,s2 : VPForm => Str ; s3 : Number => Str ; isAux : Bool} ; - TV = TransVerb ; + V2 = TransVerb ; -- = Verb ** {s3 : Preposition} ; V3 = TransVerb ** {s4 : Preposition} ; VS = Verb ; VV = Verb ** {isAux : Bool} ; - AdV = {s : Str ; p : Bool} ; + Adv = {s : Str ; p : Bool} ; S = {s : Str} ; Cl = Clause ; -- = {s : Bool => SForm => Str} ; - Slash = {s : Bool => Str ; s2 : Preposition} ; + Slash = {s : Order => Str ; s2 : Preposition} ; RP = {s : Gender => Number => NPForm => Str} ; RC = {s : Gender => Number => Str} ; IP = {s : NPForm => Str ; n : Number} ; ------ Qu = {s : QuestForm => Str} ; + Qu = {s : QuestForm => Str} ; Imp = {s : Number => Str} ; Phr = {s : Str} ; Text = {s : Str} ; diff --git a/lib/resource/english/MorphoEng.gf b/lib/resource/english/MorphoEng.gf index 33fe593ee..af01bc89a 100644 --- a/lib/resource/english/MorphoEng.gf +++ b/lib/resource/english/MorphoEng.gf @@ -211,5 +211,15 @@ oper contractNot : Str -> Str = \is -> variants {is ++ "not" ; is + "n't"} ; dont = contractNot (verbP3Do.s ! InfImp) ; + +-- From $numerals$. + +param DForm = unit | teen | ten ; +oper mkNum : Str -> Str -> Str -> {s : DForm => Str} = + \two -> \twelve -> \twenty -> + {s = table {unit => two ; teen => twelve ; ten => twenty}} ; +oper regNum : Str -> {s : DForm => Str} = + \six -> mkNum six (six + "teen") (six + "ty") ; + } ; diff --git a/lib/resource/english/NumeralsEng.gf b/lib/resource/english/NumeralsEng.gf new file mode 100644 index 000000000..1c270ff4e --- /dev/null +++ b/lib/resource/english/NumeralsEng.gf @@ -0,0 +1,31 @@ +concrete NumeralsEng of Numerals = open Prelude, MorphoEng in { + +lincat Digit = {s : DForm => Str} ; +lincat Sub10 = {s : DForm => Str} ; + +lin num x = x ; +lin n2 = mkNum "two" "twelve" "twenty" ; +lin n3 = mkNum "three" "thirteen" "thirty" ; +lin n4 = mkNum "four" "fourteen" "forty" ; +lin n5 = mkNum "five" "fifteen" "fifty" ; +lin n6 = regNum "six" ; +lin n7 = regNum "seven" ; +lin n8 = mkNum "eight" "eighteen" "eighty" ; +lin n9 = regNum "nine" ; + +lin pot01 = {s = table {f => "one"}} ; +lin pot0 d = {s = table {f => d.s ! f}} ; +lin pot110 = ss "ten" ; +lin pot111 = ss "eleven" ; +lin pot1to19 d = {s = d.s ! teen} ; +lin pot0as1 n = {s = n.s ! unit} ; +lin pot1 d = {s = d.s ! ten} ; +lin pot1plus d e = {s = d.s ! ten ++ "-" ++ e.s ! unit} ; +lin pot1as2 n = n ; +lin pot2 d = {s = d.s ! unit ++ "hundred"} ; +lin pot2plus d e = {s = d.s ! unit ++ "hundred" ++ "and" ++ e.s} ; +lin pot2as3 n = n ; +lin pot3 n = {s = n.s ++ "thousand"} ; +lin pot3plus n m = {s = n.s ++ "thousand" ++ m.s} ; + +} \ No newline at end of file diff --git a/lib/resource/english/ParadigmsEng.gf b/lib/resource/english/ParadigmsEng.gf new file mode 100644 index 000000000..741464ff9 --- /dev/null +++ b/lib/resource/english/ParadigmsEng.gf @@ -0,0 +1,301 @@ +--# -path=.:../abstract:../../prelude + +--1 English Lexical Paradigms +-- +-- Aarne Ranta 2003 +-- +-- This is an API to the user of the resource grammar +-- for adding lexical items. It give shortcuts for forming +-- expressions of basic categories: nouns, adjectives, verbs. +-- +-- Closed categories (determiners, pronouns, conjunctions) are +-- accessed through the resource syntax API, $Structural.gf$. +-- +-- The main difference with $MorphoEng.gf$ is that the types +-- referred to are compiled resource grammar types. We have moreover +-- had the design principle of always having existing forms, rather +-- than stems, as string +-- arguments of the paradigms. +-- +-- The following modules are presupposed: + +resource ParadigmsEng = open (Predef=Predef), Prelude, SyntaxEng, ResourceEng in { + +--2 Parameters +-- +-- To abstract over gender names, we define the following identifiers. + +oper + Gender : Type ; + + human : Gender ; + nonhuman : Gender ; + +-- To abstract over number names, we define the following. + Number : Type ; + + singular : Number ; + plural : Number ; + +-- To abstract over case names, we define the following. + Case : Type ; + + nominative : Case ; + genitive : Case ; + + +--2 Nouns + +-- Worst case: give all four forms and the semantic gender. +-- In practice the worst case is just: give singular and plural nominative. + +oper + mkN : (man,men,man's,men's : Str) -> Gender -> N ; + nMan : (man,men : Str) -> Gender -> N ; + +-- Regular nouns, nouns ending with "s", "y", or "o", and nouns with the same +-- plural form as the singular. + + nReg : Str -> Gender -> N ; -- dog, dogs + nKiss : Str -> Gender -> N ; -- kiss, kisses + nFly : Str -> Gender -> N ; -- fly, flies + nHero : Str -> Gender -> N ; -- hero, heroes (= nKiss !) + nSheep : Str -> Gender -> N ; -- sheep, sheep + +-- These use general heuristics, that recognizes the last letter. *N.B* it +-- does not get right with "boy", "rush", since it only looks at one letter. + + nHuman : Str -> N ; -- gambler/actress/nanny + nNonhuman : Str -> N ; -- dog/kiss/fly + +-- Nouns used as functions need a preposition. The most common is "of". + + mkN2 : N -> Preposition -> N2 ; + + funHuman : Str -> N2 ; -- the father/mistress/daddy of + funNonhuman : Str -> N2 ; -- the successor/address/copy of + +-- Proper names, with their regular genitive. + + pnReg : (John : Str) -> PN ; -- John, John's + +-- The most common cases on the higher-level category $CN$ have shortcuts. +-- The regular "y"/"s" variation is taken into account. + + cnNonhuman : Str -> CN ; + cnHuman : Str -> CN ; + npReg : Str -> NP ; + +-- In some cases, you may want to make a complex $CN$ into a function. + + mkN2CN : CN -> Preposition -> N2 ; + funOfCN : CN -> N2 ; + + +--2 Adjectives + +-- Non-comparison one-place adjectives just have one form. + + mkA : (even : Str) -> A ; + +-- Two-place adjectives need a preposition as second argument. + + mkA2 : (divisible, by : Str) -> A2 ; + +-- Comparison adjectives have three forms. The common irregular +-- cases are ones ending with "y" and a consonant that is duplicated; +-- the "y" ending is recognized by the function $aReg$. + + mkADeg : (good,better,best : Str) -> ADeg ; + + aReg : (long : Str) -> ADeg ; -- long, longer, longest + aFat : (fat : Str) -> ADeg ; -- fat, fatter, fattest + aRidiculous : (ridiculous : Str) -> ADeg ; -- -/more/most ridiculous + +-- On higher level, there are adjectival phrases. The most common case is +-- just to use a one-place adjective. + + apReg : Str -> AP ; + +--2 Adverbs + +-- Adverbs are not inflected. Most lexical ones have position not +-- before the verb. Some can be preverbal (e.g. "always"). + + mkAdv : Str -> Adv ; + mkAdvPre : Str -> Adv ; + +-- Adverbs modifying adjectives and sentences can also be formed. + + mkAdA : Str -> AdA ; + mkAdS : Str -> AdS ; + +-- Prepositional phrases are another productive form of adverbials. + + mkPP : Str -> NP -> Adv ; + +--2 Verbs +-- +-- The fragment now has all verb forms, except the gerund/present participle. +-- Except for "be", the worst case needs four forms: the infinitive and +-- the third person singular present, the past indicative, and the past participle. + + mkV : (go, goes, went, gone : Str) -> V ; + + vReg : (walk : Str) -> V ; -- walk, walks + vKiss : (kiss : Str) -> V ; -- kiss, kisses + vFly : (fly : Str) -> V ; -- fly, flies + vGo : (go : Str) -> V ; -- go, goes (= vKiss !) + +-- This generic function recognizes the special cases where the last +-- character is "y", "s", or "z". It is not right for "finish" and "convey". + + vGen : Str -> V ; -- walk/kiss/fly + +-- The verbs "be" and "have" are special. + + vBe : V ; + vHave : V ; + +-- Verbs with a particle. + + vPart : (go, goes, went, gone, up : Str) -> V ; + vPartReg : (get, up : Str) -> V ; + +-- Two-place verbs, and the special case with direct object. +-- Notice that a particle can already be included in $V$. + + mkV2 : V -> Str -> V2 ; -- look for, kill + + tvGen : (look, for : Str) -> V2 ; -- look for, talk about + tvDir : V -> V2 ; -- switch off + tvGenDir : (kill : Str) -> V2 ; -- kill + +-- Regular two-place verbs with a particle. + + tvPartReg : Str -> Str -> Str -> V2 ; -- get, along, with + +-- Ditransitive verbs. + + mkV3 : V -> Str -> Str -> V3 ; -- speak, with, about + v3Dir : V -> Str -> V3 ; -- give,_,to + v3DirDir : V -> V3 ; -- give,_,_ + +-- The definitions should not bother the user of the API. So they are +-- hidden from the document. +--. + + Gender = SyntaxEng.Gender ; + Number = SyntaxEng.Number ; + Case = SyntaxEng.Case ; + human = Hum ; + nonhuman = NoHum ; + singular = Sg ; + plural = Pl ; + + nominative = Nom ; + genitive = Nom ; + + mkN = \man,men,man's,men's,g -> + mkNoun man men man's men's ** {g = g ; lock_N = <>} ; + nReg a g = addGenN nounReg a g ; + nKiss n g = addGenN nounS n g ; + nFly = \fly -> addGenN nounY (Predef.tk 1 fly) ; + nMan = \man,men -> mkN man men (man + "'s") (men + "'s") ; + nHero = nKiss ; + nSheep = \sheep -> nMan sheep sheep ; + + nHuman = \s -> nGen s Hum ; + nNonhuman = \s -> nGen s NoHum ; + + nGen : Str -> Gender -> N = \fly,g -> let { + fl = Predef.tk 1 fly ; + y = Predef.dp 1 fly ; + eqy = ifTok (Str -> Gender -> N) y + } in + eqy "y" nFly ( + eqy "s" nKiss ( + eqy "z" nKiss ( + nReg))) fly g ; + + mkN2 = \n,p -> n ** {lock_N2 = <> ; s2 = p} ; + funNonhuman = \s -> mkN2 (nNonhuman s) "of" ; + funHuman = \s -> mkN2 (nHuman s) "of" ; + + pnReg n = nameReg n ** {lock_PN = <>} ; + + cnNonhuman = \s -> UseN (nGen s nonhuman) ; + cnHuman = \s -> UseN (nGen s human) ; + npReg = \s -> UsePN (pnReg s) ; + + mkN2CN = \n,p -> n ** {lock_N2 = <> ; s2 = p} ; + funOfCN = \n -> mkN2CN n "of" ; + + addGenN : (Str -> CommonNoun) -> Str -> Gender -> N = \f -> + \s,g -> f s ** {g = g ; lock_N = <>} ; + + mkA a = regAdjective a ** {lock_A = <>} ; + mkA2 = \s,p -> regAdjective s ** {s2 = p} ** {lock_A2 = <>} ; + mkADeg a b c = adjDegrIrreg a b c ** {lock_ADeg = <>} ; + aReg a = adjDegrReg a ** {lock_ADeg = <>} ; + aFat = \fat -> let {fatt = fat + Predef.dp 1 fat} in + mkADeg fat (fatt + "er") (fatt + "est") ; + aRidiculous a = adjDegrLong a ** {lock_ADeg = <>} ; + apReg = \s -> UseA (mkA s) ; + + aGen : Str -> ADeg = \s -> case last s of { + "y" => mkADeg s (init s + "ier") (init s + "iest") ; + "e" => mkADeg s (s + "r") (s + "st") ; + _ => aReg s + } ; + + mkAdv a = advPost a ** {lock_Adv = <>} ; + mkAdvPre a = advPre a ** {lock_Adv = <>} ; + mkPP x y = prepPhrase x y ** {lock_Adv = <>} ; + mkAdA a = ss a ** {lock_AdA = <>} ; + mkAdS a = ss a ** {lock_AdS = <>} ; + + mkV = \go,goes,went,gone -> verbNoPart (mkVerbP3 go goes went gone) ** + {lock_V = <>} ; + vReg = \walk -> mkV walk (walk + "s") (walk + "ed") (walk + "ed") ; + vKiss = \kiss -> mkV kiss (kiss + "es") (kiss + "ed") (kiss + "ed") ; + vFly = \cry -> let {cr = Predef.tk 1 cry} in + mkV cry (cr + "ies") (cr + "ied") (cr + "ied") ; + vGo = vKiss ; + + vGen = \fly -> let { + fl = Predef.tk 1 fly ; + y = Predef.dp 1 fly ; + eqy = ifTok (Str -> V) y + } in + eqy "y" vFly ( + eqy "s" vKiss ( + eqy "z" vKiss ( + vReg))) fly ; + + vPart = \go, goes, went, gone, up -> + verbPart (mkVerbP3 go goes went gone) up ** {lock_V = <>} ; + vPartReg = \get, up -> + verbPart (vGen get) up ** {lock_V = <>} ; + + mkV2 = \v,p -> v ** {lock_V2 = <> ; s3 = p} ; + tvPartReg = \get, along, to -> mkV2 (vPartReg get along) to ; + + vBe = verbBe ** {s1 = [] ; lock_V = <>} ; + vHave = verbP3Have ** {s1 = [] ; lock_V = <>} ; + + tvGen = \s,p -> mkV2 (vGen s) p ; + tvDir = \v -> mkV2 v [] ; + tvGenDir = \s -> tvDir (vGen s) ; + + mkV3 x y z = mkDitransVerb x y z ** {lock_V3 = <>} ; + v3Dir x y = mkV3 x [] y ; + v3DirDir x = v3Dir x [] ; + + -- these are used in the generated lexicon + noun : Str -> N = nNonhuman ; + + verb2 : Str -> Str -> V2 = \v -> mkV2 (vGen v) ; + verb3 : Str -> Str -> Str -> V3 = \v -> mkV3 (vGen v) ; + +} ; diff --git a/lib/resource/english/ResourceEng.gf b/lib/resource/english/ResourceEng.gf new file mode 100644 index 000000000..0979c39cd --- /dev/null +++ b/lib/resource/english/ResourceEng.gf @@ -0,0 +1,3 @@ +--# -path=.:../abstract:../../prelude + +instance ResourceEng of Resource = reuse AllResourceEng ; diff --git a/lib/resource/english/RulesEng.gf b/lib/resource/english/RulesEng.gf index 79dc469a7..9f61b3184 100644 --- a/lib/resource/english/RulesEng.gf +++ b/lib/resource/english/RulesEng.gf @@ -68,25 +68,26 @@ lin PredV = predVerb ; PredAP = predAdjective ; + PredSuperl a = predAdjective (superlAdjPhrase a) ; PredCN = predCommNoun ; ------ PredV2 = complTransVerb ; + PredV2 = complTransVerb ; PredV3 = complDitransVerb ; PredPassV = passVerb ; PredNP = predNounPhrase ; ------ PredPP = predAdverb ; + PredPP = predAdverb ; PredVS = complSentVerb ; PredVV = complVerbVerb ; ------ VTrans = transAsVerb ; + VTrans = transAsVerb ; AdjAdv a = advPost (a.s ! AAdv) ; - AdvPP p = p ; + AdvPP p = advPost p.s ; PrepNP p = prepPhrase p.s ; --- ------ AdvVP = adVerbPhrase ; ------ AdvCN = advCommNounPhrase ; + AdvVP = adVerbPhrase ; + AdvCN = advCommNounPhrase ; AdvAP = advAdjPhrase ; -} {- ----- - PosSlashTV = slashTransVerb True ; - NegSlashTV = slashTransVerb False ; + + PosSlashV2 = slashTransVerb True ; + NegSlashV2 = slashTransVerb False ; OneVP = predVerbPhrase (nameNounPhrase (nameReg "one")) ; ThereNP = thereIs ; @@ -118,6 +119,7 @@ lin ImperOne = imperUtterance singular ; ImperMany = imperUtterance plural ; + PrepS p = ss (p.s ++ ",") ; AdvS = advSentence ; TwoS = twoSentence ; @@ -150,4 +152,3 @@ lin ConsPhr = cc2 ; } ; --} \ No newline at end of file diff --git a/lib/resource/english/StructuralEng.gf b/lib/resource/english/StructuralEng.gf index 97f9667d2..d77acf5e3 100644 --- a/lib/resource/english/StructuralEng.gf +++ b/lib/resource/english/StructuralEng.gf @@ -5,7 +5,7 @@ -- Aarne Ranta 2002 -- 2003 -- concrete StructuralEng of Structural = - CategoriesEng ** open Prelude, SyntaxEng in { + CategoriesEng, NumeralsEng ** open Prelude, SyntaxEng in { lin INP = pronI ; ThouNP = pronYouSg ; @@ -16,12 +16,16 @@ concrete StructuralEng of Structural = YeNumNP = pronWithNum pronYouPl ; YouNP = pronYouSg ; TheyNP = pronThey ; + TheyFemNP = pronThey ; EveryDet = everyDet ; AllMassDet = mkDeterminer Sg "all" ; --- all the missing AllNumDet = mkDeterminerNum Pl "all" ; WhichDet = whichDet ; WhichNumDet = mkDeterminerNum Pl "which" ; + + UseNumeral i = {s = table {Nom => i.s ; Gen => i.s ++ "'s"}} ; --- + MostsDet = mostDet ; MostDet = mkDeterminer Sg "most" ; SomeDet = mkDeterminer Sg "some" ; @@ -31,6 +35,7 @@ concrete StructuralEng of Structural = NoDet = mkDeterminer Sg "no" ; NoNumDet = mkDeterminerNum Pl "no" ; ManyDet = mkDeterminer Pl "many" ; + HowManyDet = mkDeterminer Pl ["how many"] ; MuchDet = mkDeterminer Sg ["a lot of"] ; --- ThisDet = mkDeterminer Sg "this" ; TheseNumDet = mkDeterminerNum Pl "these" ; diff --git a/lib/resource/english/SyntaxEng.gf b/lib/resource/english/SyntaxEng.gf index 901d2b7a8..d394b55c9 100644 --- a/lib/resource/english/SyntaxEng.gf +++ b/lib/resource/english/SyntaxEng.gf @@ -192,6 +192,13 @@ oper p = P3 } ; +-- Moreover, superlatives can be used alone as adjectival phrases +-- ("the youngest" - in free variation). + + superlAdjPhrase : AdjDegr -> AdjPhrase = \big -> + {s = \\a => "the" ++ big.s ! Sup ! a ; + p = True + } ; --3 Two-place adjectives -- @@ -298,10 +305,12 @@ oper Tense = Present | Past ; Anteriority = Simul | Anter ; + Order = Direct | Indirect ; VPForm = VIndic Tense Anteriority Number Person | VFut Anteriority | VCondit Anteriority + | VQuest Tense Number Person --- needed for "do" inversions | VImperat | VInfinit Anteriority ; @@ -324,6 +333,11 @@ oper => "have" ; => "had" } ; + do : Tense -> Number -> Person -> Str = \t,n,p -> case of { + => "does" ; + => "do" ; + => "did" + } ; simple : VForm -> {fin,inf : Str} = \v -> { fin = goes.s ! v ; inf = [] @@ -337,6 +351,7 @@ oper in case sf of { VIndic t Simul n p => simple (tense t n p) ; VIndic t Anter n p => compound (have t n p) gone ; + VQuest t n p => compound (do Present n p) go ; VFut Simul => compound "will" go ; VFut Anter => compound "will" ("have" ++ gone) ; VCondit Simul => compound "would" go ; @@ -381,11 +396,16 @@ oper has : VPForm => Str = \\f => (go f).fin ; gone : VPForm => Str = \\f => (go f).inf in { - s = \\_ => has ; - s2 = table { - True => gone ; - False => \\vf => "not" ++ gone ! vf + s = \\b => + table { + VQuest t n p => has ! VIndic t Simul n p ; --- undo "do" inversion + vf => has ! vf } ; + s2 = \\b => let not = if_then_Str b [] "not" in + table { + VQuest t n p => not ++ gone ! VIndic t Simul n p ; + vf => not ++ gone ! vf + } ; s3 = arg ; isAux = True } ; @@ -452,7 +472,7 @@ oper predNounPhrase : NounPhrase -> VerbGroup = \john -> beGroup (\\_ => john.s ! NomP) ; - predAdverb : Adverb -> VerbGroup = \elsewhere -> + predAdverb : PrepPhrase -> VerbGroup = \elsewhere -> beGroup (\\_ => elsewhere.s) ; @@ -561,13 +581,15 @@ oper locativeNounPhrase : NounPhrase -> Adverb = prepPhrase "in" ; --- This is a source of the "mann with a telescope" ambiguity, and may produce + PrepPhrase = SS ; + +-- This is a source of the "man with a telescope" ambiguity, and may produce -- strange things, like "cars always" (while "cars today" is OK). -- Semantics will have to make finer distinctions among adverbials. -- -- N.B. the genitive case created in this way would not make sense. - advCommNounPhrase : CommNounPhrase -> Adverb -> CommNounPhrase = \car,today -> + advCommNounPhrase : CommNounPhrase -> PrepPhrase -> CommNounPhrase = \car,today -> {s = \\n => table { Nom => car.s ! n ! Nom ++ today.s ; Gen => nonExist @@ -601,31 +623,39 @@ oper param ClForm = - ClIndic Tense Anteriority - | ClFut Anteriority - | ClCondit Anteriority + ClIndic Order Tense Anteriority + | ClFut Order Anteriority + | ClCondit Order Anteriority | ClInfinit Anteriority -- "naked infinitive" clauses ; oper - cl2s : ClForm -> Number -> Person -> VPForm = \c,n,p -> case c of { - ClIndic t a => VIndic t a n p ; - ClFut a => VFut a ; - ClCondit a => VCondit a ; - ClInfinit a => VInfinit a + cl2s : ClForm -> Number -> Person -> {form : VPForm ; order : Order} = \c,n,p -> case c of { + ClIndic Indirect t Simul => {form = VQuest t n p ; order = Indirect} ; + ClIndic o t a => {form = VIndic t a n p ; order = o} ; + ClFut o a => {form = VFut a ; order = o} ; + ClCondit o a => {form = VCondit a ; order = o} ; + ClInfinit a => {form = VInfinit a ; order = Direct} --- order does not matter } ; Clause = {s : Bool => ClForm => Str} ; predVerbGroupClause : NounPhrase -> VerbGroup -> Clause = - \you,sleep -> { + \yo,sleep -> { s = \\b,c => let - n = you.n ; - cf = cl2s c n you.p + n = yo.n ; + cfo = cl2s c n yo.p ; + cf = cfo.form ; + o = cfo.order ; + you = yo.s ! NomP ; + do = sleep.s ! b ! cf ; + sleeps = sleep.s2 ! b ! cf ++ sleep.s3 ! n in - you.s ! NomP ++ sleep.s ! b ! cf ++ sleep.s2 ! b ! cf ++ - sleep.s3 ! n + case o of { + Direct => you ++ do ++ sleeps ; + Indirect => do ++ you ++ sleeps + } } ; --3 Sentence-complement verbs @@ -685,7 +715,7 @@ oper 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 -- -- This is one instance of Gazdar's *slash categories*, corresponding to his @@ -700,25 +730,26 @@ oper -- -- The particle always follows the verb, but the preposition can fly: -- "whom you make it up with" / "with whom you make it up". +--- We reduce the current case to a more general one that has tense variation. +--- TODO: full tense variation on top level. - SentenceSlashNounPhrase = {s : Bool => Str ; s2 : Preposition} ; + SentenceSlashNounPhrase = {s : Order => Str ; s2 : Preposition} ; + ClauseSlashNounPhrase = Clause ** {s2 : Preposition} ; slashTransVerb : Bool -> NounPhrase -> TransVerb -> SentenceSlashNounPhrase = - \b,You,lookat -> - let {you = You.s ! NomP ; - looks = indicVerb {s = lookat.s} You.p You.n ; - look = lookat.s ! InfImp ; - do = indicVerb verbP3Do You.p You.n ; - dont = contractNot do ; - up = lookat.s1 - } in - {s = table { - True => if_then_else Str b do dont ++ you ++ look ++ up ; - False => you ++ if_then_else Str b looks (dont ++ look) ++ up - } ; - s2 = lookat.s3 - } ; + \pol,You,lookat -> + let + youlookat = slashTransVerbCl You lookat + in { + s = \\o => youlookat.s ! pol ! ClIndic o Present Simul ; + s2 = youlookat.s2 + } ; + slashTransVerbCl : NounPhrase -> TransVerb -> ClauseSlashNounPhrase = + \you,lookat -> + predVerbGroupClause you (predVerb lookat) ** {s2 = lookat.s3} ; + +--- TODO: "there is" with tense variation. thereIs : NounPhrase -> Sentence = \abar -> predVerbPhrase @@ -729,6 +760,7 @@ oper (predVerbGroup True (predNounPhrase abar)) ; + --2 Relative pronouns and relative clauses -- -- As described in $types.Eng.gf$, relative pronouns are inflected in @@ -744,19 +776,24 @@ oper mother.s2 ++ which.s ! g ! n ! GenSP } ; +-- An auxiliary that allows the use of predication with relative pronouns. + + relNounPhrase : RelPron -> Gender -> Number -> NounPhrase = \who,g,n -> + {s = who.s ! g ! n ; n = n ; p = P3} ; + -- Relative clauses can be formed from both verb phrases ("who walks") and -- slash expressions ("whom you see", "on which you sit" / "that you sit on"). RelClause : Type = {s : Gender => Number => Str} ; relVerbPhrase : RelPron -> VerbPhrase -> RelClause = \who,walks -> - {s = \\g, n => who.s ! g ! n ! NomP ++ - indicVerb (verbOfPhrase walks) P3 n ++ walks.s2 ! n - } ; + {s = \\g,n => (predVerbPhrase (relNounPhrase who g n) walks).s} ; + +--- TODO: full tense variation in relative clauses. relSlash : RelPron -> SentenceSlashNounPhrase -> RelClause = \who,yousee -> {s = \\g,n => - let {youSee = yousee.s ! False} in + let {youSee = yousee.s ! Direct} in variants { who.s ! g ! n ! AccP ++ youSee ++ yousee.s2 ; yousee.s2 ++ who.s ! g ! n ! GenSP ++ youSee @@ -778,7 +815,6 @@ oper g = man.g } ; - --2 Interrogative pronouns -- -- If relative pronouns are adjective-like, interrogative pronouns are @@ -850,6 +886,8 @@ param oper Question = SS1 QuestForm ; +--- TODO: questions in all tenses. + --3 Yes-no questions -- -- Yes-no questions are used both independently @@ -865,15 +903,17 @@ oper questVerbPhrase' False ; questVerbPhrase' : Bool -> NounPhrase -> VerbPhrase -> Question = - \adv,john,walk -> + \adv,John,walk -> + let + john = John.s ! NomP + in {s = table { - DirQ => if_then_else Str walk.isAux - (indicVerb (verbOfPhrase walk) john.p john.n ++ - john.s ! NomP ++ walk.s2 ! john.n) - (indicVerb verbP3Do john.p john.n ++ - john.s ! NomP ++ walk.s ! InfImp ++ walk.s2 ! john.n) ; + DirQ => walk.s ! VQuest Present John.n John.p ++ + john ++ + walk.s2 ! VQuest Present John.n John.p ++ + walk.s3 ! John.n ; IndirQ => if_then_else Str adv [] (variants {"if" ; "whether"}) ++ - (predVerbPhrase john walk).s + (predVerbPhrase John walk).s } } ; @@ -885,22 +925,20 @@ oper }) (predVerbGroup True (predNounPhrase abar)) ; - --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 = \who,walk -> - {s = \\_ => who.s ! NomP ++ indicVerb (verbOfPhrase walk) P3 who.n ++ - walk.s2 ! who.n + {s = \\_ => who.s ! NomP ++ presentIndicative walk who.n P3 } ; intSlash : IntPron -> SentenceSlashNounPhrase -> Question = \who,yousee -> {s = \\q => let {youSee = case q of { - DirQ => yousee.s ! True ; - IndirQ => yousee.s ! False + DirQ => yousee.s ! Indirect ; + IndirQ => yousee.s ! Direct } } in variants { @@ -909,9 +947,9 @@ oper } } ; ---3 Interrogative adverbials +--3 Interrogative adverbs -- --- These adverbials will be defined in the lexicon: they include +-- These adverbs will be defined in the lexicon: they include -- "when", "where", "how", "why", 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 @@ -929,7 +967,6 @@ oper \why, you, walk -> {s = \\q => why.s ++ (questVerbPhrase' True you walk).s ! q} ; - --2 Imperatives -- -- We only consider second-person imperatives. @@ -937,14 +974,14 @@ oper Imperative = SS1 Number ; imperVerbPhrase : VerbPhrase -> Imperative = \walk -> - {s = \\n => walk.s ! InfImp ++ walk.s2 ! n} ; + {s = \\n => walk.s ! VImperat ++ walk.s2 ! VImperat ++ walk.s3 ! n} ; imperUtterance : Number -> Imperative -> Utterance = \n,I -> ss (I.s ! n ++ "!") ; ---2 Sentence adverbials +--2 Sentence adverbs -- --- This class covers adverbials such as "otherwise", "therefore", which are prefixed +-- This class covers adverbs such as "otherwise", "therefore", which are prefixed -- to a sentence to form a phrase. advSentence : SS -> Sentence -> Utterance = \hence,itiseven -> @@ -1119,4 +1156,3 @@ oper x ; } ; --} \ No newline at end of file diff --git a/lib/resource/english/TestResourceEng.gf b/lib/resource/english/TestResourceEng.gf index 6159aebed..6ed98bd82 100644 --- a/lib/resource/english/TestResourceEng.gf +++ b/lib/resource/english/TestResourceEng.gf @@ -1,9 +1,7 @@ --# -path=.:../abstract:../../prelude concrete TestResourceEng of TestResource = RulesEng, StructuralEng ** -{} -{- ----- -open SyntaxEng, ParadigmsEng in { + open SyntaxEng, ParadigmsEng in { flags startcat=Phr ; lexer=textlit ; parser=chart ; unlexer=text ; @@ -51,4 +49,3 @@ lin Mary = nameReg "Mary" ; } ; --} \ No newline at end of file