New place for new resource API implementations.

This commit is contained in:
aarne
2003-11-25 15:11:59 +00:00
parent 3c94482769
commit 0878449cca
22 changed files with 5609 additions and 4 deletions

View File

@@ -0,0 +1,193 @@
--# -path=.:../abstract:../../prelude
--1 The Top-Level English Resource Grammar: Combination Rules
--
-- Aarne Ranta 2002 -- 2003
--
-- This is the English concrete syntax of the multilingual resource
-- grammar. Most of the work is done in the file $syntax.Eng.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 $TypesEng.gf$.
concrete CombinationsEng of Combinations = 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 ;
ModGenOne = npGenDet singular noNum ;
ModGenMany = npGenDet plural ;
UsePN = nameNounPhrase ;
UseFun = funAsCommNounPhrase ;
AppFun = appFunComm ;
AppFun2 = appFun2 ;
AdjP1 = adj2adjPhrase ;
ComplAdj = complAdj ;
PositAdjP = positAdjPhrase ;
ComparAdjP = comparAdjPhrase ;
SuperlNP = superlNounPhrase ;
DetNP = detNounPhrase ;
IndefOneNP = indefNounPhrase singular ;
IndefManyNP = indefNounPhraseNum plural ;
DefOneNP = defNounPhrase singular ;
DefManyNP = defNounPhraseNum plural ;
MassNP = detNounPhrase (mkDeterminer Sg []) ;
CNthatS = nounThatSentence ;
UseInt i = {s = table {Nom => i.s ; Gen => i.s ++ "'s"}} ; ---
NoNum = noNum ;
PredVP = predVerbPhrase ;
PosVG = predVerbGroup True ;
NegVG = predVerbGroup False ;
PredV = predVerb ;
PredAP = predAdjective ;
PredCN = predCommNoun ;
PredTV = complTransVerb ;
PredV3 = complDitransVerb ;
PredPassV = passVerb ;
PredNP = predNounPhrase ;
PredAdV = predAdverb ;
PredVS = complSentVerb ;
PredVV = complVerbVerb ;
VTrans = transAsVerb ;
AdjAdv a = advPost (a.s ! AAdv) ;
PrepNP p = prepPhrase p.s ; ---
AdvVP = adVerbPhrase ;
AdvCN = advCommNounPhrase ;
AdvAP = advAdjPhrase ;
PosSlashTV = slashTransVerb True ;
NegSlashTV = slashTransVerb False ;
OneVP = predVerbPhrase (nameNounPhrase (nameReg "one")) ;
ThereNP = thereIs ;
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 = isThere ;
ImperVP = imperVerbPhrase ;
IndicPhrase = indicUtt ;
QuestPhrase = interrogUtt ;
ImperOne = imperUtterance singular ;
ImperMany = imperUtterance plural ;
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 ;
} ;

View File

