Extending resource.

This commit is contained in:
aarne
2003-11-19 17:33:06 +00:00
parent 18dfde370e
commit 1ca5e5398a
20 changed files with 2673 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
abstract Database = {
flags startcat=Query ;
cat
Query ;
Category ; Subject ; Value ; Property ; Relation ; Comparison ; Name ;
Feature ;
fun
WhichAre : Category -> Property -> Query ;
IsThere : Category -> Query ;
AreThere : Category -> Query ;
IsIt : Subject -> Property -> Query ;
WhatIs : Value -> Query ;
MoreThan : Comparison -> Subject -> Property ;
TheMost : Comparison -> Category -> Value ;
Relatively : Comparison -> Category -> Property ;
RelatedTo : Relation -> Subject -> Property ;
Individual : Name -> Subject ;
AllN : Category -> Subject ;
Any : Category -> Subject ;
MostN : Category -> Subject ;
EveryN : Category -> Subject ;
FeatureOf : Feature -> Subject -> Subject ;
ValueOf : Feature -> Name -> Value ;
WithProperty : Category -> Property -> Category ;
} ;

View File

@@ -0,0 +1,43 @@
--# -path=.:../resource/nabstract:../resource/nenglish:../prelude
concrete DatabaseEng of Database = open Prelude, ResEng in {
flags lexer=text ; unlexer=text ;
lincat
Query = Phr ;
Subject = NP ;
Category = CN ;
Property = AP ;
Comparison = AdjDeg ;
Relation = Adj2 ;
Feature = Fun ;
Value = NP ;
Name = PN ;
lin
WhichAre A B = QuestPhrase (IntVP (NounIPMany A) (PosA B)) ;
IsThere A = QuestPhrase (IsThereCN A) ;
AreThere A = QuestPhrase (AreThereCN A) ;
WhatIs val = QuestPhrase (IntVP WhatOne (PosNP val)) ;
IsIt Q A = QuestPhrase (QuestVP Q (PosA A)) ;
MoreThan = ComparAdjP ;
TheMost = SuperlNP ;
Relatively C _ = PositAdjP C ;
RelatedTo = ComplAdj ;
FeatureOf f x = DefOneNP (AppFun f x) ;
ValueOf f x = DefOneNP (AppFun f (UsePN x)) ;
WithProperty A B = ModAdj B A ;
Individual = UsePN ;
AllN = DetNP AllDet ;
MostN = DetNP MostDet ;
EveryN = DetNP EveryDet ;
Any = DetNP AnysDet ;
} ;

View File

@@ -0,0 +1,11 @@
resource DatabaseEngRes = open Prelude in {
oper
mkSent : SS -> SS -> SS1 Bool = \long, short ->
{s = table {b => if_then_else Str b long.s short.s}} ;
mkSentPrel : Str -> SS -> SS1 Bool = \prel, matter ->
mkSent (ss (prel ++ matter.s)) matter ;
mkSentSame : SS -> SS1 Bool = \s ->
mkSent s s ;
} ;

View File

@@ -0,0 +1,16 @@
abstract Restaurant = Database ** {
fun
Restaurant, Bar : Category ;
French, Italian, Indian, Japanese : Property ;
address, phone, priceLevel : Feature ;
Cheap, Expensive : Comparison ;
WhoRecommend : Name -> Query ;
WhoHellRecommend : Name -> Query ;
-- examples of restaurant names
LucasCarton : Name ;
LaCoupole : Name ;
BurgerKing : Name ;
} ;

View File

@@ -0,0 +1,30 @@
--# -path=.:../resource/nabstract:../resource/nenglish:../prelude
concrete RestaurantEng of Restaurant =
DatabaseEng ** open Prelude,ParadigmsEng in {
lin
Restaurant = cnNonhuman "restaurant" ;
Bar = cnNonhuman "bar" ;
French = apReg "French" ;
Italian = apReg "Italian" ;
Indian = apReg "Indian" ;
Japanese = apReg "Japanese" ;
address = funNonhuman "address" ;
phone = funNonhuman ["number"] ; --- phone
priceLevel = funNonhuman ["level"] ; --- price
Cheap = aReg "cheap" ;
Expensive = aRidiculous "expensive" ;
WhoRecommend rest =
ss (["who recommended"] ++ rest.s ! nominative) ** {lock_Phr = <>} ;
WhoHellRecommend rest =
ss (["who the hell recommended"] ++ rest.s ! nominative) ** {lock_Phr = <>} ;
LucasCarton = pnReg ["Lucas Carton"] ;
LaCoupole = pnReg ["La Coupole"] ;
BurgerKing = pnReg ["Burger King"] ;
} ;

View File

