1
0
forked from GitHub/gf-core

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

@@ -1,6 +1,6 @@
--# -path=.:../resource/nabstract:../resource/nenglish:../prelude
concrete DatabaseEng of Database = open Prelude, ResEng in {
concrete DatabaseEng of Database = open Prelude, ResourceEng in {
flags lexer=text ; unlexer=text ;
@@ -17,8 +17,8 @@ lincat
lin
WhichAre A B = QuestPhrase (IntVP (NounIPMany A) (PosVG (PredAP B))) ;
IsThere A = QuestPhrase (IsThereCN A) ;
AreThere A = QuestPhrase (AreThereCN NoNum A) ;
IsThere A = QuestPhrase (IsThereNP (IndefOneNP A)) ;
AreThere A = QuestPhrase (IsThereNP (IndefManyNP NoNum A)) ;
WhatIs val = QuestPhrase (IntVP WhatOne (PosVG (PredNP val))) ;
IsIt Q A = QuestPhrase (QuestVP Q (PosVG (PredAP A))) ;

View File

@@ -1,7 +1,7 @@
--# -path=.:../resource/nabstract:../resource/nenglish:../prelude
concrete RestaurantEng of Restaurant =
DatabaseEng ** open Prelude,ParadigmsEng in {
DatabaseEng ** open Prelude, ParadigmsEng in {
lin
Restaurant = cnNonhuman "restaurant" ;

View File

@@ -0,0 +1,331 @@
--1 Abstract Syntax for Multilingual Resource Grammar
--
-- Aarne Ranta 2002 -- 2003
--
-- Although concrete syntax differs a lot between different languages,
-- many structures can be treated as common, on the level
-- of abstraction that GF provides.
-- What we will present in the following is a linguistically oriented abstract
-- syntax that has been successfully defined for the following languages:
--
--* $Eng$lish
--* $Fin$nish
--* $Fre$nch
--* $Ger$man
--* $Ita$lian
--* $Rus$sian
--* $Swe$dish
--
-- The three-letter prefixes are used in file names all over the resource
-- grammar library; we refer to them commonly as $X$ below.
--!
-- The grammar 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, instead of this module, the $reuse$ module which has the name
-- $ResourceX$
abstract Combinations = PredefAbs ** {
--!
--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. In general, the correspondence between linguistic
-- and semantic categories is many-to-many.
--
-- 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. Prepositional
-- phrases that are not complements belong to the category
-- $AdV$ of adverbials.
--
-- In each group below, some categories are *lexical* in the sense of only
-- containing atomic elements. These elements are not necessarily expressed by
-- one word in all languages; the essential thing is that they have no
-- constituents. Thus they have no productions in this part of the
-- resource grammar. The $ParadigmsX$ grammars provide ways of defining
-- lexical elements.
--
-- Lexical categories are listed before other categories
-- in each group and divided by an empty line.
--!
--3 Nouns and noun phrases
--
cat
N ; -- simple common noun, e.g. "car"
PN ; -- proper name, e.g. "John", "New York"
Fun ; -- function word, e.g. "mother (of)"
Fun2 ; -- two-place function, e.g. "flight (from) (to)"
CN ; -- common noun phrase, e.g. "red car", "car that John owns"
NP ; -- noun phrase, e.g. "John", "all cars", "you"
Det ; -- determiner, e.g. "every", "all"
Num ; -- numeral, e.g. "three", "879"
--!
--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"
-- The difference between $Adj1$ and $AdjDeg$ is that the former has no
-- comparison forms.
--!
--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"
VV ; -- verb-compl. verb, e.g. "can", "want"
VG ; -- verbal group, e.g. "switch the light on"
VP ; -- verb phrase, e.g. "switch the light on", "don't run"
--!
--3 Adverbials
--
-- This group has no lexical categories.
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
--
-- This group has no lexical categories.
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
--
-- This group has no lexical categories.
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
--
-- This group has no lexical categories.
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"
UsePN : PN -> NP ; -- "John"
UseFun : Fun -> CN ; -- "successor"
UseInt : Int -> Num ; -- "32" --- assumes i > 1
ModAdj : AP -> CN -> CN ; -- "red car"
DetNP : Det -> CN -> NP ; -- "every car"
MassNP : CN -> NP ; -- "wine"
IndefOneNP : CN -> NP ; -- "a car", "cars"
IndefManyNP : Num -> CN -> NP ; -- "houses", "86 houses"
DefOneNP : CN -> NP ; -- "the car"
DefManyNP : Num -> CN -> NP ; -- "the cars", "the 86 cars"
ModGenOne : NP -> CN -> NP ; -- "John's car"
ModGenMany : Num -> NP -> CN -> NP ; -- "John's cars", "John's 86 cars"
AppFun : Fun -> NP -> CN ; -- "successor of zero"
AppFun2 : Fun2 -> NP -> Fun ; -- "flight from Paris"
CNthatS : CN -> S -> CN ; -- "idea that the Earth is flat"
NoNum : Num ; -- no numeral modifier
--!
--3 Adjectives and adjectival phrases
--
AdjP1 : Adj1 -> AP ; -- "red"
PositAdjP : AdjDeg -> AP ; -- "old"
ComplAdj : Adj2 -> NP -> AP ; -- "divisible by two"
ComparAdjP : AdjDeg -> NP -> AP ; -- "older than John"
SuperlNP : AdjDeg -> CN -> NP ; -- "the oldest man"
--!
--3 Verbs and verb phrases
--
-- The principal way of forming sentences ($S$) is by combining a noun phrase
-- with a verb phrase (the $PredVP$ rule below). In addition to this, verb
-- phrases have uses in relative clauses and questions. Verb phrases already
-- have (or have not) a negation, but they are formed from verbal groups
-- ($VG$), which have both positive and negative forms.
PredV : V -> VG ; -- "walk", "doesn't walk"
PredPassV : V -> VG ; -- "is seen", "is not seen"
PredTV : TV -> NP -> VG ; -- "sees John", "doesn't see John"
PredVS : VS -> S -> VG ; -- "says that I run", "doesn't say..."
PredVV : VV -> VG -> VG ; -- "can run", "can't run", "tries to run"
PredV3 : V3 -> NP -> NP -> VG ; -- "prefers wine to beer"
PredNP : NP -> VG ; -- "is John", "is not John"
PredAdV : AdV -> VG ; -- "is everywhere", "is not in France"
PredAP : AP -> VG ; -- "is old", "isn't old"
PredCN : CN -> VG ; -- "is a man", "isn't a man"
VTrans : TV -> V ; -- "loves"
PosVG,NegVG : VG -> VP ; --
--!
--3 Adverbials
--
-- Here is how complex adverbials can be formed and used.
AdjAdv : AP -> AdV ; -- "freely", "more consciously than you"
PrepNP : Prep -> NP -> AdV ; -- "in London", "after the war"
AdvVP : VP -> AdV -> VP ; -- "always walks", "walks in the park"
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"
ThereNP : NP -> S ; -- "there is a bar","there are 86 bars"
IdRP : RP ; -- "which"
FunRP : Fun -> RP -> RP ; -- "the successor of which"
RelVP : RP -> VP -> RC ; -- "who walks", "who doesn't walk"
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"; "doesn't 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"
IsThereNP : NP -> Qu ; -- "is there a bar", "are there (86) 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,90 @@
--1 GF Resource Grammar API for Structural Words
--
-- AR 21/11/2003
--
-- 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
--!
--2 Determiners and noun phrases
--
-- Many plural determiners can take a numeral modifier. So can the plural
-- pronouns "we" and "you".
EveryDet, WhichDet, AllDet, -- every, sg which, sg all
SomeDet, AnyDet, NoDet, -- sg some, any, no
MostDet, MostsDet, ManyDet, MuchDet : Det ; -- sg most, pl most, many, much
ThisDet, ThatDet : Det ; -- this, that
AllsDet, WhichsDet, -- pl all, which (86)
SomesDet, AnysDet, NosDet, -- pl some, any, no
TheseDet, ThoseDet : Num -> Det ; -- these, those (86)
ThisNP, ThatNP : NP ; -- this, that
TheseNP, ThoseNP : Num -> NP ; -- these, those (86)
INP, ThouNP, HeNP, SheNP, ItNP : NP ; -- personal pronouns in singular
WeNP, YeNP : Num -> NP ; -- these pronouns can take numeral
TheyNP : NP ; YouNP : NP ; -- they, the polite you
EverybodyNP, SomebodyNP, NobodyNP, -- everybody, somebody, nobody
EverythingNP, SomethingNP, NothingNP : NP ; -- everything, something, nothing
--!
--2 Auxiliary verbs
--
-- Depending on language, all, some, or none of there verbs belong to
-- a separate class of *auxiliary* verbs. The list is incomplete.
CanVV, CanKnowVV, MustVV : VV ; -- can (pouvoir/savoir), must
WantVV : VV ; -- want (to do)
--!
--2 Adverbials
--
WhenIAdv,WhereIAdv,WhyIAdv,HowIAdv : IAdv ; -- when, where, why, how
EverywhereNP, SomewhereNP,NowhereNP : AdV ; -- everywhere, somewhere, nowhere
VeryAdv, TooAdv : AdA ; -- very, too
AlmostAdv, QuiteAdv : AdA ; -- almost, quite
OtherwiseAdv, ThereforeAdv : AdS ; -- therefore, otherwise
--!
--2 Conjunctions and subjunctions
--
AndConj, OrConj : Conj ; -- and, or
BothAnd, EitherOr, NeitherNor : ConjD ; -- both-and, either-or, neither-nor
IfSubj, WhenSubj, AlthoughSubj : Subj ; -- if, when, although
--!
--2 Prepositions
--
-- We have carefully chosen a set of semantic relations expressible
-- by prepositions in some languages, by cases or postpositions in
-- others. Complement uses of prepositions are not included, and
-- should be treated by the use of many-place verbs, adjectives, and
-- functions.
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
PartPrep : Prep ; -- partitive "of" ("bottle of wine")
AgentPrep : Prep ; -- agent "by" in passive constructions
--!
--2 Affirmation and negation
--
-- The negative-positive (French "si", German "doch") is missing.
PhrYes, PhrNo : Phr ; -- yes, no
}

View File

@@ -0,0 +1,18 @@
abstract TestResource = Structural ** {
-- a random sample of lexicon to test resource grammar with
fun
Big, Happy, Small, Old, Young : AdjDeg ;
American, Finnish : Adj1 ;
Married : Adj2 ;
Man, Woman, Car, House, Light, Bar, Bottle, Wine : N ;
Walk, Run : V ;
Send, Wait, Love, Drink, 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,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} ;
} ;

View File

@@ -0,0 +1,199 @@
--# -path=.:../abstract:../../prelude
--1 The Top-Level Swedish Resource Grammar: Combination Rules
--
-- Aarne Ranta 2002 -- 2003
--
-- This is the Swedish concrete syntax of the multilingual resource
-- grammar. Most of the work is done in the file $SyntaxSwe.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 $TypesSwe.gf$.
concrete CombinationsSwe of Combinations = open Prelude, SyntaxSwe in {
flags
startcat=Phr ;
lexer=text ;
unlexer=text ;
lincat
CN = {s : Number => SpeciesP => Case => Str ; g : Gender ; x : Sex ;
p : IsComplexCN} ;
N = CommNoun ;
-- = {s : Number => Species => Case => Str ; g : Gender ; x : Sex} ;
NP = NounPhrase ;
-- = {s : NPForm => Str ; g : Gender ; n : Number} ;
PN = {s : Case => Str ; g : Gender ; x : Sex} ;
Det = {s : Gender => Sex => Str ; n : Number ; b : SpeciesP} ;
Fun = Function ;
-- = CommNoun ** {s2 : Preposition} ;
Fun2 = Function ** {s3 : Preposition} ;
Num = {s : Case => Str} ;
Prep = {s : Str} ;
Adj1 = Adjective ;
-- = {s : AdjFormPos => Case => Str} ;
Adj2 = Adjective ** {s2 : Preposition} ;
AdjDeg = {s : AdjForm => Str} ;
AP = Adjective ** {p : IsPostfixAdj} ;
V = Verb ;
-- = {s : VForm => Str ; s1 : Str} ;
VG = {s : VForm => Str ; s2 : Bool => Str ; s3 : Gender => Number => Str} ;
VP = {s : VForm => Str ; s2 : Str ; s3 : Gender => Number => Str} ;
TV = TransVerb ;
-- = Verb ** {s2 : Preposition} ;
V3 = TransVerb ** {s3 : Preposition} ;
VS = Verb ;
VV = Verb ** {isAux : Bool} ;
AdV = {s : Str ; isPost : Bool} ;
S = Sentence ;
-- = {s : Order => Str} ;
Slash = Sentence ** {s2 : Preposition} ;
RP = {s : RelCase => GenNum => Str ; g : RelGender} ;
RC = {s : GenNum => Str} ;
IP = NounPhrase ;
Qu = {s : QuestForm => Str} ;
Imp = {s : Number => Str} ;
Phr = {s : Str} ;
Conj = {s : Str ; n : Number} ;
ConjD = {s1 : Str ; s2 : Str ; n : Number} ;
ListS = {s1,s2 : Order => Str} ;
ListAP = {s1,s2 : AdjFormPos => Case => Str ; p : Bool} ;
ListNP = {s1,s2 : NPForm => Str ; g : Gender ; n : Number} ;
--.
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 (mkDeterminerSg (detSgInvar []) IndefP) ;
UseInt i = {s = table {Nom => i.s ; Gen => i.s ++ "s"}} ; ---
NoNum = noNum ;
CNthatS = nounThatSentence ;
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 ! adverbForm ! Nom) ;
PrepNP p = prepPhrase p.s ; ---
AdvVP = adVerbPhrase ;
AdvCN = advCommNounPhrase ;
AdvAP = advAdjPhrase ;
ThereNP A = predVerbPhrase npDet
(predVerbGroup True
(complTransVerb (mkDirectVerb verbFinnas) A)) ;
PosSlashTV = slashTransVerb True ;
NegSlashTV = slashTransVerb False ;
OneVP = predVerbPhrase npMan ;
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 A = questVerbPhrase npDet
(predVerbGroup True
(complTransVerb (mkDirectVerb verbFinnas) A)) ;
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 ;
} ;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,292 @@
--# -path=.:../abstract:../../prelude
--1 Swedish Lexical Paradigms
--
-- Aarne Ranta 2003
--
-- This is an API to the user of the resource grammar
-- for adding lexical items. It give shortcuts for forming
-- expressions of basic categories: nouns, adjectives, verbs.
--
-- Closed categories (determiners, pronouns, conjunctions) are
-- accessed through the resource syntax API, $Structural.gf$.
--
-- The main difference with $MorphoSwe.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 ParadigmsSwe = open (Predef=Predef), Prelude, SyntaxSwe, ResourceSwe in {
--2 Parameters
--
-- To abstract over gender names, we define the following identifiers.
oper
utrum : Gender ;
neutrum : Gender ;
masculine : Sex ;
nonmasculine : Sex ;
-- To abstract over case names, we define the following.
nominative : Case ;
genitive : Case ;
-- To abstract over number names, we define the following.
singular : Number ;
plural : Number ;
--2 Nouns
-- Worst case: give all nominative forms and the gender.
-- The genitive is formed automatically, even when the nominative
-- ends with an "s".
mkN : (_,_,_,_ : Str) -> Gender -> Sex -> N ;
-- man, mannen, män, männen
-- Here are some common patterns, corresponding to school-gramamr declensions.
-- Except $nPojke$, $nKarl$, and $nMurare$,
-- they are defined to be $nonmasculine$, which means that they don't create
-- the definite adjective form with "e" but with "a".
nApa : Str -> N ; -- apa (apan, apor, aporna) ; utrum
nBil : Str -> N ; -- bil (bilen, bilar, bilarna) ; utrum
nKarl : Str -> N ; -- karl (karlen, karlar, karlarna) ; utrum ; masculine
nPojke : Str -> N ; -- pojke (pojken, pojkar, pojkarna) ; utrum ; masculine
nNyckel : Str -> N ; -- nyckel (nyckeln, nycklar, nycklarna) ; utrum
nRisk : Str -> N ; -- risk (risken, risker, riskerna) ; utrum
nDike : Str -> N ; -- dike (diket, diken, dikena) ; neutrum
nRep : Str -> N ; -- rep (repet, rep, repen) ; neutrum
nPapper : Str -> N ; -- papper (pappret, papper, pappren) ; neutrum
nMurare : Str -> N ; -- murare (muraren, murare, murarna) ; utrum ; masculine
nKikare : Str -> N ; -- kikare (kikaren, kikare, kikarna) ; utrum
-- Nouns used as functions need a preposition. The most common ones are "av",
-- "på", and "till".
mkFun : N -> Preposition -> Fun ;
funAv : N -> Fun ;
funPaa : N -> Fun ;
funTill : N -> Fun ;
-- Proper names, with their possibly
-- irregular genitive. The regular genitive is "s", omitted after "s".
mkPN : (_,_ : Str) -> Gender -> Sex -> PN ; -- Karolus, Karoli
pnReg : Str -> Gender -> Sex -> PN ; -- Johan,Johans ; Johannes, Johannes
-- On the top level, it is maybe $CN$ that is used rather than $N$, and
-- $NP$ rather than $PN$.
mkCN : N -> CN ;
mkNP : (Karolus, Karoli : Str) -> Gender -> NP ;
npReg : Str -> Gender -> NP ; -- Johann, Johanns
--2 Adjectives
-- Non-comparison one-place adjectives need four forms in the worst case:
-- strong singular, weak singular, plural.
mkAdj1 : (_,_,_,_ : Str) -> Adj1 ; -- liten, litet, lilla, små
-- Special cases needing one form each are: regular adjectives,
-- adjectives with unstressed "e" in the last syllable, those
-- ending with "n" as a further special case, and invariable
-- adjectives.
adjReg : Str -> Adj1 ; -- billig (billigt, billiga, billiga)
adjNykter : Str -> Adj1 ; -- nykter (nyktert, nyktra, nyktra)
adjGalen : Str -> Adj1 ; -- galen (galet, galna, galna)
adjInvar : Str -> Adj1 ; -- bra
-- Two-place adjectives need a preposition and a case as extra arguments.
mkAdj2 : Adj1 -> Str -> Adj2 ; -- delbar, med
mkAdj2Reg : Str -> Str -> Adj2 ; --
-- Comparison adjectives may need the three four forms for the positive case, plus
-- three more forms for the comparison cases.
mkAdjDeg : (liten, litet, lilla, sma, mindre, minst, minsta : Str) -> AdjDeg ;
-- Some comparison adjectives are completely regular.
aReg : Str -> AdjDeg ;
-- On top level, there are adjectival phrases. The most common case is
-- just to use a one-place adjective. The variation in $adjGen$ is taken
-- into account.
apReg : Str -> AP ;
--2 Verbs
--
-- The fragment only has present tense so far.
-- The worst case needs three forms: the infinitive, the indicative, and the
-- imperative.
mkV : (_,_,_ : Str) -> V ; -- vara, är, var; trivas, trivs, trivs
-- The main conjugations need one string each.
vKoka : Str -> V ; -- tala (talar, tala)
vSteka : Str -> V ; -- leka (leker, lek)
vBo : Str -> V ; -- bo (bor, bo)
vAndas : Str -> V ; -- andas [all forms the same: also "slåss"]
vTrivas : Str -> V ; -- trivas (trivs, trivs)
-- The verbs 'be' and 'have' are special.
vVara : V ;
vHa : V ;
-- Particle verbs are formed by putting together a verb and a particle.
-- If the verb already has a particle, it is replaced by the new one.
mkPartV : V -> Str -> V ; -- stänga av ;
-- Two-place verbs, and the special case with direct object.
mkTV : V -> Preposition -> TV ; -- tycka, om
tvDir : V -> TV ; -- gilla
-- The definitions should not bother the user of the API. So they are
-- hidden from the document.
--.
utrum = Utr ;
neutrum = Neutr ;
masculine = Masc ;
nonmasculine = NoMasc ;
nominative = Nom ;
genitive = Gen ;
-- singular defined in Types
-- plural defined in Types
mkN = \apa, apan, apor, aporna, g, x -> let
{nom = table {
SF Sg Indef _ => apa ;
SF Sg Def _ => apan ;
SF Pl Indef _ => apor ;
SF Pl Def _ => aporna
}
} in
{s = \\n,d,c => mkCase c (nom ! SF n d Nom) ;
g = g ; x = x ; lock_N = <>
} ;
-- auxiliaries
mkGenit : Tok -> Tok = \s -> ifTok Tok (Predef.dp 1 s) "s" s (s + "s") ;
mkCase : Case -> Tok -> Tok = \c,t -> case c of {
Nom => t ;
Gen => mkGenit t
} ;
nApa = \apa ->
let {apor = Predef.tk 1 apa + "or"} in
mkN apa (apa + "n") apor (apor + "na") utrum nonmasculine ;
nBil = \bil ->
mkN bil (bil + "en") (bil + "ar") (bil + "arna") utrum nonmasculine ;
nKarl = \bil ->
mkN bil (bil + "en") (bil + "ar") (bil + "arna") utrum masculine ;
nPojke = \pojke ->
let {bil = Predef.tk 1 pojke} in
mkN pojke (bil + "en") (bil + "ar") (bil + "arna") utrum masculine ;
nNyckel = \cykel ->
let {cykl = Predef.tk 2 cykel + Predef.dp 1 cykel} in
mkN cykel (cykel + "n") (cykl + "ar") (cykl + "arna") utrum nonmasculine ;
nRisk = \bil ->
mkN bil (bil + "en") (bil + "er") (bil + "erna") utrum nonmasculine ;
nDike = \dike ->
mkN dike (dike + "t") (dike + "n") (dike + "na") neutrum nonmasculine ;
nRep = \rep ->
mkN rep (rep + "et") rep (rep + "en") neutrum nonmasculine ;
nPapper = \cykel ->
let {cykl = Predef.tk 2 cykel + Predef.dp 1 cykel} in
mkN cykel (cykl + "et") cykel (cykl + "en") neutrum nonmasculine ;
nMurare = \murare ->
let {murar = Predef.tk 1 murare} in
mkN murare (murar + "en") murare (murar + "na") utrum masculine ;
nKikare = \murare ->
let {murar = Predef.tk 1 murare} in
mkN murare (murar + "en") murare (murar + "na") utrum nonmasculine ;
mkFun x y = SyntaxSwe.mkFun x y ** {lock_Fun = <>} ;
funAv = \f -> mkFun f "av" ;
funPaa = \f -> mkFun f "på" ;
funTill = \f -> mkFun f "till" ;
mkPN = \karolus, karoli, g, x ->
{s = table {Gen => karoli ; _ => karolus} ; g = g ; x = x ; lock_PN = <>} ;
pnReg = \horst ->
mkPN horst (ifTok Tok (Predef.dp 1 horst) "s" horst (horst + "s")) ;
mkCN = UseN ;
mkNP = \a,b,g -> UsePN (mkPN a b g nonmasculine) ; -- gender irrelevant in NP
npReg = \s,g -> UsePN (pnReg s g nonmasculine) ;
mkAdj1 = \liten, litet, lilla, små ->
{s = table {
Strong (ASg Utr) => \\c => mkCase c liten ;
Strong (ASg Neutr) => \\c => mkCase c litet ;
Strong APl => \\c => mkCase c små ;
Weak (AxSg Masc) => \\c => mkCase c (Predef.tk 1 lilla + "e") ;
Weak _ => \\c => mkCase c lilla
} ;
lock_Adj1 = <>
} ;
adjReg = \billig -> mkAdj1 billig (billig + "t") (billig + "a") (billig + "a") ;
adjNykter = \nykter ->
let {nyktr = Predef.tk 2 nykter + Predef.dp 1 nykter} in
mkAdj1 nykter (nykter + "t") (nyktr + "a") (nyktr + "a") ;
adjGalen = \galen ->
let {gal = Predef.tk 2 galen} in
mkAdj1 galen (gal + "et") (gal + "na") (gal + "na") ;
adjInvar = \bra -> {s = \\_,_ => bra ; lock_Adj1 = <>} ;
mkAdj2 = \a,p -> a ** {s2 = p ; lock_Adj2 = <>} ;
mkAdj2Reg = \a -> mkAdj2 (adjReg a) ;
mkAdjDeg = \liten, litet, lilla, sma, mindre, minst, minsta ->
let {lit = (mkAdj1 liten litet lilla sma).s} in
{s = table {
AF (Posit f) c => lit ! f ! c ;
AF Compar c => mkCase c mindre ;
AF (Super SupStrong) c => mkCase c minst ;
AF (Super SupWeak) c => mkCase c minsta --- masculine!
} ;
lock_AdjDeg = <>
} ;
aReg = \fin -> mkAdjDeg fin
(fin + "t") (fin + "a") (fin + "a") (fin + "are") (fin + "ast") (fin + "aste") ;
apReg = \s -> AdjP1 (adjReg s) ;
mkV x y z = mkVerb x y z ** {lock_V = <>} ;
vKoka = \tala -> mkV tala (tala+"r") tala ;
vSteka = \leka -> let {lek = Predef.tk 1 leka} in mkV leka (lek + "er") lek ;
vBo = \bo -> mkV bo (bo+"r") bo ;
vAndas = \andas -> mkV andas andas andas ;
vTrivas = \trivas ->
let {trivs = Predef.tk 1 trivas + "s"} in mkV trivas trivs trivs ;
vVara = verbVara ** {lock_V = <>} ;
vHa = verbHava ** {lock_V = <>} ;
mkPartV v p = {s = v.s ; s1 = p ; lock_V = <>} ;
mkTV x y = mkTransVerb x y ** {lock_TV = <>} ;
tvDir = \v -> mkTV v [] ;
} ;

View File

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

View File

@@ -0,0 +1,137 @@
--# -path=.:../abstract:../../prelude
--1 The Top-Level English Resource Grammar: Structural Words
--
-- Aarne Ranta 2002 -- 2003
--
concrete StructuralSwe of Structural =
CombinationsSwe ** open Prelude, SyntaxSwe in {
lin
INP = pronNounPhrase jag_32 ;
ThouNP = pronNounPhrase du_33 ;
HeNP = pronNounPhrase han_34 ;
SheNP = pronNounPhrase hon_35 ;
WeNP n = pronNounPhrase (pronWithNum vi_36 n) ;
YeNP n = pronNounPhrase (pronWithNum ni_37 n) ;
TheyNP = pronNounPhrase de_38 ;
YouNP = let {ni = pronNounPhrase ni_37 } in {s = ni.s ; g = ni.g ; n = Sg} ;
ItNP = pronNounPhrase det_40 ; ----
ThisNP = regNameNounPhrase ["det här"] Neutr NoMasc ;
ThatNP = regNameNounPhrase ["det där"] Neutr NoMasc ;
TheseNP n = {s = \\c => ["det här"] ++ n.s ! npCase c ; g = Neutr ; n = Pl} ;
ThoseNP n = {s = \\c => ["det där"] ++ n.s ! npCase c ; g = Neutr ; n = Pl} ;
EveryDet = varjeDet ;
AllDet = mkDeterminerSgGender2 "all" "allt" IndefP ;
AllsDet = mkDeterminerPlNum "alla" IndefP ;
AnyDet = mkDeterminerSgGender2 "någon" "något" IndefP ;
AnysDet = mkDeterminerPlNum "några" IndefP ;
SomeDet = mkDeterminerSgGender2 "någon" "något" IndefP ;
SomesDet = mkDeterminerPlNum "några" IndefP ;
ManyDet = mkDeterminerPl "många" IndefP ;
NoDet = mkDeterminerSgGender2 "ingen" "inget" IndefP ;
NosDet = mkDeterminerPlNum "inga" IndefP ;
WhichsDet = mkDeterminerPlNum "vilka" IndefP ;
WhichDet = vilkenDet ;
MostDet = mkDeterminerSgGender2 ["den mesta"] ["det mesta"] (DefP Def) ;
MostsDet = flestaDet ;
MuchDet = mkDeterminerSg (detSgInvar "mycket") IndefP ;
ThisDet = mkDeterminerSgGender2 ["den här"] ["det här"] (DefP Def) ;
ThatDet = mkDeterminerSgGender2 ["den där"] ["det där"] (DefP Def) ;
TheseDet = mkDeterminerPlNum ["de här"] (DefP Def) ;
ThoseDet = mkDeterminerPlNum ["de där"] (DefP Def) ;
HowIAdv = ss "hur" ;
WhenIAdv = ss "när" ;
WhereIAdv = ss "var" ;
WhyIAdv = ss "varför" ;
AndConj = ss "och" ** {n = Pl} ;
OrConj = ss "eller" ** {n = Sg} ;
BothAnd = sd2 "både" "och" ** {n = Pl} ;
EitherOr = sd2 "antingen" "eller" ** {n = Sg} ;
NeitherNor = sd2 "varken" "eller" ** {n = Sg} ;
IfSubj = ss "om" ;
WhenSubj = ss "när" ;
PhrYes = ss ["Ja ."] ;
PhrNo = ss ["Nej ."] ;
VeryAdv = ss "mycket" ;
TooAdv = ss "för" ;
OtherwiseAdv = ss "annars" ;
ThereforeAdv = ss "därför" ;
{-
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 Sg "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} ;
ThoseNP n = nameNounPhrase {s = \\c => "those" ++ n.s ! c} ;
-}
EverybodyNP = nameNounPhrase (mkProperName "alleman" Utr Masc) ;
SomebodyNP = nameNounPhrase (mkProperName "någon" Utr Masc) ;
NobodyNP = nameNounPhrase (mkProperName "ingen" Utr Masc) ;
EverythingNP = nameNounPhrase (mkProperName "allting" Neutr NoMasc) ;
SomethingNP = nameNounPhrase (mkProperName "någonting" Neutr NoMasc) ;
NothingNP = nameNounPhrase (mkProperName "ingenting" Neutr NoMasc) ;
CanVV = mkVerb "kunna" "kan" "kunn" ** {isAux = True} ; ---
CanKnowVV = mkVerb "kunna" "kan" "kunn" ** {isAux = True} ; ---
MustVV = mkVerb "få" "måste" "få" ** {isAux = True} ; ---
WantVV = mkVerb "vilja" "vill" "vilj" ** {isAux = True} ; ---
EverywhereNP = advPost "varstans" ;
SomewhereNP = advPost "någonstans" ;
NowhereNP = advPost "ingenstans" ;
AlthoughSubj = ss "fast" ;
AlmostAdv = ss "nästan" ;
QuiteAdv = ss "ganska" ;
InPrep = ss "i" ;
OnPrep = ss "på" ;
ToPrep = ss "till" ;
ThroughPrep = ss "genom" ;
AbovePrep = ss "ovanför" ;
UnderPrep = ss "under" ;
InFrontPrep = ss "framför" ;
BehindPrep = ss "bakom" ;
BetweenPrep = ss "mellan" ;
FromPrep = ss "från" ;
BeforePrep = ss "före" ;
DuringPrep = ss "under" ;
AfterPrep = ss "efter" ;
WithPrep = ss "med" ;
WithoutPrep = ss "utan" ;
ByMeansPrep = ss "med" ;
PartPrep = ss "av" ;
AgentPrep = ss "av" ;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,51 @@
--# -path=.:../abstract:../../prelude
concrete TestResourceSwe of TestResource = StructuralSwe ** open SyntaxSwe in {
flags startcat=Phr ; lexer=text ; unlexer=text ;
-- a random sample from the lexicon
lin
Big = stor_25 ;
Small = liten_1146 ;
Old = gammal_16 ;
Young = ung_29 ;
American = extAdjective (aFin "amerikansk") ;
Finnish = extAdjective (aFin "finsk") ;
Happy = aFin "lycklig" ;
Married = extAdjective (aAbstrakt "gift") ** {s2 = "med"} ;
Man = extCommNoun Masc man_1144 ;
Bar = extCommNoun NoMasc (sSak "bar") ;
Bottle = extCommNoun NoMasc (sApa "flask") ;
Woman = extCommNoun NoMasc (sApa "kvinn") ;
Car = extCommNoun NoMasc (sBil "bil") ;
House = extCommNoun NoMasc (sHus "hus") ;
Light = extCommNoun NoMasc (sHus "ljus") ;
Wine = extCommNoun NoMasc (sParti "vin") ;
Walk = extVerb Act gå_1174 ;
Run = extVerb Act (vFinna "spring" "sprang" "sprung") ;
Drink = extTransVerb (vFinna "drick" "drack" "druck") [] ;
Love = extTransVerb (vTala "älsk") [] ;
Send = extTransVerb (vTala "skick") [] ;
Wait = extTransVerb (vTala "vänt") "på" ;
Give = extTransVerb (vFinna "giv" "gav" "giv") [] ** {s3 = "till"} ; --- ge
Prefer = extTransVerb (vFinna "föredrag" "föredrog" "föredrag") [] **
{s3 = "framför"} ; --- föredra
Say = extVerb Act (vLeka "säg") ; --- works in present tense...
Prove = extVerb Act (vTala "bevis") ;
SwitchOn = mkDirectVerb (extVerbPart Act (vFinna "sätt" "satte" "satt") "på") ;
SwitchOff = mkDirectVerb (extVerbPart Act (vLeka "stäng") "av") ;
Mother = mkFun (extCommNoun NoMasc mor_1) "till" ;
Uncle = mkFun (extCommNoun Masc farbror_8) "till" ;
Connection = mkFun (extCommNoun NoMasc (sVarelse "förbindelse")) "från" **
{s3 = "till"} ;
Always = advPre "alltid" ;
Well = advPost "bra" ;
John = mkProperName "Johan" Utr Masc ;
Mary = mkProperName "Maria" Utr NoMasc ;
} ;

View File

@@ -0,0 +1,161 @@
--1 Swedish Word Classes and Morphological Parameters
--
-- This is a resource module for Swedish morphology, defining the
-- morphological parameters and word classes of Swedish. It is aimed
-- to be complete w.r.t. the description of word forms.
-- However, it does not include those parameters that are not needed for
-- analysing individual words: such parameters are defined in syntax modules.
--
-- This GF grammar was obtained from the functional morphology file TypesSw.hs
-- semi-automatically. The GF inflection engine obtained was obtained automatically.
resource TypesSwe = open Prelude in {
--
--2 Enumerated parameter types
--
-- These types are the ones found in school grammars.
-- Their parameter values are atomic.
param
Gender = Utr | Neutr ;
Number = Sg | Pl ;
Species = Indef | Def ;
Case = Nom | Gen ;
Sex = NoMasc | Masc ;
Mode = Ind | Cnj ;
Voice = Act | Pass ;
Degree = Pos | Comp | Sup ;
Person = P1 | P2 | P3 ;
--2 Word classes and hierarchical parameter types
--
-- Real parameter types (i.e. ones on which words and phrases depend)
-- are mostly hierarchical. The alternative would be cross-products of
-- simple parameters, but this would usually overgenerate.
--
--3 Substantives
--
-- Substantives (= common nouns) have a parameter of type SubstForm.
param SubstForm = SF Number Species Case ;
-- Substantives moreover have an inherent gender.
oper Subst : Type = {s : SubstForm => Str ; h1 : Gender} ;
--3 Adjectives
--
-- Adjectives are a very complex class, and the full table has as many as
-- 18 different forms. The major division is between the comparison degrees;
-- the comparative has only the 2 case forms, whereas the positive has 12 forms.
param
AdjForm = AF AdjFormGrad Case ;
-- The positive strong forms depend on gender: "en stor bil" - "ett stort hus".
-- But the weak forms depend on sex: "den stora bilen" - "den store mannen".
-- The plural never makes a gender-sex distinction.
GenNum = ASg Gender | APl ;
SexNum = AxSg Sex | AxPl ;
AdjFormPos = Strong GenNum | Weak SexNum ;
AdjFormSup = SupStrong | SupWeak ;
AdjFormGrad =
Posit AdjFormPos
| Compar
| Super AdjFormSup ;
oper
Adj : Type = {s : AdjForm => Str} ;
adverbForm : AdjFormPos = Strong (ASg Neutr) ;
--3 Verbs
--
-- Verbs have 9 finite forms and as many as 18 infinite forms; the large number
-- of the latter comes from adjectives.
oper Verbum : Type = {s : VerbForm => Str} ;
param
VFin =
Pres Mode Voice
| Pret Mode Voice
| Imper ; --- no passive
VInf =
Inf Voice
| Supin Voice
| PtPres Case
| PtPret AdjFormPos Case ;
VerbForm =
VF VFin
| VI VInf ;
-- However, the syntax only needs a simplified verb category, with
-- present tense only. Such a verb can be extracted from the full verb,
-- and a choice can be made between an active and a passive (deponent) verb.
-- Active verbs continue to have passive forms. But we add an extra field $s1$
-- for a verb particle, as e.g. in "se upp".
param
VMode = Infinit | Indicat | Imperat ;
VForm = VPres VMode Voice ;
oper
Verb : Type = {s : VForm => Str ; s1 : Str} ;
extVerbPart : Voice -> Verbum -> Str -> Verb = \v,verb,upp -> {s = table {
VPres Infinit v => verb.s ! VI (Inf v) ;
VPres Indicat v => verb.s ! VF (Pres Ind v) ;
VPres Imperat Act => verb.s ! VF Imper ;
VPres Imperat Pass => verb.s ! VF (Pres Ind Pass) --- no passive in Verbum
} ;
s1 = upp
} ;
extVerb : Voice -> Verbum -> Verb = \v,verb ->
extVerbPart v verb [] ;
--3 Other open classes
--
-- Proper names, adverbs (Adv having comparison forms and AdvIn not having them),
-- and interjections are the remaining open classes.
oper
PNm : Type = {s : Case => Str ; h1 : Gender} ;
Adv : Type = {s : Degree => Str} ;
AdvInv : Type = {s : Str} ;
Interj : Type = {s : Str} ;
--3 Closed classes
--
-- The rest of the Swedish word classes are closed, i.e. not extensible by new
-- lexical entries. Thus we don't have to know how to build them, but only
-- how to use them, i.e. which parameters they have.
--
-- The most important distinction is between proper-name-like pronouns and
-- adjective-like pronouns, which are inflected in completely different parameters.
param
NPForm = PNom | PAcc | PGen GenNum ;
AdjPronForm = APron GenNum Case ;
AuxVerbForm = AuxInf | AuxPres | AuxPret | AuxSup ;
oper
ProPN : Type = {s : NPForm => Str ; h1 : Gender ; h2 : Number ; h3 : Person} ;
ProAdj : Type = {s : AdjPronForm => Str} ;
Prep : Type = {s : Str} ;
Conjunct : Type = {s : Str} ;
Subjunct : Type = {s : Str} ;
Art : Type = {s : GenNum => Str} ;
Part : Type = {s : Str} ;
Infin : Type = {s : Str} ;
VAux : Type = {s : AuxVerbForm => Str} ;
}