@@ -0,0 +1,202 @@
--# -path=.:../../prelude
--1 A Simple English Resource Morphology
--
-- Aarne Ranta 2002
--
-- This resource morphology contains definitions needed in the resource
-- syntax. It moreover contains the most usual inflectional patterns.
--
-- We use the parameter types and word classes defined in $Types.gf$.
resource MorphoEng = TypesEng ** open Prelude, (Predef=Predef) in {
--2 Nouns
--
-- For conciseness and abstraction, we define a worst-case macro for
-- noun inflection. It is used for defining special case that
-- only need one string as argument.
oper
mkNoun : (_,_,_,_ : Str) -> CommonNoun =
\man,men, mans, mens -> {s = table {
Sg => table {Nom => man ; Gen => mans} ;
Pl => table {Nom => men ; Gen => mens}
}} ;
nounReg : Str -> CommonNoun = \dog ->
mkNoun dog (dog + "s") (dog + "'s") (dog + "s'");
nounS : Str -> CommonNoun = \kiss ->
mkNoun kiss (kiss + "es") (kiss + "'s") (kiss + "es'") ;
nounY : Str -> CommonNoun = \fl ->
mkNoun (fl + "y") (fl + "ies") (fl + "y's") (fl + "ies'") ;
--3 Proper names
--
-- Regular proper names are inflected with "'s" in the genitive.
nameReg : Str -> ProperName = \john ->
{s = table {Nom => john ; Gen => john + "'s"}} ;
--2 Pronouns
--
-- Here we define personal and relative pronouns.
mkPronoun : (_,_,_,_ : Str) -> Number -> Person -> Pronoun = \I,me,my,mine,n,p ->
{s = table {NomP => I ; AccP => me ; GenP => my ; GenSP => mine} ;
n = n ; p = p} ;
pronI = mkPronoun "I" "me" "my" "mine" Sg P1 ;
pronYouSg = mkPronoun "you" "you" "your" "yours" Sg P2 ; -- verb form still OK
pronHe = mkPronoun "he" "him" "his" "his" Sg P3 ;
pronShe = mkPronoun "she" "her" "her" "hers" Sg P3 ;
pronIt = mkPronoun "it" "it" "its" "it" Sg P3 ;
pronWe = mkPronoun "we" "us" "our" "ours" Pl P1 ;
pronYouPl = mkPronoun "you" "you" "your" "yours" Pl P2 ;
pronThey = mkPronoun "they" "them" "their" "theirs" Pl P3 ;
-- Relative pronouns in the accusative have the 'no pronoun' variant.
-- The simple pronouns do not really depend on number.
relPron : RelPron = {s = table {
NoHum => \\_ => table {
NomP => variants {"that" ; "which"} ;
AccP => variants {"that" ; "which" ; []} ;
GenP => variants {"whose"} ;
GenSP => variants {"which"}
} ;
Hum => \\_ => table {
NomP => variants {"that" ; "who"} ;
AccP => variants {"that" ; "who" ; "whom" ; []} ;
GenP => variants {"whose"} ;
GenSP => variants {"whom"}
}
}
} ;
--3 Determiners
--
-- We have just a heuristic definition of the indefinite article.
-- There are lots of exceptions: consonantic "e" ("euphemism"), consonantic
-- "o" ("one-sided"), vocalic "u" ("umbrella").
artIndef = pre {"a" ;
"an" / strs {"a" ; "e" ; "i" ; "o" ; "A" ; "E" ; "I" ; "O" }} ;
artDef = "the" ;
--2 Adjectives
--
-- To form the adjectival and the adverbial forms, two strings are needed
-- in the worst case.
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.
regAdjective : Str -> Adjective = \free ->
let
y = Predef.dp 1 free
in mkAdjective
free
(ifTok Str y "y" (Predef.tk 1 free + ("ily")) (free + "ly")) ;
-- 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 ->
adjDegrIrreg ridiculous ("more" ++ ridiculous) ("most" ++ ridiculous) ;
--3 Verbs
--
-- Except for "be", the worst case needs four forms.
mkVerbP3 : (_,_,_,_: Str) -> VerbP3 = \go,goes,went,gone ->
{s = table {
InfImp => go ;
Indic P3 => goes ;
Indic _ => go ;
Past _ => went ;
PPart => gone
}
} ;
mkVerb : (_,_,_ : Str) -> VerbP3 = \ring,rang,rung ->
mkVerbP3 ring (ring + "s") rang rung ;
regVerbP3 : Str -> VerbP3 = \walk ->
mkVerb walk (walk + "ed") (walk + "ed") ;
verbP3s : Str -> VerbP3 = \kiss ->
mkVerbP3 kiss (kiss + "es") (kiss + "ed") (kiss + "ed") ;
verbP3e : Str -> VerbP3 = \love ->
mkVerbP3 love (love + "s") (love + "d") (love + "d") ;
verbP3y : Str -> VerbP3 = \cr ->
mkVerbP3 (cr + "y") (cr + "ies") (cr + "ied") (cr + "ied") ;
verbP3Have = mkVerbP3 "have" "has" "had" "had" ;
verbP3Do = mkVerbP3 "do" "does" "did" "done" ;
verbBe : VerbP3 = {s = table {
InfImp => "be" ;
Indic P1 => "am" ;
Indic P2 => "are" ;
Indic P3 => "is" ;
Past Sg => "was" ;
Past Pl => "were" ;
PPart => "been"
}} ;
verbPart : VerbP3 -> Particle -> Verb = \v,p ->
v ** {s1 = p} ;
verbNoPart : VerbP3 -> Verb = \v -> verbPart v [] ;
-- The optional negation contraction is a useful macro e.g. for "do".
contractNot : Str -> Str = \is -> variants {is ++ "not" ; is + "n't"} ;
dont = contractNot (verbP3Do.s ! InfImp) ;
} ;