@@ -0,0 +1,263 @@
--1 Abstract Syntax for Multilingual Resource Grammar
--
-- Aarne Ranta 2002 -- 2003
--
-- Although concrete syntax differs a lot between different languages,
-- many structures can be found that are common, on a certain level
-- of abstraction. What we will present in the following is an abstract
-- syntax that has been successfully defined for English, Finnish, French, German,
-- Italian, Russian, and Swedish. It has been applied to define language
-- fragments on technical or near-to-technical domains: database queries,
-- video recorder dialogue systems, software specifications, and a
-- health-related phrase book. Each new application helped to identify some
-- missing structures in the resource and suggested some additions, but the
-- number of them was usually small.
--
-- To use the resource in applications, you need the following
-- $cat$ and $fun$ rules in $oper$ form, completed by taking the
-- $lincat$ and $lin$ judgements of a particular language. This is done
-- by using the $reuse$ module with the desired concrete syntax of
-- $ResAbs$ as argument.
--2 Categories
--
-- The categories of this resource grammar are mostly 'standard' categories
-- of linguistics. Their is no claim that they correspond to semantic categories
-- definable in type theory: to define such correspondences is the business
-- of applications grammars.
--
-- Categories that may look special are $Adj2$, $Fun$, and $TV$. They are all
-- instances of endowing another category with a complement, which can be either
-- a direct object (whose case may vary) or a prepositional phrase. This, together
-- with the category $Adv$, removes the need of a category of
-- 'prepositional phrases', which is too language-dependent to make sense
-- on this level of abstraction.
--
abstract Combinations = PredefAbs ** {
--3 Nouns and noun phrases
--
cat
N ; -- simple common noun, e.g. "car"
CN ; -- common noun phrase, e.g. "red car", "car that John owns"
NP ; -- noun phrase, e.g. "John", "all cars", "you"
PN ; -- proper name, e.g. "John", "New York"
Det ; -- determiner, e.g. "every", "all"
Fun ; -- function word, e.g. "mother (of)"
Fun2 ; -- two-place function, e.g. "flight (from) (to)"
--3 Adjectives and adjectival phrases
--
Adj1 ; -- one-place adjective, e.g. "even"
Adj2 ; -- two-place adjective, e.g. "divisible (by)"
AdjDeg ; -- degree adjective, e.g. "big/bigger/biggest"
AP ; -- adjective phrase, e.g. "divisible by two", "bigger than John"
--3 Verbs and verb phrases
--
V ; -- one-place verb, e.g. "walk"
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"
VP ; -- verb phrase, e.g. "switch the light on"
--3 Adverbials
--
AdV ; -- adverbial e.g. "now", "in the house"
AdA ; -- ad-adjective e.g. "very"
AdS ; -- sentence adverbial e.g. "therefore", "otherwise"
Prep ; -- pre/postposition, case e.g. "after", Adessive
--3 Sentences and relative clauses
--
S ; -- sentence, e.g. "John walks"
Slash ; -- sentence without NP, e.g. "John waits for (...)"
RP ; -- relative pronoun, e.g. "which", "the mother of whom"
RC ; -- relative clause, e.g. "who walks", "that I wait for"
--3 Questions and imperatives
--
IP ; -- interrogative pronoun, e.g. "who", "whose mother", "which yellow car"
IAdv ; -- interrogative adverb., e.g. "when", "why"
Qu ; -- question, e.g. "who walks"
Imp ; -- imperative, e.g. "walk!"
--3 Coordination and subordination
--
Conj ; -- conjunction, e.g. "and"
ConjD ; -- distributed conj. e.g. "both - and"
Subj ; -- subjunction, e.g. "if", "when"
ListS ; -- list of sentences
ListAP ; -- list of adjectival phrases
ListNP ; -- list of noun phrases
--3 Complete utterances
--
Phr ; -- full phrase, e.g. "John walks.","Who walks?", "Wait for me!"
Text ; -- sequence of phrases e.g. "One is odd. Therefore, two is even."
--2 Rules
--
-- This set of rules is minimal, in the sense of defining the simplest combinations
-- of categories and not having redundant rules.
-- When the resource grammar is used as a library, it will often be useful to
-- access it through an intermediate library that defines more rules as
-- 'macros' for combinations of the ones below.
--3 Nouns and noun phrases
--
fun
UseN : N -> CN ; -- "car"
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"
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"
--3 Adjectives and adjectival phrases
--
AdjP1 : Adj1 -> AP ; -- "red"
ComplAdj : Adj2 -> NP -> AP ; -- "divisible by two"
PositAdjP : AdjDeg -> AP ; -- "old"
ComparAdjP : AdjDeg -> NP -> AP ; -- "older than John"
SuperlNP : AdjDeg -> CN -> NP ; -- "the oldest man"
--3 Verbs and verb phrases
--
PosV, NegV : V -> VP ; -- "walk", "doesn't walk"
PosA, NegA : AP -> VP ; -- "is old", "isn't old"
PosCN, NegCN : CN -> VP ; -- "is a man", "isn't a man"
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"
PosVS, NegVS : VS -> S -> VP ; -- "says that I run", "doesn't say..."
PosV3, NegV3 : V3 -> NP -> NP -> VP ; -- "prefers wine to beer"
VTrans : TV -> V ; -- "loves"
--3 Adverbials
--
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"
--3 Sentences and relative clauses
--
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"
IdRP : RP ; -- "which"
FunRP : Fun -> RP -> RP ; -- "the successor of which"
RelVP : RP -> VP -> RC ; -- "who walks"
RelSlash : RP -> Slash -> RC ; -- "that I wait for"/"for which I wait"
ModRC : CN -> RC -> CN ; -- "man who walks"
RelSuch : S -> RC ; -- "such that it is even"
--3 Questions and imperatives
--
WhoOne, WhoMany : IP ; -- "who (is)", "who (are)"
WhatOne, WhatMany : IP ; -- "what (is)", "what (are)"
FunIP : Fun -> IP -> IP ; -- "the mother of whom"
NounIPOne, NounIPMany : CN -> IP ; -- "which car", "which cars"
QuestVP : NP -> VP -> Qu ; -- "does John walk"
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"
ImperVP : VP -> Imp ; -- "be a man"
IndicPhrase : S -> Phr ; -- "I walk."
QuestPhrase : Qu -> Phr ; -- "Do I walk?"
ImperOne, ImperMany : Imp -> Phr ; -- "Be a man!", "Be men!"
AdvS : AdS -> S -> Phr ; -- "Therefore, 2 is prime."
--3 Coordination
--
-- We consider "n"-ary coordination, with "n" > 1. To this end, we have introduced
-- a *list category* $ListX$ for each category $X$ whose expressions we want to
-- conjoin. Each list category has two constructors, the base case being $TwoX$.
-- We have not defined coordination of all possible categories here,
-- since it can be tricky in many languages. For instance, $VP$ coordination
-- is linguistically problematic in German because $VP$ is a discontinuous
-- category.
ConjS : Conj -> ListS -> S ; -- "John walks and Mary runs"
ConjAP : Conj -> ListAP -> AP ; -- "even and prime"
ConjNP : Conj -> ListNP -> NP ; -- "John or Mary"
ConjDS : ConjD -> ListS -> S ; -- "either John walks or Mary runs"
ConjDAP : ConjD -> ListAP -> AP ; -- "both even and prime"
ConjDNP : ConjD -> ListNP -> NP ; -- "either John or Mary"
TwoS : S -> S -> ListS ;
ConsS : ListS -> S -> ListS ;
TwoAP : AP -> AP -> ListAP ;
ConsAP : ListAP -> AP -> ListAP ;
TwoNP : NP -> NP -> ListNP ;
ConsNP : ListNP -> NP -> ListNP ;
--3 Subordination
--
-- Subjunctions are different from conjunctions, but form
-- a uniform category among themselves.
SubjS : Subj -> S -> S -> S ; -- "if 2 is odd, 3 is even"
SubjImper : Subj -> S -> Imp -> Imp ; -- "if it is hot, use a glove!"
SubjQu : Subj -> S -> Qu -> Qu ; -- "if you are new, who are you?"
SubjVP : VP -> Subj -> S -> VP ; -- "(a man who) sings when he runs"
--2 One-word utterances
--
-- These are, more generally, *one-phrase utterances*. The list below
-- is very incomplete.
PhrNP : NP -> Phr ; -- "Some man.", "John."
PhrOneCN, PhrManyCN : CN -> Phr ; -- "A car.", "Cars."
PhrIP : IAdv -> Phr ; -- "Who?"
PhrIAdv : IAdv -> Phr ; -- "Why?"
--2 Text formation
--
-- A text is a sequence of phrases. It is defined like a non-empty list.
OnePhr : Phr -> Text ;
ConsPhr : Phr -> Text -> Text ;
} ;

View File

@@ -0,0 +1,4 @@
abstract PredefAbs = {
cat String ; Int ;
} ;

View File

