diff --git a/lib/resource/english/CategoriesEng.gf b/lib/resource/english/CategoriesEng.gf index 5a024a073..231b8368d 100644 --- a/lib/resource/english/CategoriesEng.gf +++ b/lib/resource/english/CategoriesEng.gf @@ -48,9 +48,8 @@ lincat V = Verb ; -- = {s : VForm => Str ; s1 : Particle} - VG = {s : Bool => SForm => Str ; s2 : Bool => Number => Str ; - isAuxT, isAuxF : Bool} ; - VP = {s : SForm => Str ; s2 : Number => Str ; isAux : Bool} ; + VG = {s,s2 : Bool => VPForm => Str ; s3 : Number => Str ; isAux : Bool} ; + VP = {s,s2 : VPForm => Str ; s3 : Number => Str ; isAux : Bool} ; TV = TransVerb ; -- = Verb ** {s3 : Preposition} ; V3 = TransVerb ** {s4 : Preposition} ; @@ -67,7 +66,7 @@ lincat 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/Rules.gf b/lib/resource/english/RulesEng.gf similarity index 63% rename from lib/resource/english/Rules.gf rename to lib/resource/english/RulesEng.gf index 15c78277a..79dc469a7 100644 --- a/lib/resource/english/Rules.gf +++ b/lib/resource/english/RulesEng.gf @@ -19,78 +19,26 @@ -- one has to know how the syntactic categories are -- implemented. The parameter types are defined in $TypesEng.gf$. -concrete CombinationsEng of Combinations = open Prelude, SyntaxEng in { +concrete RulesEng of Rules = CategoriesEng ** open Prelude, SyntaxEng in { flags startcat=Phr ; lexer=text ; unlexer=text ; -lincat - N = CommNoun ; - -- = {s : Number => Case => Str} - CN = CommNounPhrase ; - -- = CommNoun ** {g : Gender} - NP = {s : NPForm => Str ; n : Number ; p : Person} ; - PN = {s : Case => Str} ; - Det = {s : Str ; n : Number} ; - Fun = Function ; - -- = CommNounPhrase ** {s2 : Preposition} ; - Fun2 = Function ** {s3 : Preposition} ; - Num = {s : Case => Str} ; - - Adj1 = Adjective ; - -- = {s : AForm => Str} - Adj2 = Adjective ** {s2 : Preposition} ; - AdjDeg = {s : Degree => AForm => Str} ; - AP = Adjective ** {p : Bool} ; - - V = Verb ; - -- = {s : VForm => Str ; s1 : Particle} - VG = {s : Bool => VForm => Str ; s2 : Bool => Number => Str ; - isAuxT, isAuxF : Bool} ; - VP = {s : VForm => Str ; s2 : Number => Str ; isAux : Bool} ; - TV = TransVerb ; - -- = Verb ** {s3 : Preposition} ; - V3 = TransVerb ** {s4 : Preposition} ; - VS = Verb ; - VV = Verb ** {isAux : Bool} ; - - AdV = {s : Str ; p : Bool} ; - - S = {s : Str} ; - Slash = {s : Bool => Str ; s2 : Preposition} ; - RP = {s : Gender => Number => NPForm => Str} ; - RC = {s : Gender => Number => Str} ; - - IP = {s : NPForm => Str ; n : Number} ; - Qu = {s : QuestForm => Str} ; - Imp = {s : Number => Str} ; - Phr = {s : Str} ; - Text = {s : Str} ; - - Conj = {s : Str ; n : Number} ; - ConjD = {s1 : Str ; s2 : Str ; n : Number} ; - - ListS = {s1 : Str ; s2 : Str} ; - ListAP = {s1,s2 : AForm => Str ; p : Bool} ; - ListNP = {s1,s2 : NPForm => Str ; n : Number ; p : Person} ; - ---. - lin UseN = noun2CommNounPhrase ; - ModAdj = modCommNounPhrase ; + ModAP = modCommNounPhrase ; ModGenOne = npGenDet singular noNum ; ModGenNum = npGenDet plural ; UsePN = nameNounPhrase ; - UseFun = funAsCommNounPhrase ; - AppFun = appFunComm ; - AppFun2 = appFun2 ; - AdjP1 = adj2adjPhrase ; - ComplAdj = complAdj ; - PositAdjP = positAdjPhrase ; - ComparAdjP = comparAdjPhrase ; + UseN2 = funAsCommNounPhrase ; + AppN2 = appFunComm ; + AppN3 = appFun2 ; + UseA = adj2adjPhrase ; + ComplA2 = complAdj ; + PositADeg = positAdjPhrase ; + ComparADeg = comparAdjPhrase ; SuperlNP = superlNounPhrase ; DetNP = detNounPhrase ; @@ -108,29 +56,35 @@ lin SymbCN cn s = {s = \\n,c => cn.s ! n ! c ++ s.s ; g = cn.g} ; + IntCN cn s = + {s = \\n,c => cn.s ! n ! c ++ s.s ; + g = cn.g} ; PredVP = predVerbPhrase ; PosVG = predVerbGroup True ; NegVG = predVerbGroup False ; + PredVG = predVerbGroupClause ; + PredV = predVerb ; PredAP = predAdjective ; PredCN = predCommNoun ; - PredTV = complTransVerb ; +----- PredV2 = complTransVerb ; PredV3 = complDitransVerb ; PredPassV = passVerb ; PredNP = predNounPhrase ; - PredAdV = predAdverb ; +----- PredPP = predAdverb ; PredVS = complSentVerb ; PredVV = complVerbVerb ; - VTrans = transAsVerb ; +----- VTrans = transAsVerb ; AdjAdv a = advPost (a.s ! AAdv) ; + AdvPP p = p ; PrepNP p = prepPhrase p.s ; --- - AdvVP = adVerbPhrase ; - AdvCN = advCommNounPhrase ; +----- AdvVP = adVerbPhrase ; +----- AdvCN = advCommNounPhrase ; AdvAP = advAdjPhrase ; - +} {- ----- PosSlashTV = slashTransVerb True ; NegSlashTV = slashTransVerb False ; OneVP = predVerbPhrase (nameNounPhrase (nameReg "one")) ; @@ -196,3 +150,4 @@ lin ConsPhr = cc2 ; } ; +-} \ No newline at end of file diff --git a/lib/resource/english/StructuralEng.gf b/lib/resource/english/StructuralEng.gf index 261d65fa0..97f9667d2 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 = - CombinationsEng ** open Prelude, SyntaxEng in { + CategoriesEng ** open Prelude, SyntaxEng in { lin INP = pronI ; ThouNP = pronYouSg ; diff --git a/lib/resource/english/SyntaxEng.gf b/lib/resource/english/SyntaxEng.gf index 6a2564642..901d2b7a8 100644 --- a/lib/resource/english/SyntaxEng.gf +++ b/lib/resource/english/SyntaxEng.gf @@ -324,11 +324,6 @@ 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 = [] @@ -351,18 +346,61 @@ oper VInfinit Anter => compound "have" gone } ; - - -} ; -{- useVerb : Verb -> (Number => Str) -> VerbGroup = \verb,arg -> - let go = verbVPForm go + let + go = verbVPForm verb ; + off = verb.s1 ; + has : VPForm => Str = \\f => (go f).fin ; + gone : VPForm => Str = \\f => (go f).inf ++ off in { - s = \\b,vf => (go sf).fin ; - s2 = \\b,vf => (go sf).inf ; - s3 = arg + s = table { + True => has ; + False => table { + VIndic t Simul n p => auxDo t n p ; + VImperat => auxDo Present Sg P2 ; + VInfinit a => "not" ++ has ! VInfinit a ; + vf => has ! vf + } + } ; + s2 = table { + True => gone ; + False => table { + VIndic t Simul n p => "not" ++ has ! VInfinit Simul ++ off ; + VImperat => "not" ++ has ! VInfinit Simul ++ off ; + VInfinit a => gone ! VInfinit a ; + vf => "not" ++ gone ! vf + } + } ; + s3 = arg ; + isAux = False } ; + useVerbAux : Verb -> (Number => Str) -> VerbGroup = \verb,arg -> + let + go = verbVPForm verb ; + 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 + } ; + s3 = arg ; + isAux = True + } ; + + auxDo : Tense -> Number -> Person -> Str = \t,n,p -> case of { + => "does" ; + => "do" ; + => "did" + } ; + + beGroup : (Number => Str) -> VerbGroup = + useVerbAux (verbBe ** {s1 = []}) ; + +---- TODO: the contracted forms. + -- Verb phrases are discontinuous: the three parts of a verb phrase are -- (s) an inflected verb, (s2) infinitive or participle, and (s3) complement. -- For instance: "doesn't" - "walk" - ""; "hasn't" - "been" - "old". @@ -383,11 +421,13 @@ oper isAux : Bool ; } ; +-- All negative verb phrase behave as auxiliary ones in questions. + predVerbGroup : Bool -> VerbGroup -> VerbPhrase = \b,vg -> { s = vg.s ! b ; s2 = vg.s2 ! b ; s3 = vg.s3 ; - isAux = vg.isAux + isAux = orB (notB b) vg.isAux } ; -- A simple verb can be made into a verb phrase with an empty complement. @@ -396,18 +436,7 @@ oper -- double negations with "don't" are not grammatical. predVerb : Verb -> VerbGroup = \walk -> - {s = \\b,v => if_then_Str b - (walk.s ! v ++ walk.s1) - (contractNot (verbP3Do.s ! v)) ; - s2 = \\b,_ => if_then_Str b - [] - (walk.s ! InfImp ++ walk.s1) ; - isAux = False - } ; - --- Sometimes we want to extract the verb part of a verb phrase. - - verbOfPhrase : VerbPhrase -> VerbP3 = \v -> {s = v.s} ; + useVerb walk (\\_ => []) ; -- Verb phrases can also be formed from adjectives ("is old"), -- common nouns ("is a man"), and noun phrases ("ist John"). @@ -415,39 +444,17 @@ oper -- on semantic grounds. predAdjective : Adjective -> VerbGroup = \old -> - {s = beOrNotBe ; - s2 = \\_,_ => old.s ! AAdj ; - isAux = True - } ; + beGroup (\\_ => old.s ! AAdj) ; predCommNoun : CommNoun -> VerbGroup = \man -> - {s = beOrNotBe ; - s2 = \\_,n => indefNoun n man ; - isAux = True - } ; + beGroup (\\n => indefNoun n man) ; predNounPhrase : NounPhrase -> VerbGroup = \john -> - {s = beOrNotBe ; - s2 = \\_,_ => john.s ! NomP ; - isAux = True - } ; + beGroup (\\_ => john.s ! NomP) ; predAdverb : Adverb -> VerbGroup = \elsewhere -> - {s = beOrNotBe ; - s2 = \\_,_ => elsewhere.s ; - isAux = True - } ; + beGroup (\\_ => elsewhere.s) ; --- We use an auxiliary giving all forms of "be". - - beOrNotBe : Bool => VForm => Str = \\b => - if_then_else (VForm => Str) b - verbBe.s - (table { - InfImp => contractNot "do" ++ "be" ; - Indic P1 => "am" ++ "not" ; - v => contractNot (verbBe.s ! v) - }) ; --3 Transitive verbs -- @@ -461,25 +468,24 @@ oper -- The rule for using transitive verbs is the complementization rule. -- Particles produce free variation: before or after the complement --- ("I switch on the TV" / "I switch the TV on"). - - complTransVerb : TransVerb -> NounPhrase -> VerbGroup = \lookat,john -> - let lookatjohn = bothWays lookat.s1 (lookat.s3 ++ john.s ! AccP) - in {s = \\b,v => if_then_Str b (lookat.s ! v) (contractNot (verbP3Do.s ! v)) ; - s2 = \\b,_ => if_then_Str b lookatjohn (lookat.s ! InfImp ++ lookatjohn) ; - isAux = False - } ; +-- ("I switch on the radio" / "I switch the radio on"). +---- TODO: do this again. + complTransVerb : TransVerb -> NounPhrase -> VerbGroup = \switch,radio -> + useVerb switch (\\_ => switch.s3 ++ radio.s ! AccP) ; -- Verbs that take direct object and a particle: + mkTransVerbPart : VerbP3 -> Str -> TransVerb = \turn,off -> {s = turn.s ; s1 = off ; s3 = []} ; -- Verbs that take prepositional object, no particle: + mkTransVerb : VerbP3 -> Str -> TransVerb = \wait,for -> {s = wait.s ; s1 = [] ; s3 = for} ; -- Verbs that take direct object, no particle: + mkTransVerbDir : VerbP3 -> TransVerb = \love -> mkTransVerbPart love [] ; @@ -496,7 +502,6 @@ oper --- reflTransVerb : TransVerb -> VerbGroup = \love -> - -- Transitive verbs can be used elliptically as verbs. The semantics -- is left to applications. The definition is trivial, due to record -- subtyping. @@ -505,8 +510,8 @@ oper 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. +---- TODO: We treat so far only the rule in which the ditransitive +---- verb takes both complements to form a verb phrase. DitransVerb = TransVerb ** {s4 : Preposition} ; @@ -515,18 +520,12 @@ oper complDitransVerb : DitransVerb -> NounPhrase -> NounPhrase -> VerbGroup = \give,you,beer -> - let - youbeer = give.s1 ++ give.s3 ++ you.s ! AccP ++ give.s4 ++ beer.s ! AccP - in - {s = \\b,v => if_then_Str b (give.s ! v) (contractNot (verbP3Do.s ! v)) ; - s2 = \\b,_ => if_then_Str b youbeer (give.s ! InfImp ++ youbeer) ; - isAux = False - } ; + useVerb give + (\\_ => give.s1 ++ give.s3 ++ you.s ! AccP ++ give.s4 ++ beer.s ! AccP) ; - ---2 Adverbials +--2 Adverbs -- --- Adverbials are not inflected (we ignore comparison, and treat +-- Adverbs are not inflected (we ignore comparison, and treat -- compared adverbials as separate expressions; this could be done another way). -- We distinguish between post- and pre-verbal adverbs. @@ -543,6 +542,7 @@ oper { s = \\v => (if_then_else Str postp [] well.s) ++ sings.s ! v ; s2 = \\n => sings.s2 ! n ++ (if_then_else Str postp well.s []) ; + s3 = sings.s3 ; isAux = sings.isAux } ; @@ -575,7 +575,6 @@ oper g = car.g } ; - --2 Sentences -- -- Sentences are not inflected in this fragment of English without tense. @@ -587,10 +586,47 @@ oper -- contain negation. predVerbPhrase : NounPhrase -> VerbPhrase -> Sentence = \john,walks -> - ss (john.s ! NomP ++ indicVerb (verbOfPhrase walks) john.p john.n ++ - walks.s2 ! john.n) ; + ss ( + john.s ! NomP ++ + presentIndicative walks john.n john.p + ) ; + presentIndicative : VerbPhrase -> Number -> Person -> Str = \sleep,n,p -> + let + cf = VIndic Present Simul n p + in + sleep.s ! cf ++ sleep.s2 ! cf ++ sleep.s3 ! n ; +--3 Tensed clauses + + param + ClForm = + ClIndic Tense Anteriority + | ClFut Anteriority + | ClCondit 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 + } ; + + Clause = {s : Bool => ClForm => Str} ; + + predVerbGroupClause : NounPhrase -> VerbGroup -> Clause = + \you,sleep -> { + s = \\b,c => + let + n = you.n ; + cf = cl2s c n you.p + in + you.s ! NomP ++ sleep.s ! b ! cf ++ sleep.s2 ! b ! cf ++ + sleep.s3 ! n + } ; --3 Sentence-complement verbs -- @@ -599,13 +635,11 @@ oper SentenceVerb : Type = Verb ; -- To generate "says that John walks" / "doesn't say that John walks": +---- TODO: the alternative without "that" complSentVerb : SentenceVerb -> Sentence -> VerbGroup = \say,johnruns -> - let {thatjohnruns = optStr "that" ++ johnruns.s} in - {s = \\b,v => if_then_Str b (say.s ! v) (contractNot (verbP3Do.s ! v)) ; - s2 = \\b,_ => if_then_Str b thatjohnruns (say.s ! InfImp ++ thatjohnruns) ; - isAux = False - } ; + useVerb say (\\_ => "that" ++ johnruns.s) ; + --3 Verb-complement verbs -- @@ -627,22 +661,13 @@ oper let taux = try.isAux ; to = if_then_Str taux [] "to" ; - dont = table VForm {v => if_then_Str taux - (try.s ! v ++ "not") -- can not - (contractNot (verbP3Do.s ! v)) -- doesn't ... - } ; - trnot = if_then_Str taux - [] -- - (try.s ! InfImp ++ try.s1) ; -- ... try + torun : Number => Str = + \\n => to ++ run.s ! True ! VInfinit Simul ++ + run.s2 ! True ! VInfinit Simul ++ run.s3 ! n in - {s = \\b,v => if_then_Str b - (try.s ! v ++ try.s1 ++ to ++ run.s ! True ! InfImp) - (dont ! v) ; - s2 = \\b,v => if_then_Str b - (run.s2 ! True ! v) - (trnot ++ run.s ! True ! InfImp ++ run.s2 ! True ! v) ; - isAux = taux - } ; + if_then_else VerbGroup taux + (useVerb try torun) + (useVerbAux try torun) ; -- The three most important example auxiliaries. @@ -650,7 +675,7 @@ oper {s = table { InfImp => beable ; Indic _ => can ; - Past _ => could ; + Pastt _ => could ; PPart => beenable } ; s1 = [] ; @@ -660,6 +685,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 diff --git a/lib/resource/english/TestResourceEng.gf b/lib/resource/english/TestResourceEng.gf new file mode 100644 index 000000000..6159aebed --- /dev/null +++ b/lib/resource/english/TestResourceEng.gf @@ -0,0 +1,54 @@ +--# -path=.:../abstract:../../prelude + +concrete TestResourceEng of TestResource = RulesEng, StructuralEng ** +{} +{- ----- +open SyntaxEng, ParadigmsEng in { + +flags startcat=Phr ; lexer=textlit ; parser=chart ; unlexer=text ; + +-- a random sample from the lexicon + +lin + Big = adjDegrIrreg "big" "bigger" "biggest"; + Happy = adjDegrReg "happy" ; + Small = adjDegrReg "small" ; + Old = adjDegrReg "old" ; + Young = adjDegrReg "young" ; + 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") ; + Prove = verbNoPart (regVerbP3 "prove") ; + 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" ; + Mother = funOfReg "mother" human ; + Uncle = funOfReg "uncle" human ; + Connection = cnNoHum (nounReg "connection") ** {s2 = "from" ; s3 = "to"} ; + + Always = advPre "always" ; + Well = advPost "well" ; + + SwitchOn = mkTransVerbPart (verbP3s "switch") "on" ; + SwitchOff = mkTransVerbPart (verbP3s "switch") "off" ; + + John = nameReg "John" ; + Mary = nameReg "Mary" ; + +} ; +-} \ No newline at end of file