View File

@@ -0,0 +1,242 @@
--# -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, $resource.Abs.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 as string
-- arguments of the paradigms, not stems.
--
-- The following modules are presupposed:
resource ParadigmsEng = open (Predef=Predef), Prelude, SyntaxEng, ResEng in {
--2 Parameters
--
-- To abstract over gender names, we define the following identifiers.
oper
human : Gender ;
nonhuman : Gender ;
-- To abstract over number names, we define the following.
singular : Number ;
plural : Number ;
--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".
mkFun : N -> Preposition -> Fun ;
funHuman : Str -> Fun ; -- the father/mistress/daddy of
funNonhuman : Str -> Fun ; -- the successor/address/copy of
-- Proper names, with their regular genitive.
pnReg : (John : Str) -> PN ; -- John, John's
-- The most common cases on the top level havee shortcuts.
-- The regular "y"/"s" variation is taken into account in $CN$.
cnNonhuman : Str -> CN ;
cnHuman : Str -> CN ;
npReg : Str -> NP ;
-- In some cases, you may want to make a complex $CN$ into a function.
mkFunCN : CN -> Preposition -> Fun ;
funOfCN : CN -> Fun ;
--2 Adjectives
-- Non-comparison one-place adjectives just have one form.
mkAdj1 : (even : Str) -> Adj1 ;
-- Two-place adjectives need a preposition as second argument.
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;
-- the "y" ending is recognized by the function $aReg$.
mkAdjDeg : (good,better,best : Str) -> AdjDeg ;
aReg : (long : Str) -> AdjDeg ; -- long, longer, longest
aFat : (fat : Str) -> AdjDeg ; -- fat, fatter, fattest
aRidiculous : (ridiculous : Str) -> AdjDeg ; -- -/more/most ridiculous
-- On top level, there are adjectival phrases. The most common case is
-- just to use a one-place adjective.
apReg : Str -> AP ;
--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$.
mkTV : V -> Str -> TV ; -- look for, kill
tvGen : (look, for : Str) -> TV ; -- look for, talk about
tvDir : V -> TV ; -- switch off
tvGenDir : (kill : Str) -> TV ; -- kill
-- Regular two-place verbs with a particle.
tvPartReg : Str -> Str -> Str -> TV ; -- get, along, with
-- The definitions should not bother the user of the API. So they are
-- hidden from the document.
--.
human = Hum ;
nonhuman = NoHum ;
-- singular defined in types.Eng
-- plural defined in types.Eng
nominative = 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 ;
mkFun = \n,p -> n ** {lock_Fun = <> ; s2 = p} ;
funNonhuman = \s -> mkFun (nNonhuman s) "of" ;
funHuman = \s -> mkFun (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) ;
mkFunCN = \n,p -> n ** {lock_Fun = <> ; s2 = p} ;
funOfCN = \n -> mkFunCN n "of" ;
addGenN : (Str -> CommonNoun) -> Str -> Gender -> N = \f ->
\s,g -> f s ** {g = g ; lock_N = <>} ;
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 = <>} ;
aFat = \fat -> let {fatt = fat + Predef.dp 1 fat} in
mkAdjDeg fat (fatt + "er") (fatt + "est") ;
aRidiculous a = adjDegrLong a ** {lock_AdjDeg = <>} ;
apReg = \s -> AdjP1 (mkAdj1 s) ;
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 (regVerbP3 get) up ** {lock_V = <>} ;
mkTV = \v,p -> v ** {lock_TV = <> ; s3 = p} ;
tvPartReg = \get, along, to -> mkTV (vPartReg get along) to ;
vBe = verbBe ** {s1 = [] ; lock_V = <>} ;
vHave = verbP3Have ** {s1 = [] ; lock_V = <>} ;
tvGen = \s,p -> mkTV (vGen s) p ;
tvDir = \v -> mkTV v [] ;
tvGenDir = \s -> tvDir (vGen s) ;
} ;