@@ -0,0 +1,275 @@
--1 Abstract Syntax for Multilingual Resource Grammar
--
-- Aarne Ranta 2002 -- 2003
--
-- Although concrete syntax differs a lot between different languages,
-- many structures can be found that are common, on a certain level
-- of abstraction. What we will present in the following is an abstract
-- syntax that has been successfully defined for English, Finnish, French, German,
-- Italian, Russian, and Swedish. It has been applied to define language
-- fragments on technical or near-to-technical domains: database queries,
-- video recorder dialogue systems, software specifications, and a
-- health-related phrase book. Each new application helped to identify some
-- missing structures in the resource and suggested some additions, but the
-- number of them was usually small.
--
-- To use the resource in applications, you need the following
-- $cat$ and $fun$ rules in $oper$ form, completed by taking the
-- $lincat$ and $lin$ judgements of a particular language. This is done
-- by using the $reuse$ module with the desired concrete syntax of
-- $ResAbs$ as argument.
--2 Categories
--
-- The categories of this resource grammar are mostly 'standard' categories
-- of linguistics. Their is no claim that they correspond to semantic categories
-- definable in type theory: to define such correspondences is the business
-- of applications grammars.
--
-- Categories that may look special are $Adj2$, $Fun$, and $TV$. They are all
-- instances of endowing another category with a complement, which can be either
-- a direct object (whose case may vary) or a prepositional phrase. This, together
-- with the category $Adv$, removes the need of a category of
-- 'prepositional phrases', which is too language-dependent to make sense
-- on this level of abstraction.
--
abstract ResAbs = {
--3 Nouns and noun phrases
--
cat
N ; -- simple common noun, e.g. "car"
CN ; -- common noun phrase, e.g. "red car", "car that John owns"
NP ; -- noun phrase, e.g. "John", "all cars", "you"
PN ; -- proper name, e.g. "John", "New York"
Det ; -- determiner, e.g. "every", "all"
Fun ; -- function word, e.g. "mother (of)"
Fun2 ; -- two-place function, e.g. "flight (from) (to)"
--3 Adjectives and adjectival phrases
--
Adj1 ; -- one-place adjective, e.g. "even"
Adj2 ; -- two-place adjective, e.g. "divisible (by)"
AdjDeg ; -- degree adjective, e.g. "big/bigger/biggest"
AP ; -- adjective phrase, e.g. "divisible by two", "bigger than John"
--3 Verbs and verb phrases
--
V ; -- one-place verb, e.g. "walk"
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"
VP ; -- verb phrase, e.g. "switch the light on"
--3 Adverbials
--
AdV ; -- adverbial e.g. "now", "in the house"
AdA ; -- ad-adjective e.g. "very"
AdS ; -- sentence adverbial e.g. "therefore", "otherwise"
--3 Sentences and relative clauses
--
S ; -- sentence, e.g. "John walks"
Slash ; -- sentence without NP, e.g. "John waits for (...)"
RP ; -- relative pronoun, e.g. "which", "the mother of whom"
RC ; -- relative clause, e.g. "who walks", "that I wait for"
--3 Questions and imperatives
--
IP ; -- interrogative pronoun, e.g. "who", "whose mother", "which yellow car"
IAdv ; -- interrogative adverb., e.g. "when", "why"
Qu ; -- question, e.g. "who walks"
Imp ; -- imperative, e.g. "walk!"
--3 Coordination and subordination
--
Conj ; -- conjunction, e.g. "and"
ConjD ; -- distributed conj. e.g. "both - and"
Subj ; -- subjunction, e.g. "if", "when"
ListS ; -- list of sentences
ListAP ; -- list of adjectival phrases
ListNP ; -- list of noun phrases
--3 Complete utterances
--
Phr ; -- full phrase, e.g. "John walks.","Who walks?", "Wait for me!"
Text ; -- sequence of phrases e.g. "One is odd. Therefore, two is even."
--2 Rules
--
-- This set of rules is minimal, in the sense of defining the simplest combinations
-- of categories and not having redundant rules.
-- When the resource grammar is used as a library, it will often be useful to
-- access it through an intermediate library that defines more rules as
-- 'macros' for combinations of the ones below.
--3 Nouns and noun phrases
--
fun
UseN : N -> CN ; -- "car"
ModAdj : AP -> CN -> CN ; -- "red car"
DetNP : Det -> CN -> NP ; -- "every car"
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"
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"
--3 Adjectives and adjectival phrases
--
AdjP1 : Adj1 -> AP ; -- "red"
ComplAdj : Adj2 -> NP -> AP ; -- "divisible by two"
PositAdjP : AdjDeg -> AP ; -- "old"
ComparAdjP : AdjDeg -> NP -> AP ; -- "older than John"
SuperlNP : AdjDeg -> CN -> NP ; -- "the oldest man"
--3 Verbs and verb phrases
--
PosV, NegV : V -> VP ; -- "walk", "doesn't walk"
PosA, NegA : AP -> VP ; -- "is old", "isn't old"
PosCN, NegCN : CN -> VP ; -- "is a man", "isn't a man"
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"
PosVS, NegVS : VS -> S -> VP ; -- "says that I run", "doesn't say..."
PosV3, NegV3 : V3 -> NP -> NP -> VP ; -- "prefers wine to beer"
VTrans : TV -> V ; -- "loves"
--3 Adverbials
--
AdvVP : VP -> AdV -> VP ; -- "always walks", "walks in the park"
LocNP : NP -> AdV ; -- "in London"
AdvCN : CN -> AdV -> CN ; -- "house in London", "house today"
AdvAP : AdA -> AP -> AP ; -- "very good"
--3 Sentences and relative clauses
--
PredVP : NP -> VP -> S ; -- "John walks"
PosSlashTV, NegSlashTV : NP -> TV -> Slash ; -- "John sees", "John doesn's see"
OneVP : VP -> S ; -- "one walks"
IdRP : RP ; -- "which"
FunRP : Fun -> RP -> RP ; -- "the successor of which"
RelVP : RP -> VP -> RC ; -- "who walks"
RelSlash : RP -> Slash -> RC ; -- "that I wait for"/"for which I wait"
ModRC : CN -> RC -> CN ; -- "man who walks"
RelSuch : S -> RC ; -- "such that it is even"
--3 Questions and imperatives
--
WhoOne, WhoMany : IP ; -- "who (is)", "who (are)"
WhatOne, WhatMany : IP ; -- "what (is)", "what (are)"
FunIP : Fun -> IP -> IP ; -- "the mother of whom"
NounIPOne, NounIPMany : CN -> IP ; -- "which car", "which cars"
QuestVP : NP -> VP -> Qu ; -- "does John walk"
IntVP : IP -> VP -> Qu ; -- "who walks"
IntSlash : IP -> Slash -> Qu ; -- "whom does John see"
QuestAdv : IAdv -> NP -> VP -> Qu ; -- "why do you walk"
ImperVP : VP -> Imp ; -- "be a man"
IndicPhrase : S -> Phr ; -- "I walk."
QuestPhrase : Qu -> Phr ; -- "Do I walk?"
ImperOne, ImperMany : Imp -> Phr ; -- "Be a man!", "Be men!"
AdvS : AdS -> S -> Phr ; -- "Therefore, 2 is prime."
--3 Coordination
--
-- We consider "n"-ary coordination, with "n" > 1. To this end, we have introduced
-- a *list category* $ListX$ for each category $X$ whose expressions we want to
-- conjoin. Each list category has two constructors, the base case being $TwoX$.
-- We have not defined coordination of all possible categories here,
-- since it can be tricky in many languages. For instance, $VP$ coordination
-- is linguistically problematic in German because $VP$ is a discontinuous
-- category.
ConjS : Conj -> ListS -> S ; -- "John walks and Mary runs"
ConjAP : Conj -> ListAP -> AP ; -- "even and prime"
ConjNP : Conj -> ListNP -> NP ; -- "John or Mary"
ConjDS : ConjD -> ListS -> S ; -- "either John walks or Mary runs"
ConjDAP : ConjD -> ListAP -> AP ; -- "both even and prime"
ConjDNP : ConjD -> ListNP -> NP ; -- "either John or Mary"
TwoS : S -> S -> ListS ;
ConsS : ListS -> S -> ListS ;
TwoAP : AP -> AP -> ListAP ;
ConsAP : ListAP -> AP -> ListAP ;
TwoNP : NP -> NP -> ListNP ;
ConsNP : ListNP -> NP -> ListNP ;
--3 Subordination
--
-- Subjunctions are different from conjunctions, but form
-- a uniform category among themselves.
SubjS : Subj -> S -> S -> S ; -- "if 2 is odd, 3 is even"
SubjImper : Subj -> S -> Imp -> Imp ; -- "if it is hot, use a glove!"
SubjQu : Subj -> S -> Qu -> Qu ; -- "if you are new, who are you?"
SubjVP : VP -> Subj -> S -> VP ; -- "(a man who) sings when he runs"
--2 One-word utterances
--
-- These are, more generally, *one-phrase utterances*. The list below
-- is very incomplete.
PhrNP : NP -> Phr ; -- "Some man.", "John."
PhrOneCN, PhrManyCN : CN -> Phr ; -- "A car.", "Cars."
PhrIP : IAdv -> Phr ; -- "Who?"
PhrIAdv : IAdv -> Phr ; -- "Why?"
--2 Text formation
--
-- A text is a sequence of phrases. It is defined like a non-empty list.
OnePhr : Phr -> Text ;
ConsPhr : Phr -> Text -> Text ;
--2 Examples of structural words
--
-- Here we have some words belonging to closed classes and appearing
-- in all languages we have considered.
-- Sometimes they are not really meaningful, e.g. $TheyNP$ in French
-- should really be replaced by masculine and feminine variants.
EveryDet, AllDet, WhichDet, MostDet : Det ; -- every, all, which, most
INP, ThouNP, HeNP, SheNP, ItNP : NP ; -- personal pronouns in singular
WeNP, YeNP, TheyNP : NP ; -- personal pronouns in plural
YouNP : NP ; -- the polite you
WhenIAdv,WhereIAdv,WhyIAdv,HowIAdv : IAdv ; -- when, where, why, how
AndConj, OrConj : Conj ; -- and, or
BothAnd, EitherOr, NeitherNor : ConjD ; -- both-and, either-or, neither-nor
IfSubj, WhenSubj : Subj ; -- if, when
PhrYes, PhrNo : Phr ; -- yes, no
VeryAdv, TooAdv : AdA ; -- very, too
OtherwiseAdv, ThereforeAdv : AdS ; -- therefore, otherwise
} ;

View File

@@ -0,0 +1,36 @@
--2 Examples of structural words
--
-- Here we have some words belonging to closed classes and appearing
-- in all languages we have considered.
-- Sometimes they are not really meaningful, e.g. $TheyNP$ in French
-- should really be replaced by masculine and feminine variants.
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
INP, ThouNP, HeNP, SheNP, ItNP : NP ; -- personal pronouns in singular
WeNP, YeNP, TheyNP : NP ; -- personal pronouns in plural
YouNP : NP ; -- the polite you
EverybodyNP, SomebodyNP, NobodyNP, -- everybody, somebody, nobody
EverythingNP, SomethingNP, NothingNP : NP ; -- everything, something, nothing
WhenIAdv,WhereIAdv,WhyIAdv,HowIAdv : IAdv ; -- when, where, why, how
EverywhereNP, SomewhereNP, NowhereNP : AdV ;-- everywhere, somewhere, nowhere
AndConj, OrConj : Conj ; -- and, or
BothAnd, EitherOr, NeitherNor : ConjD ; -- both-and, either-or, neither-nor
IfSubj, WhenSubj, AlthoughSubj : Subj ; -- if, when, although
PhrYes, PhrNo : Phr ; -- yes, no
VeryAdv, TooAdv : AdA ; -- very, too
AlmostAdv, QuiteAdv : AdA ; -- almost, quite
OtherwiseAdv, ThereforeAdv : AdS ; -- therefore, otherwise
InPrep, OnPrep, ToPrep, FromPrep, -- spatial relations
ThroughPrep, AbovePrep, UnderPrep,
InFrontPrep, BehindPrep, BetweenPrep : Prep ;
BeforePrep, DuringPrep, AfterPrep : Prep ; -- temporal relations
WithPrep, WithoutPrep, ByMeansPrep : Prep ; -- some other relations
AgentPrep : Prep ; -- agent "by" in passive constructions
}

View File

@@ -0,0 +1,18 @@
abstract TestResource = Structural ** {
-- a random sample of lexicon to test resource grammar with
fun
Big, Small, Old, Young : AdjDeg ;
American, Finnish : Adj1 ;
Married : Adj2 ;
Man, Woman, Car, House, Light : N ;
Walk, Run : V ;
Send, Wait, Love, SwitchOn, SwitchOff : TV ;
Give, Prefer : V3 ;
Say, Prove : VS ;
Mother, Uncle : Fun ;
Connection : Fun2 ;
Well, Always : AdV ;
John, Mary : PN ;
} ;

View File

@@ -0,0 +1,81 @@
-- added 19/11/2003
-- Combinations.gf
cat
Prep ; -- pre/postposition and/or case
fun
ThereIsCN, ThereAreCN : CN -> S ; -- "there is a bar", "there are 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
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
-- 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
EverybodyNP, SomebodyNP, NobodyNP, -- everybody, somebody, nobody
EverythingNP, SomethingNP, NothingNP : NP ; -- everything, something, nothing
EverywhereNP, SomewhereNP, NowhereNP : Adv ;-- everywhere, somewhere, nowhere
AlthoughSubj : Subj ; -- although
AlmostAdv, QuiteAdv : AdA ; -- almost, quite
InPrep, OnPrep, ToPrep, FromPrep, -- spatial relations
ThroughPrep, AbovePrep, UnderPrep,
InFrontPrep, BehindPrep, BetweenPrep : Prep ;
BeforePrep, DuringPrep, AfterPrep : Prep ; -- temporal relations
WithPrep, WithoutPrep, ByMeansPrep : Prep ; -- some other relations
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

View File

@@ -0,0 +1,195 @@
--# -path=.:../nabstract:../../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} ;
Adj1 = Adjective ;
-- = {s : Str}
Adj2 = Adjective ** {s2 : Preposition} ;
AdjDeg = {s : Degree => Str} ;
AP = Adjective ** {p : Bool} ;
V = Verb ;
-- = {s : VForm => Str ; s1 : Particle}
VP = {s : VForm => Str ; s2 : Number => Str ; isAux : Bool} ;
TV = TransVerb ;
-- = Verb ** {s3 : Preposition} ;
V3 = TransVerb ** {s4 : Preposition} ;
VS = Verb ;
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 : Str ; s2 : Str ; p : Bool} ;
ListNP = {s1,s2 : NPForm => Str ; n : Number ; p : Person} ;
--.
lin
UseN = noun2CommNounPhrase ;
ModAdj = modCommNounPhrase ;
ModGenOne = npGenDet singular ;
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 = indefNounPhrase plural ;
DefOneNP = defNounPhrase singular ;
DefManyNP = defNounPhrase plural ;
MassNP = detNounPhrase (mkDeterminer Sg []) ;
IntNP n = detNounPhrase (mkDeterminer Pl n.s) ;
DefIntNP n = detNounPhrase (mkDeterminer Pl ("the" ++ n.s)) ;
CNthatS = nounThatSentence ;
PredVP = predVerbPhrase ;
PosV = predVerb True ;
NegV = predVerb False ;
PosA = predAdjective True ;
NegA = predAdjective False ;
PosCN = predCommNoun True ;
NegCN = predCommNoun False ;
PosTV = complTransVerb True ;
NegTV = complTransVerb False ;
PosV3 = complDitransVerb True ;
NegV3 = complDitransVerb False ;
PosPassV = passVerb True ;
NegPassV = passVerb False ;
PosNP = predNounPhrase True ;
NegNP = predNounPhrase False ;
PosVS = complSentVerb True ;
NegVS = complSentVerb False ;
VTrans = transAsVerb ;
AdvVP = adVerbPhrase ;
PrepNP p = prepPhrase p.s ; ---
AdvCN = advCommNounPhrase ;
AdvAP = advAdjPhrase ;
PosSlashTV = slashTransVerb True ;
NegSlashTV = slashTransVerb False ;
OneVP = predVerbPhrase (nameNounPhrase (nameReg "one")) ;
ThereIsCN A = prefixSS ["there is"] ---
(defaultNounPhrase (indefNounPhrase singular A)) ;
ThereAreCN A = prefixSS ["there are"]
(defaultNounPhrase (indefNounPhrase plural A)) ;
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 ;
IsThereCN = isThere singular ;
AreThereCN = isThere plural ;
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,167 @@
--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 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
--
-- For the comparison of adjectives, three forms are needed in the worst case.
mkAdjDegr : (_,_,_ : Str) -> AdjDegr = \good,better,best ->
{s = table {Pos => good ; Comp => better ; Sup => best}} ;
adjDegrReg : Str -> AdjDegr = \long ->
mkAdjDegr long (long + "er") (long + "est") ;
adjDegrY : Str -> AdjDegr = \lovel ->
mkAdjDegr (lovel + "y") (lovel + "ier") (lovel + "iest") ;
-- Many adjectives are 'inflected' by adding a comparison word.
adjDegrLong : Str -> AdjDegr = \ridiculous ->
mkAdjDegr ridiculous ("more" ++ ridiculous) ("most" ++ ridiculous) ;
-- simple adjectives are just strings
simpleAdj : Str -> Adjective = ss ;
--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,243 @@
--# -path=.:../nabstract:../../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.
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
-- 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 = simpleAdj a ** {lock_Adj1 = <>} ;
mkAdj2 = \s,p -> simpleAdj s ** {s2 = p} ** {lock_Adj2 = <>} ;
mkAdjDeg a b c = mkAdjDegr 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 = <>} ;
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=.:../nabstract:../../prelude
resource ResEng = reuse StructuralEng ;