View File

@@ -0,0 +1,83 @@
--1 A Small Predication Library
--
-- (c) Aarne Ranta 2003 under Gnu GPL.
--
-- This library is built on a language-independent API of
-- resource grammars. It has a common part, the type signatures
-- (defined here), and language-dependent parts. The user of
-- the library should only have to look at the type signatures.
resource Predication = open English in {
-- We first define a set of predication patterns.
oper
predV1 : V -> NP -> S ; -- one-place verb: "John walks"
predV2 : TV -> NP -> NP -> S ; -- two-place verb: "John loves Mary"
predVColl : V -> NP -> NP -> S ; -- collective verb: "John and Mary fight"
predA1 : Adj1 -> NP -> S ; -- one-place adjective: "John is old"
predA2 : Adj2 -> NP -> NP -> S ; -- two-place adj: "John is married to Mary"
predAComp : AdjDeg -> NP -> NP -> S ; -- compar adj: "John is older than Mary"
predAColl : Adj1 -> NP -> NP -> S ; -- collective adj: "John and Mary are married"
predN1 : N -> NP -> S ; -- one-place noun: "John is a man"
predN2 : Fun -> NP -> NP -> S ; -- two-place noun: "John is a lover of Mary"
predNColl : N -> NP -> NP -> S ; -- collective noun: "John and Mary are lovers"
-- Individual-valued function applications.
appFun1 : Fun -> NP -> NP ; -- one-place function: "the successor of x"
appFunColl : Fun -> NP -> NP -> NP ; -- collective function: "the sum of x and y"
-- Families of types, expressed by common nouns depending on arguments.
appFam1 : Fun -> NP -> CN ; -- one-place family: "divisor of x"
appFamColl : Fun -> NP -> NP -> CN ; -- collective family: "path between x and y"
-- Type constructor, similar to a family except that the argument is a type.
constrTyp1 : Fun -> CN -> CN ;
-- Logical connectives on two sentences.
conjS : S -> S -> S ;
disjS : S -> S -> S ;
implS : S -> S -> S ;
-- As an auxiliary, we need two-place conjunction of names ("John and Mary"),
-- used in collective predication.
conjNP : NP -> NP -> NP ;
-----------------------------
---- what follows should be an implementation of the preceding
oper
predV1 = \F, x -> PredVP x (PosV F) ;
predV2 = \F, x, y -> PredVP x (PosTV F y) ;
predVColl = \F, x, y -> PredVP (conjNP x y) (PosV F) ;
predA1 = \F, x -> PredVP x (PosA (AdjP1 F)) ;
predA2 = \F, x, y -> PredVP x (PosA (ComplAdj F y)) ;
predAComp = \F, x, y -> PredVP x (PosA (ComparAdjP F y)) ;
predAColl = \F, x, y -> PredVP (conjNP x y) (PosA (AdjP1 F)) ;
predN1 = \F, x -> PredVP x (PosCN (UseN F)) ;
predN2 = \F, x, y -> PredVP x (PosCN (AppFun F y)) ;
predNColl = \F, x, y -> PredVP (conjNP x y) (PosCN (UseN F)) ;
appFun1 = \f, x -> DefOneNP (AppFun f x) ;
appFunColl = \f, x, y -> DefOneNP (AppFun f (conjNP x y)) ;
appFam1 = \F, x -> AppFun F x ;
appFamColl = \F, x, y -> AppFun F (conjNP x y) ;
conjS = \A, B -> ConjS AndConj (TwoS A B) ;
disjS = \A, B -> ConjS OrConj (TwoS A B) ;
implS = \A, B -> SubjS IfSubj A B ;
constrTyp1 = \F, A -> AppFun F (IndefManyNP A) ;
conjNP = \x, y -> ConjNP AndConj (TwoNP x y) ;
} ;