View File

@@ -0,0 +1,94 @@
--# -path=.:../nabstract:../../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 = pronWe ;
YeNP = pronYouPl ;
YouNP = pronYouSg ;
TheyNP = pronThey ;
EveryDet = everyDet ;
AllDet = allDet ;
WhichDet = whichDet ;
MostDet = mostDet ;
SomeDet = mkDeterminer Sg "some" ;
SomesDet = mkDeterminer Pl "some" ;
AnyDet = mkDeterminer Sg "any" ;
AnysDet = mkDeterminer Pl "any" ;
NoDet = mkDeterminer Sg "no" ;
NosDet = mkDeterminer Pl "no" ;
ManyDet = mkDeterminer Sg "many" ;
MuchDet = mkDeterminer Sg ["a lot of"] ; ---
ThisDet = mkDeterminer Sg "this" ;
TheseDet = mkDeterminer Pl "these" ;
ThatDet = mkDeterminer Sg "that" ;
ThoseDet = mkDeterminer Pl "those" ;
ThisNP = nameNounPhrase (nameReg "this") ;
TheseNP = nameNounPhrase (nameReg "these") ;
ThatNP = nameNounPhrase (nameReg "that") ;
ThoseNP = nameNounPhrase (nameReg "those") ;
EverybodyNP = nameNounPhrase (nameReg "everybody") ;
SomebodyNP = nameNounPhrase (nameReg "somebody") ;
NobodyNP = nameNounPhrase (nameReg "nobody") ;
EverythingNP = nameNounPhrase (nameReg "everything") ;
SomethingNP = nameNounPhrase (nameReg "something") ;
NothingNP = nameNounPhrase (nameReg "nothing") ;
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" ;
AgentPrep = ss "by" ;
}

View File