View File

@@ -0,0 +1,3 @@
--# -path=.:../abstract:../../prelude
resource ResourceEng = reuse StructuralEng ;

View File

@@ -0,0 +1,103 @@
--# -path=.:../abstract:../../prelude
--1 The Top-Level English Resource Grammar: Structural Words
--
-- Aarne Ranta 2002 -- 2003
--
concrete StructuralEng of Structural =
CombinationsEng ** open Prelude, SyntaxEng in {
lin
INP = pronI ;
ThouNP = pronYouSg ;
HeNP = pronHe ;
SheNP = pronShe ;
ItNP = pronIt ;
WeNP = pronWithNum pronWe ;
YeNP = pronWithNum pronYouPl ;
YouNP = pronYouSg ;
TheyNP = pronThey ;
EveryDet = everyDet ;
AllDet = mkDeterminer Sg "all" ; --- all the missing
AllsDet = mkDeterminerNum Pl "all" ;
WhichDet = whichDet ;
WhichsDet = mkDeterminerNum Pl "which" ;
MostsDet = mostDet ;
MostDet = mkDeterminer Sg "most" ;
SomeDet = mkDeterminer Sg "some" ;
SomesDet = mkDeterminerNum Pl "some" ;
AnyDet = mkDeterminer Sg "any" ;
AnysDet = mkDeterminerNum Pl "any" ;
NoDet = mkDeterminer Sg "no" ;
NosDet = mkDeterminerNum Pl "no" ;
ManyDet = mkDeterminer Pl "many" ;
MuchDet = mkDeterminer Sg ["a lot of"] ; ---
ThisDet = mkDeterminer Sg "this" ;
TheseDet = mkDeterminerNum Pl "these" ;
ThatDet = mkDeterminer Sg "that" ;
ThoseDet = mkDeterminerNum Pl "those" ;
ThisNP = nameNounPhrase (nameReg "this") ;
ThatNP = nameNounPhrase (nameReg "that") ;
TheseNP n = nameNounPhrase {s = \\c => "these" ++ n.s ! c} ; --- Pl; Gen!
ThoseNP n = nameNounPhrase {s = \\c => "those" ++ n.s ! c} ; --- Pl; Gen!
EverybodyNP = nameNounPhrase (nameReg "everybody") ;
SomebodyNP = nameNounPhrase (nameReg "somebody") ;
NobodyNP = nameNounPhrase (nameReg "nobody") ;
EverythingNP = nameNounPhrase (nameReg "everything") ;
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" ;
WhyIAdv = ss "why" ;
EverywhereNP = advPost "everywhere" ;
SomewhereNP = advPost "somewhere" ;
NowhereNP = advPost "nowhere" ;
AndConj = ss "and" ** {n = Pl} ;
OrConj = ss "or" ** {n = Sg} ;
BothAnd = sd2 "both" "and" ** {n = Pl} ;
EitherOr = sd2 "either" "or" ** {n = Sg} ;
NeitherNor = sd2 "neither" "nor" ** {n = Sg} ;
IfSubj = ss "if" ;
WhenSubj = ss "when" ;
AlthoughSubj = ss "although" ;
PhrYes = ss "Yes." ;
PhrNo = ss "No." ;
VeryAdv = ss "very" ;
TooAdv = ss "too" ;
AlmostAdv = ss "almost" ;
QuiteAdv = ss "quite" ;
OtherwiseAdv = ss "otherwise" ;
ThereforeAdv = ss "therefore" ;
InPrep = ss "in" ;
OnPrep = ss "on" ;
ToPrep = ss "to" ;
ThroughPrep = ss "through" ;
AbovePrep = ss "above" ;
UnderPrep = ss "under" ;
InFrontPrep = ss ["in front of"] ;
BehindPrep = ss "behind" ;
BetweenPrep = ss "between" ;
FromPrep = ss "from" ;
BeforePrep = ss "before" ;
DuringPrep = ss "during" ;
AfterPrep = ss "after" ;
WithPrep = ss "with" ;
WithoutPrep = ss "without" ;
ByMeansPrep = ss "by" ;
PartPrep = ss "of" ;
AgentPrep = ss "by" ;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,50 @@
--# -path=.:../abstract:../../prelude
concrete TestResourceEng of TestResource = StructuralEng ** open SyntaxEng in {
flags startcat=Phr ; lexer=literals ; 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" Hum ;
Uncle = funOfReg "uncle" Hum ;
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" ;
} ;

View File

@@ -0,0 +1,104 @@
--1 English Word Classes and Morphological Parameters
--
-- This is a resource module for English morphology, defining the
-- morphological parameters and word classes of English. It is aimed
-- to be complete w.r.t. the description of word forms.
-- However, it only includes those parameters that are needed for
-- analysing individual words: such parameters are defined in syntax modules.
--
-- We use the language-independent prelude.
resource TypesEng = open Prelude in {
--
--2 Enumerated parameter types
--
-- These types are the ones found in school grammars.
-- Their parameter values are atomic.
param
Number = Sg | Pl ;
Gender = NoHum | Hum ;
Case = Nom | Gen ;
Person = P1 | P2 | P3 ;
Degree = Pos | Comp | Sup ;
-- For data abstraction, we define
oper
singular = Sg ;
plural = Pl ;
--2 Word classes and hierarchical parameter types
--
-- Real parameter types (i.e. ones on which words and phrases depend)
-- are often hierarchical. The alternative would be cross-products of
-- simple parameters, but this would usually overgenerate.
--
--3 Common nouns
--
-- Common nouns are inflected in number and case.
CommonNoun : Type = {s : Number => Case => Str} ;
--
--3 Adjectives
--
-- The major division is between the comparison degrees, but it
-- is also good to leave room for adjectives that cannon be compared.
-- It is, however, productive to form an adverbial from any adjective.
param AForm = AAdj | AAdv ;
oper
Adjective : Type = SS1 AForm ;
AdjDegr = {s : Degree => AForm => Str} ;
--3 Verbs
--
-- We treat the full conjugation now.
-- The present tense is made to depend on person, which correspond to forms
-- in the singular; plural forms are uniformly equal to the 2nd person singular.
param
VForm = InfImp | Indic Person | Past Number | PPart ;
oper
VerbP3 : Type = SS1 VForm ;
-- A full verb can moreover have a particle.
Particle : Type = Str ;
Verb = VerbP3 ** {s1 : Particle} ;
--
--3 Pronouns
--
-- For pronouns, we need four case forms: "I" - "me" - "my" - "mine".
param
NPForm = NomP | AccP | GenP | GenSP ;
oper
Pronoun : Type = {s : NPForm => Str ; n : Number ; p : Person} ;
-- Coercions between pronoun cases and ordinaty cases.
toCase : NPForm -> Case = \c -> case c of {GenP => Gen ; _ => Nom} ;
toNPForm : Case -> NPForm = \c -> case c of {Gen => GenP ; _ => NomP} ; ---
--3 Proper names
--
-- Proper names only need two cases.
ProperName : Type = SS1 Case ;
--3 Relative pronouns
--
-- Relative pronouns are inflected in gender (human/nonhuman), number, and case.
RelPron : Type = {s : Gender => Number => NPForm => Str} ;
} ;