@@ -0,0 +1,931 @@
--1 A Small English Resource Syntax
--
-- Aarne Ranta 2002
--
-- This resource grammar contains definitions needed to construct
-- indicative, interrogative, and imperative sentences in English.
--
-- The following files are presupposed:
resource SyntaxEng = MorphoEng ** open Prelude, (CO = Coordination) in {
--2 Common Nouns
--
-- Simple common nouns are defined as the type $CommNoun$ in $morpho.Deu.gf$.
--3 Common noun phrases
-- To the common nouns of morphology,
-- we add natural gender (human/nonhuman) which is needed in syntactic
-- combinations (e.g. "man who runs" - "program which runs").
oper
CommNoun = CommonNoun ** {g : Gender} ;
CommNounPhrase = CommNoun ;
noun2CommNounPhrase : CommNoun -> CommNounPhrase = \man ->
man ;
cnGen : CommonNoun -> Gender -> CommNoun = \cn,g ->
cn ** {g = g} ;
cnHum : CommonNoun -> CommNoun = \cn ->
cnGen cn Hum ;
cnNoHum : CommonNoun -> CommNoun = \cn ->
cnGen cn NoHum ;
--2 Noun phrases
--
-- The worst case is pronouns, which have inflection in the possessive forms.
-- Proper names are a special case.
NounPhrase : Type = Pronoun ;
nameNounPhrase : ProperName -> NounPhrase = \john ->
{s = \\c => john.s ! toCase c ; n = Sg ; p = P3} ;
--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 ->
{s = \\c => every.s ++ man.s ! every.n ! toCase c ;
n = every.n ;
p = P3
} ;
mkDeterminer : Number -> Str -> Determiner = \n,det ->
{s = det ;
n = n
} ;
everyDet = mkDeterminer Sg "every" ;
allDet = mkDeterminer Pl "all" ;
mostDet = mkDeterminer Pl "most" ;
aDet = mkDeterminer Sg artIndef ;
plDet = mkDeterminer Pl [] ;
theSgDet = mkDeterminer Sg "the" ;
thePlDet = mkDeterminer Pl "the" ;
anySgDet = mkDeterminer Sg "any" ;
anyPlDet = mkDeterminer Pl "any" ;
whichSgDet = mkDeterminer Sg "which" ;
whichPlDet = mkDeterminer Pl "which" ;
whichDet = whichSgDet ; --- API
indefNoun : Number -> CommNoun -> Str = \n,man ->
(indefNounPhrase n man).s ! NomP ;
indefNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n,man ->
{s = \\c => case n of {
Sg => artIndef ++ man.s ! n ! toCase c ;
Pl => 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} ;
-- 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 ->
{s = \\c => variants {
artDef ++ car.s ! n ! Nom ++ "of" ++ john.s ! GenSP ;
john.s ! GenP ++ car.s ! n ! toCase c
} ;
n = n ;
p = P3
} ;
-- *Bare plural noun phrases* like "men", "good cars", are built without a
-- determiner word.
plurDet : CommNounPhrase -> NounPhrase = \cn ->
{s = \\c => cn.s ! plural ! toCase c ;
p = P3 ;
n = Pl
} ;
-- Constructions like "the idea that two is even" are formed at the
-- first place as common nouns, so that one can also have "a suggestion that...".
nounThatSentence : CommNounPhrase -> Sentence -> CommNounPhrase = \idea,x ->
{s = \\n,c => idea.s ! n ! c ++ "that" ++ x.s ;
g = idea.g
} ;
--2 Adjectives
--
-- Adjectival phrases have a parameter $p$ telling if they are prefixed ($True$) or
-- postfixed (complex APs).
AdjPhrase : Type = Adjective ** {p : Bool} ;
adj2adjPhrase : Adjective -> AdjPhrase = \new -> new ** {p = True} ;
simpleAdjPhrase : Str -> AdjPhrase = \French ->
adj2adjPhrase (simpleAdj French) ;
--3 Comparison adjectives
--
-- Each of the comparison forms has a characteristic use:
--
-- Positive forms are used alone, as adjectival phrases ("big").
positAdjPhrase : AdjDegr -> AdjPhrase = \big ->
adj2adjPhrase (ss (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 ;
p = False
} ;
-- Superlative forms are used with a modified noun, picking out the
-- 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 ;
n = Sg ;
p = P3
} ;
--3 Two-place adjectives
--
-- A two-place adjective is an adjective with a preposition used before
-- the complement.
Preposition = Str ;
AdjCompl = Adjective ** {s2 : Preposition} ;
complAdj : AdjCompl -> NounPhrase -> AdjPhrase = \related,john ->
{s = related.s ++ related.s2 ++ john.s ! AccP ;
p = False
} ;
--3 Modification of common nouns
--
-- The two main functions of adjective are in predication ("John is old")
-- and in modification ("an old man"). Predication will be defined
-- later, in the chapter on verbs.
--
-- Modification must pay attention to pre- and post-noun
-- adjectives: "big car"/"car bigger than X"
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 {}}) ;
g = car.g
} ;
--2 Function expressions
-- A function expression is a common noun together with the
-- preposition prefixed to its argument ("mother of x").
-- The type is analogous to two-place adjectives and transitive verbs.
Function = CommNounPhrase ** {s2 : Preposition} ;
-- The application of a function gives, in the first place, a common noun:
-- "mother/mothers of John". From this, other rules of the resource grammar
-- give noun phrases, such as "the mother of John", "the mothers of John",
-- "the mothers of John and Mary", and "the mother of John and Mary" (the
-- latter two corresponding to distributive and collective functions,
-- respectively). Semantics will eventually tell when each
-- of the readings is meaningful.
appFunComm : Function -> NounPhrase -> CommNounPhrase = \mother,john ->
{s = \\n => table {
Gen => nonExist ; --- ?
_ => mother.s ! n ! Nom ++ mother.s2 ++ john.s ! GenSP
} ;
g = mother.g
} ;
-- It is possible to use a function word as a common noun; the semantics is
-- often existential or indexical.
funAsCommNounPhrase : Function -> CommNounPhrase =
noun2CommNounPhrase ;
-- The following is an aggregate corresponding to the original function application
-- producing "John's mother" and "the mother of John". It does not appear in the
-- resource grammar API any longer.
appFun : Bool -> Function -> NounPhrase -> NounPhrase = \coll, mother,john ->
let {n = john.n ; nf = if_then_else Number coll Sg n} in
variants {
defNounPhrase nf (appFunComm mother john) ;
npGenDet nf john mother
} ;
-- The commonest case is functions with the preposition "of".
funOf : CommNoun -> Function = \mother ->
mother ** {s2 = "of"} ;
funOfReg : Str -> Gender -> Function = \mother,g ->
funOf (nounReg mother ** {g = g}) ;
-- Two-place functions add one argument place.
Function2 = Function ** {s3 : Preposition} ;
-- There application starts by filling the first place.
appFun2 : Function2 -> NounPhrase -> Function = \train, paris ->
{s = \\n,c => train.s ! n ! c ++ train.s2 ++ paris.s ! AccP ;
g = train.g ;
s2 = train.s3
} ;
--2 Verbs
--
--3 Verb phrases
--
-- Verb phrases are discontinuous: the two parts of a verb phrase are
-- (s) an inflected verb, (s2) infinitive and complement.
-- For instance: "doesn't" - "walk" ; "isn't" - "old" ; "is" - "a man"
-- There's also a parameter telling if the verb is an auxiliary:
-- this is needed in question.
VerbPhrase = VerbP3 ** {s2 : Number => Str ; isAux : Bool} ;
-- From the inflection table, we selecting the finite form as function
-- of person and number:
indicVerb : VerbP3 -> Person -> Number -> Str = \v,p,n -> case n of {
Sg => v.s ! Indic p ;
Pl => v.s ! Indic P2
} ;
-- A simple verb can be made into a verb phrase with an empty complement.
-- There are two versions, depending on if we want to negate the verb.
-- N.B. negation is *not* a function applicable to a verb phrase, since
-- double negations with "don't" are not grammatical.
predVerb : Bool -> Verb -> VerbPhrase = \b,walk ->
if_then_else VerbPhrase b
{s = \\v => walk.s ! v ++ walk.s1 ;
s2 = \\_ => [] ;
isAux = False
}
{s = \\v => contractNot (verbP3Do.s ! v) ;
s2 = \\_ => walk.s ! InfImp ++ walk.s1 ;
isAux = True
} ;
-- Sometimes we want to extract the verb part of a verb phrase.
verbOfPhrase : VerbPhrase -> VerbP3 = \v -> {s = v.s} ;
-- Verb phrases can also be formed from adjectives ("is old"),
-- common nouns ("is a man"), and noun phrases ("ist John").
-- The third rule is overgenerating: "is every man" has to be ruled out
-- on semantic grounds.
predAdjective : Bool -> Adjective -> VerbPhrase = \b,old ->
{s = beOrNotBe b ;
s2 = \\_ => old.s ;
isAux = True
} ;
predCommNoun : Bool -> CommNoun -> VerbPhrase = \b,man ->
{s = beOrNotBe b ;
s2 = \\n => indefNoun n man ;
isAux = True
} ;
predNounPhrase : Bool -> NounPhrase -> VerbPhrase = \b,john ->
{s = beOrNotBe b ;
s2 = \\_ => john.s ! NomP ;
isAux = True
} ;
-- 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
--
-- Transitive verbs are verbs with a preposition for the complement,
-- in analogy with two-place adjectives and functions.
-- One might prefer to use the term "2-place verb", since
-- "transitive" traditionally means that the inherent preposition is empty.
-- Such a verb is one with a *direct object*.
TransVerb : Type = Verb ** {s3 : Preposition} ;
-- 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 : Bool -> TransVerb -> NounPhrase -> VerbPhrase =
\b,lookat,john ->
let {lookatjohn = bothWays lookat.s1 (lookat.s3 ++ john.s ! AccP)} in
if_then_else VerbPhrase b
{s = lookat.s ;
s2 = \\_ => lookatjohn ;
isAux = False}
{s = \\v => contractNot (verbP3Do.s ! v) ;
s2 = \\_ => lookat.s ! InfImp ++ lookatjohn ;
isAux = True} ;
-- 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 [] ;
-- Transitive verbs with accusative objects can be used passively.
-- The function does not check that the verb is transitive.
-- Therefore, the function can also be used for "he is swum", etc.
-- The syntax is the same as for adjectival predication.
passVerb : Bool -> Verb -> VerbPhrase = \b,love ->
predAdjective b (adj2adjPhrase (ss (love.s ! PPart))) ;
-- Transitive verbs can be used elliptically as verbs. The semantics
-- is left to applications. The definition is trivial, due to record
-- subtyping.
transAsVerb : TransVerb -> Verb = \love ->
love ;
-- *Ditransitive verbs* are verbs with three argument places.
-- We treat so far only the rule in which the ditransitive
-- verb takes both complements to form a verb phrase.
DitransVerb = TransVerb ** {s4 : Preposition} ;
mkDitransVerb : Verb -> Preposition -> Preposition -> DitransVerb = \v,p1,p2 ->
v ** {s3 = p1 ; s4 = p2} ;
complDitransVerb :
Bool -> DitransVerb -> NounPhrase -> NounPhrase -> VerbPhrase =
\b,give,you,beer ->
let {
youbeer = give.s1 ++ give.s3 ++ you.s ! AccP ++ give.s4 ++ beer.s ! AccP
} in
if_then_else VerbPhrase b
{s = give.s ;
s2 = \\_ => youbeer ;
isAux = False
}
{s = \\v => contractNot (verbP3Do.s ! v) ;
s2 = \\_ => give.s ! InfImp ++ youbeer ;
isAux = True
} ;
--2 Adverbials
--
-- Adverbials 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.
Adverb : Type = SS ** {p : Bool} ;
advPre : Str -> Adverb = \seldom -> ss seldom ** {p = False} ;
advPost : Str -> Adverb = \well -> ss well ** {p = True} ;
-- N.B. this rule generates the cyclic parsing rule $VP#2 ::= VP#2$
-- and cannot thus be parsed.
adVerbPhrase : VerbPhrase -> Adverb -> VerbPhrase = \sings, well ->
let {postp = orB well.p sings.isAux} in
{
s = \\v => (if_then_else Str postp [] well.s) ++ sings.s ! v ;
s2 = \\n => sings.s2 ! n ++ (if_then_else Str postp well.s []) ;
isAux = sings.isAux
} ;
advAdjPhrase : SS -> AdjPhrase -> AdjPhrase = \very, good ->
{s = very.s ++ good.s ;
p = good.p
} ;
-- Adverbials are typically generated by prefixing prepositions.
-- The rule for creating locative noun phrases by the preposition "in"
-- is a little shaky, since other prepositions may be preferred ("on", "at").
prepPhrase : Preposition -> NounPhrase -> Adverb = \on, it ->
advPost (on ++ it.s ! AccP) ;
locativeNounPhrase : NounPhrase -> Adverb =
prepPhrase "in" ;
-- This is a source of the "mann 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 ->
{s = \\n => table {
Nom => car.s ! n ! Nom ++ today.s ;
Gen => nonExist
} ;
g = car.g
} ;
--2 Sentences
--
-- Sentences are not inflected in this fragment of English without tense.
Sentence : Type = SS ;
-- This is the traditional $S -> NP VP$ rule. It takes care of
-- agreement between subject and verb. Recall that the VP may already
-- contain negation.
predVerbPhrase : NounPhrase -> VerbPhrase -> Sentence = \john,walks ->
ss (john.s ! NomP ++ indicVerb (verbOfPhrase walks) john.p john.n ++
walks.s2 ! john.n) ;
-- This is a macro for simultaneous predication and complementization.
predTransVerb : Bool -> NounPhrase -> TransVerb -> NounPhrase -> Sentence =
\b,you,see,john ->
predVerbPhrase you (complTransVerb b see john) ;
--3 Sentence-complement verbs
--
-- Sentence-complement verbs take sentences as complements.
SentenceVerb : Type = Verb ;
-- To generate "says that John walks" / "doesn't say that John walks":
complSentVerb : Bool -> SentenceVerb -> Sentence -> VerbPhrase =
\b,say,johnruns ->
let {thatjohnruns = optStr "that" ++ johnruns.s} in
if_then_else VerbPhrase b
{s = say.s ;
s2 = \\_ => thatjohnruns ;
isAux = False}
{s = \\v => contractNot (verbP3Do.s ! v) ;
s2 = \\_ => say.s ! InfImp ++ thatjohnruns ;
isAux = True} ;
--2 Sentences missing noun phrases
--
-- This is one instance of Gazdar's *slash categories*, corresponding to his
-- $S/NP$.
-- We cannot have - nor would we want to have - a productive slash-category former.
-- Perhaps a handful more will be needed.
--
-- Notice that the slash category has a similar relation to sentences as
-- transitive verbs have to verbs: it's like a *sentence taking a complement*.
-- However, we need something more to distinguish its use in direct questions:
-- not just "you see" but ("whom") "do you see".
--
-- The particle always follows the verb, but the preposition can fly:
-- "whom you make it up with" / "with whom you make it up".
SentenceSlashNounPhrase = {s : Bool => Str ; 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
} ;
--2 Relative pronouns and relative clauses
--
-- As described in $types.Eng.gf$, relative pronouns are inflected in
-- gender (human/nonhuman), number, and case.
--
-- We get the simple relative pronoun ("who"/"which"/"whom"/"whose"/"that"/$""$)
-- from $morpho.Eng.gf$.
identRelPron : RelPron = relPron ;
funRelPron : Function -> RelPron -> RelPron = \mother,which ->
{s = \\g,n,c => "the" ++ mother.s ! n ! Nom ++
mother.s2 ++ which.s ! g ! n ! GenSP
} ;
-- 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
} ;
relSlash : RelPron -> SentenceSlashNounPhrase -> RelClause = \who,yousee ->
{s = \\g,n =>
let {youSee = yousee.s ! False} in
variants {
who.s ! g ! n ! AccP ++ youSee ++ yousee.s2 ;
yousee.s2 ++ who.s ! g ! n ! GenSP ++ youSee
}
} ;
-- A 'degenerate' relative clause is the one often used in mathematics, e.g.
-- "number x such that x is even".
relSuch : Sentence -> RelClause = \A ->
{s = \\_,_ => "such" ++ "that" ++ A.s} ;
-- The main use of relative clauses is to modify common nouns.
-- The result is a common noun, out of which noun phrases can be formed
-- by determiners. No comma is used before these relative clause.
modRelClause : CommNounPhrase -> RelClause -> CommNounPhrase = \man,whoruns ->
{s = \\n,c => man.s ! n ! c ++ whoruns.s ! man.g ! n ;
g = man.g
} ;
--2 Interrogative pronouns
--
-- If relative pronouns are adjective-like, interrogative pronouns are
-- noun-phrase-like.
IntPron : Type = {s : NPForm => Str ; n : Number} ;
-- In analogy with relative pronouns, we have a rule for applying a function
-- to a relative pronoun to create a new one.
funIntPron : Function -> IntPron -> IntPron = \mother,which ->
{s = \\c => "the" ++ mother.s ! which.n ! Nom ++ mother.s2 ++ which.s ! GenSP ;
n = which.n
} ;
-- There is a variety of simple interrogative pronouns:
-- "which house", "who", "what".
nounIntPron : Number -> CommNounPhrase -> IntPron = \n, car ->
{s = \\c => "which" ++ car.s ! n ! toCase c ;
n = n
} ;
intPronWho : Number -> IntPron = \num -> {
s = table {
NomP => "who" ;
AccP => variants {"who" ; "whom"} ;
GenP => "whose" ;
GenSP => "whom"
} ;
n = num
} ;
intPronWhat : Number -> IntPron = \num -> {
s = table {
GenP => "what's" ;
_ => "what"
} ;
n = num
} ;
--2 Utterances
-- By utterances we mean whole phrases, such as
-- 'can be used as moves in a language game': indicatives, questions, imperative,
-- and one-word utterances. The rules are far from complete.
--
-- N.B. we have not included rules for texts, which we find we cannot say much
-- about on this level. In semantically rich GF grammars, texts, dialogues, etc,
-- will of course play an important role as categories not reducible to utterances.
-- An example is proof texts, whose semantics show a dependence between premises
-- and conclusions. Another example is intersentential anaphora.
Utterance = SS ;
indicUtt : Sentence -> Utterance = \x -> ss (x.s ++ ".") ;
interrogUtt : Question -> Utterance = \x -> ss (x.s ! DirQ ++ "?") ;
--2 Questions
--
-- Questions are either direct ("are you happy") or indirect
-- ("if/whether you are happy").
param
QuestForm = DirQ | IndirQ ;
oper
Question = SS1 QuestForm ;
--3 Yes-no questions
--
-- Yes-no questions are used both independently
-- ("does John walk" / "if John walks")
-- and after interrogative adverbials
-- ("why does John walk" / "why John walks").
--
-- It is economical to handle with all these cases by the one
-- rule, $questVerbPhrase'$. The word ("ob" / "whether") never appears
-- if there is an adverbial.
questVerbPhrase : NounPhrase -> VerbPhrase -> Question =
questVerbPhrase' False ;
questVerbPhrase' : Bool -> NounPhrase -> VerbPhrase -> Question =
\adv,john,walk ->
{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) ;
IndirQ => if_then_else Str adv [] (variants {"if" ; "whether"}) ++
(predVerbPhrase john walk).s
}
} ;
isThere : Number -> CommNounPhrase -> Question = \n,bar ->
questVerbPhrase
(case n of {
Sg => nameNounPhrase (nameReg "there") ;
Pl => {s = \\_ => "there" ; n = Pl ; p = P3}
})
(predNounPhrase True (indefNounPhrase n bar)) ;
--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
} ;
intSlash : IntPron -> SentenceSlashNounPhrase -> Question = \who,yousee ->
{s = \\q =>
let {youSee = case q of {
DirQ => yousee.s ! True ;
IndirQ => yousee.s ! False
}
} in
variants {
who.s ! AccP ++ youSee ++ yousee.s2 ;
yousee.s2 ++ who.s ! GenSP ++ youSee
}
} ;
--3 Interrogative adverbials
--
-- These adverbials 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
-- from noun phrases.
IntAdverb = SS ;
prepIntAdverb : Preposition -> IntPron -> IntAdverb = \at, whom ->
ss (at ++ whom.s ! AccP) ;
-- A question adverbial can be applied to anything, and whether this makes
-- sense is a semantic question.
questAdverbial : IntAdverb -> NounPhrase -> VerbPhrase -> Question =
\why, you, walk ->
{s = \\q => why.s ++ (questVerbPhrase' True you walk).s ! q} ;
--2 Imperatives
--
-- We only consider second-person imperatives.
Imperative = SS1 Number ;
imperVerbPhrase : VerbPhrase -> Imperative = \walk ->
{s = \\n => walk.s ! InfImp ++ walk.s2 ! n} ;
imperUtterance : Number -> Imperative -> Utterance = \n,I ->
ss (I.s ! n ++ "!") ;
--2 Sentence adverbials
--
-- This class covers adverbials such as "otherwise", "therefore", which are prefixed
-- to a sentence to form a phrase.
advSentence : SS -> Sentence -> Utterance = \hence,itiseven ->
ss (hence.s ++ itiseven.s ++ ".") ;
--2 Coordination
--
-- Coordination is to some extent orthogonal to the rest of syntax, and
-- has been treated in a generic way in the module $CO$ in the file
-- $coordination.gf$. The overall structure is independent of category,
-- but there can be differences in parameter dependencies.
--
--3 Conjunctions
--
-- Coordinated phrases are built by using conjunctions, which are either
-- simple ("and", "or") or distributed ("both - and", "either - or").
--
-- The conjunction has an inherent number, which is used when conjoining
-- noun phrases: "John and Mary are..." vs. "John or Mary is..."; in the
-- case of "or", the result is however plural if any of the disjuncts is.
Conjunction = CO.Conjunction ** {n : Number} ;
ConjunctionDistr = CO.ConjunctionDistr ** {n : Number} ;
--3 Coordinating sentences
--
-- We need a category of lists of sentences. It is a discontinuous
-- category, the parts corresponding to 'init' and 'last' segments
-- (rather than 'head' and 'tail', because we have to keep track of the slot between
-- the last two elements of the list). A list has at least two elements.
ListSentence : Type = SD2 ;
twoSentence : (_,_ : Sentence) -> ListSentence = CO.twoSS ;
consSentence : ListSentence -> Sentence -> ListSentence =
CO.consSS CO.comma ;
-- To coordinate a list of sentences by a simple conjunction, we place
-- it between the last two elements; commas are put in the other slots,
-- e.g. "du rauchst, er trinkt und ich esse".
conjunctSentence : Conjunction -> ListSentence -> Sentence = \c,xs ->
ss (CO.conjunctX c xs) ;
-- To coordinate a list of sentences by a distributed conjunction, we place
-- the first part (e.g. "either") in front of the first element, the second
-- part ("or") between the last two elements, and commas in the other slots.
-- For sentences this is really not used.
conjunctDistrSentence : ConjunctionDistr -> ListSentence -> Sentence =
\c,xs ->
ss (CO.conjunctDistrX c xs) ;
--3 Coordinating adjective phrases
--
-- The structure is the same as for sentences. The result is a prefix adjective
-- if and only if all elements are prefix.
ListAdjPhrase : Type = SD2 ** {p : Bool} ;
twoAdjPhrase : (_,_ : AdjPhrase) -> ListAdjPhrase = \x,y ->
CO.twoStr x.s y.s ** {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} ;
conjunctAdjPhrase : Conjunction -> ListAdjPhrase -> AdjPhrase = \c,xs ->
ss (CO.conjunctX c xs) ** {p = xs.p} ;
conjunctDistrAdjPhrase : ConjunctionDistr -> ListAdjPhrase -> AdjPhrase =
\c,xs ->
ss (CO.conjunctDistrX c xs) ** {p = xs.p} ;
--3 Coordinating noun phrases
--
-- The structure is the same as for sentences. The result is either always plural
-- or plural if any of the components is, depending on the conjunction.
ListNounPhrase : Type = {s1,s2 : NPForm => Str ; n : Number ; p : Person} ;
twoNounPhrase : (_,_ : NounPhrase) -> ListNounPhrase = \x,y ->
CO.twoTable NPForm x y ** {n = conjNumber x.n y.n ; p = conjPerson x.p y.p} ;
consNounPhrase : ListNounPhrase -> NounPhrase -> ListNounPhrase = \xs,x ->
CO.consTable NPForm CO.comma xs x **
{n = conjNumber xs.n x.n ; p = conjPerson xs.p x.p} ;
conjunctNounPhrase : Conjunction -> ListNounPhrase -> NounPhrase = \c,xs ->
CO.conjunctTable NPForm c xs ** {n = conjNumber c.n xs.n ; p = xs.p} ;
conjunctDistrNounPhrase : ConjunctionDistr -> ListNounPhrase -> NounPhrase =
\c,xs ->
CO.conjunctDistrTable NPForm c xs ** {n = conjNumber c.n xs.n ; p = xs.p} ;
-- We have to define a calculus of numbers of persons. For numbers,
-- it is like the conjunction with $Pl$ corresponding to $False$.
conjNumber : Number -> Number -> Number = \m,n -> case <m,n> of {
<Sg,Sg> => Sg ;
_ => Pl
} ;
-- For persons, we let the latter argument win ("either you or I am absent"
-- but "either I or you are absent"). This is not quite clear.
conjPerson : Person -> Person -> Person = \_,p ->
p ;
--2 Subjunction
--
-- Subjunctions ("when", "if", etc)
-- are a different way to combine sentences than conjunctions.
-- The main clause can be a sentences, an imperatives, or a question,
-- but the subjoined clause must be a sentence.
--
-- There are uniformly two variant word orders, e.g.
-- "if you smoke I get angry"
-- and "I get angry if you smoke".
Subjunction = SS ;
subjunctSentence : Subjunction -> Sentence -> Sentence -> Sentence =
\if, A, B ->
ss (subjunctVariants if A.s B.s) ;
subjunctImperative : Subjunction -> Sentence -> Imperative -> Imperative =
\if, A, B ->
{s = \\n => subjunctVariants if A.s (B.s ! n)} ;
subjunctQuestion : Subjunction -> Sentence -> Question -> Question =
\if, A, B ->
{s = \\q => subjunctVariants if A.s (B.s ! q)} ;
subjunctVariants : Subjunction -> Str -> Str -> Str = \if,A,B ->
variants {if.s ++ A ++ "," ++ B ; B ++ "," ++ if.s ++ A} ;
subjunctVerbPhrase : VerbPhrase -> Subjunction -> Sentence -> VerbPhrase =
\V, if, A ->
adVerbPhrase V (advPost (if.s ++ A.s)) ;
--2 One-word utterances
--
-- An utterance can consist of one phrase of almost any category,
-- the limiting case being one-word utterances. These
-- utterances are often (but not always) in what can be called the
-- default form of a category, e.g. the nominative.
-- This list is far from exhaustive.
useNounPhrase : NounPhrase -> Utterance = \john ->
postfixSS "." (defaultNounPhrase john) ;
useCommonNounPhrase : Number -> CommNounPhrase -> Utterance = \n,car ->
useNounPhrase (indefNounPhrase n car) ;
useRegularName : SS -> NounPhrase = \john ->
nameNounPhrase (nameReg john.s) ;
-- Here are some default forms.
defaultNounPhrase : NounPhrase -> SS = \john ->
ss (john.s ! NomP) ;
defaultQuestion : Question -> SS = \whoareyou ->
ss (whoareyou.s ! DirQ) ;
defaultSentence : Sentence -> Utterance = \x ->
x ;
} ;

View File

@@ -0,0 +1,46 @@
-- use this path to read the grammar from the same directory
--# -path=.:../nabstract:../../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 = mkAdjDegr "big" "bigger" "biggest";
Small = adjDegrReg "small" ;
Old = adjDegrReg "old" ;
Young = adjDegrReg "young" ;
American = simpleAdj "American" ;
Finnish = simpleAdj "Finnish" ;
Married = simpleAdj "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") ;
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" ;
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,101 @@
--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.
-- Such adjectives are simply strings.
Adjective : Type = SS ;
AdjDegr = SS1 Degree ;
--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} ;
} ;