Working on with new resource API.

This commit is contained in:
aarne
2003-11-21 15:28:25 +00:00
parent 6d99debdff
commit 9cd2c273a2
12 changed files with 726 additions and 220 deletions

View File

@@ -16,11 +16,11 @@ lincat
Name = PN ;
lin
WhichAre A B = QuestPhrase (IntVP (NounIPMany A) (PosA B)) ;
WhichAre A B = QuestPhrase (IntVP (NounIPMany A) (PosVG (PredAP 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)) ;
AreThere A = QuestPhrase (AreThereCN NoNum A) ;
WhatIs val = QuestPhrase (IntVP WhatOne (PosVG (PredNP val))) ;
IsIt Q A = QuestPhrase (QuestVP Q (PosVG (PredAP A))) ;
MoreThan = ComparAdjP ;
TheMost = SuperlNP ;

View File

@@ -42,7 +42,7 @@ oper
-- parametric order between two strings
preOrPost : Bool -> Str -> Str -> Str = \pr,x,y ->
if_then_else Str pr (x ++ y) (y ++ x) ;
if_then_Str pr (x ++ y) (y ++ x) ;
-- Booleans
@@ -59,6 +59,7 @@ oper
orB : (_,_ : Bool) -> Bool = \a,b -> if_then_else Bool a True b ;
notB : Bool -> Bool = \a -> if_then_else Bool a False True ;
if_then_Str : Bool -> Str -> Str -> Str = if_then_else Str ;
-- zero, one, two, or more (elements in a list etc)

View File

@@ -3,10 +3,23 @@
-- 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
-- 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
@@ -16,48 +29,64 @@
-- 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.
-- 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.
-- 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. 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.
-- 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.
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)"
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
--
@@ -65,33 +94,42 @@ cat
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"
VP ; -- verb phrase, e.g. "switch the light on"
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
--
@@ -103,13 +141,15 @@ cat
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
@@ -118,64 +158,78 @@ cat
-- 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"
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"
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"
UseInt : Int -> Num ; -- "32" --- assumes i > 1
NoNum : Num ; -- no numeral modifier
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"
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"
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.
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"
PosAdV, NegAdV : AdV -> VP ; -- "is everywhere", "is not in France"
PosVS, NegVS : VS -> S -> VP ; -- "says that I run", "doesn't say..."
--- PosVV, NegVV : VV -> VP -> VP ; -- "can run", "can't run", "tries to run"
PosV3, NegV3 : V3 -> NP -> NP -> VP ; -- "prefers wine to beer"
VTrans : TV -> V ; -- "loves"
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"
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
--
@@ -187,11 +241,12 @@ fun
IdRP : RP ; -- "which"
FunRP : Fun -> RP -> RP ; -- "the successor of which"
RelVP : RP -> VP -> RC ; -- "who walks"
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
--
@@ -200,7 +255,7 @@ fun
FunIP : Fun -> IP -> IP ; -- "the mother of whom"
NounIPOne, NounIPMany : CN -> IP ; -- "which car", "which cars"
QuestVP : NP -> VP -> Qu ; -- "does John walk"
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"
@@ -215,6 +270,7 @@ fun
AdvS : AdS -> S -> Phr ; -- "Therefore, 2 is prime."
--!
--3 Coordination
--
-- We consider "n"-ary coordination, with "n" > 1. To this end, we have introduced
@@ -243,6 +299,7 @@ fun
TwoNP : NP -> NP -> ListNP ;
ConsNP : ListNP -> NP -> ListNP ;
--!
--3 Subordination
--
-- Subjunctions are different from conjunctions, but form
@@ -253,6 +310,7 @@ fun
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
@@ -263,6 +321,7 @@ fun
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.

View File

@@ -1,5 +1,7 @@
--2 Examples of structural words
--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
@@ -8,35 +10,67 @@
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
-- Many plural determiners can take a numeral modifier.
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 ; -- personal pronouns in plural
YouNP : NP ; -- the polite you
TheyNP : NP ; YouNP : NP ; -- they, the polite you
EverybodyNP, SomebodyNP, NobodyNP, -- everybody, somebody, nobody
EverythingNP, SomethingNP, NothingNP : NP ; -- everything, something, nothing
--- CanVV, CanKnowVV, MustVV : VV ; -- can (pouvoir/savoir), must
--- WantVV : VV ; -- want (to do)
--!
--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
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
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 ;
@@ -44,4 +78,13 @@ fun
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

@@ -1,26 +1,42 @@
-- added 19/11/2003
-- added 19/11/2003 -- 21/11
-- Combinations.gf
cat
Prep ; -- pre/postposition and/or case e.g.
Num ; -- numeral, e.g. "three", "879"
--- VV ; -- verb-compl. verb, e.g. "can", "want"
VV ; -- verb-compl. verb, e.g. "can", "want"
VG ; -- verbal group
fun
ThereIsCN : CN -> S ; -- "there is a bar", "there are bars"
ThereAreCN : Num -> CN -> S ; -- "there are 86 bars"
PrepNP : Prep -> NP -> AdV ; -- "in London", "after the war" (replace LocNP)
MassNP : CN -> NP ; -- "wine"
--- PosVV, NegVV : VV -> VP -> VP ; -- "can run", "can't run", "tries to run"
PosAdV, NegAdV : AdV -> VP ; -- "is everywhere", "is not in France"
PredAdV : AdV -> VP ; -- "is everywhere", "is not in France"
AdjAdv : AP -> AdV ; -- "freely", "more consciously than you"
IsThereCN, AreThereCN : CN -> Qu ;-- "is there a bar", "are there bars"
IsThereCN,AreThereCN : CN -> Qu ; -- "is there a bar", "are there bars"
PosVG,NegVG : VG -> VP ; --
-- merged PosX and NegX to PredX, for the following
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"
-- changed type signatures: added Num
IndefManyNP : Num -> CN -> NP ; -- "houses", "86 houses"
DefManyNP : Num -> CN -> NP ; -- "the cars", "the 86 cars"
ModGenMany : Num -> NP -> CN -> NP ; -- "John's cars", "John's 86 cars"
DefManyNP : Num -> CN -> NP ; -- "the cars", "the 86 cars"
ModGenMany : Num -> NP -> CN -> NP ; -- "John's cars", "John's 86 cars"
UseInt : Int -> Num ; -- "32" --- assumes i > 1
NoNum : Num ; -- no numeral modifier

View File

@@ -47,6 +47,8 @@ lincat
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} ;
@@ -103,26 +105,19 @@ lin
NoNum = noNum ;
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 ;
PosAdV = predAdverb True ;
NegAdV = predAdverb False ;
PosVS = complSentVerb True ;
NegVS = complSentVerb False ;
--- PosVV = complVerbVerb True ;
--- NegVV = complVerbVerb False ;
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) ;

View File

@@ -49,10 +49,10 @@ concrete StructuralEng of Structural =
SomethingNP = nameNounPhrase (nameReg "something") ;
NothingNP = nameNounPhrase (nameReg "nothing") ;
--- CanVV = vvCan ;
--- CanKnowVV = vvCan ;
--- MustVV = vvMust ;
--- WantVV = verbNoPart (regVerbP3 "want") ** {isAux = False} ;
CanVV = vvCan ;
CanKnowVV = vvCan ;
MustVV = vvMust ;
WantVV = verbNoPart (regVerbP3 "want") ** {isAux = False} ;
HowIAdv = ss "how" ;
WhenIAdv = ss "when" ;

View File

@@ -294,8 +294,21 @@ oper
-- There's also a parameter telling if the verb is an auxiliary:
-- this is needed in question.
VerbGroup = {
s : Bool => VForm => Str ;
s2 : Bool => Number => Str ;
isAuxT : Bool ;
isAuxF : Bool
} ;
VerbPhrase = VerbP3 ** {s2 : Number => Str ; isAux : Bool} ;
predVerbGroup : Bool -> VerbGroup -> VerbPhrase = \b,vg -> {
s = vg.s ! b ;
s2 = vg.s2 ! b ;
isAux = if_then_else Bool b vg.isAuxT vg.isAuxF
} ;
-- From the inflection table, we selecting the finite form as function
-- of person and number:
@@ -309,15 +322,15 @@ oper
-- 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
predVerb : Verb -> VerbGroup = \walk ->
{s = \\b,v => if_then_Str b
(walk.s ! v ++ walk.s1)
(contractNot (verbP3Do.s ! v)) ;
s2 = \\b,_ => if_then_Str b
[]
(walk.s ! InfImp ++ walk.s1) ;
isAuxT = False ;
isAuxF = True
} ;
-- Sometimes we want to extract the verb part of a verb phrase.
@@ -329,33 +342,33 @@ oper
-- 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 ! AAdj ;
isAux = True
predAdjective : Adjective -> VerbGroup = \old ->
{s = beOrNotBe ;
s2 = \\_,_ => old.s ! AAdj ;
isAuxT, isAuxF = True
} ;
predCommNoun : Bool -> CommNoun -> VerbPhrase = \b,man ->
{s = beOrNotBe b ;
s2 = \\n => indefNoun n man ;
isAux = True
predCommNoun : CommNoun -> VerbGroup = \man ->
{s = beOrNotBe ;
s2 = \\_,n => indefNoun n man ;
isAuxT, isAuxF = True
} ;
predNounPhrase : Bool -> NounPhrase -> VerbPhrase = \b,john ->
{s = beOrNotBe b ;
s2 = \\_ => john.s ! NomP ;
isAux = True
predNounPhrase : NounPhrase -> VerbGroup = \john ->
{s = beOrNotBe ;
s2 = \\_,_ => john.s ! NomP ;
isAuxT, isAuxF = True
} ;
predAdverb : Bool -> Adverb -> VerbPhrase = \b,elsewhere ->
{s = beOrNotBe b ;
s2 = \\_ => elsewhere.s ;
isAux = True
predAdverb : Adverb -> VerbGroup = \elsewhere ->
{s = beOrNotBe ;
s2 = \\_,_ => elsewhere.s ;
isAuxT, isAuxF = True
} ;
-- We use an auxiliary giving all forms of "be".
beOrNotBe : Bool -> (VForm => Str) = \b ->
beOrNotBe : Bool => VForm => Str = \\b =>
if_then_else (VForm => Str) b
verbBe.s
(table {
@@ -378,16 +391,13 @@ oper
-- 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} ;
complTransVerb : TransVerb -> NounPhrase -> VerbGroup = \lookat,john ->
let lookatjohn = bothWays lookat.s1 (lookat.s3 ++ john.s ! AccP)
in {s = \\b,v => if_then_Str b (lookat.s ! v) (contractNot (verbP3Do.s ! v)) ;
s2 = \\b,_ => if_then_Str b lookatjohn (lookat.s ! InfImp ++ lookatjohn) ;
isAuxT = False ;
isAuxF = True
} ;
-- Verbs that take direct object and a particle:
@@ -407,8 +417,8 @@ oper
-- 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 (regAdjective (love.s ! PPart))) ;
passVerb : Verb -> VerbGroup = \love ->
predAdjective (adj2adjPhrase (regAdjective (love.s ! PPart))) ;
-- Transitive verbs can be used elliptically as verbs. The semantics
-- is left to applications. The definition is trivial, due to record
@@ -426,20 +436,15 @@ oper
mkDitransVerb : Verb -> Preposition -> Preposition -> DitransVerb = \v,p1,p2 ->
v ** {s3 = p1 ; s4 = p2} ;
complDitransVerb :
Bool -> DitransVerb -> NounPhrase -> NounPhrase -> VerbPhrase =
\b,give,you,beer ->
let {
complDitransVerb : DitransVerb -> NounPhrase -> NounPhrase -> VerbGroup =
\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
in
{s = \\b,v => if_then_Str b (give.s ! v) (contractNot (verbP3Do.s ! v)) ;
s2 = \\b,_ => if_then_Str b youbeer (give.s ! InfImp ++ youbeer) ;
isAuxT = False ;
isAuxF = True
} ;
@@ -510,12 +515,6 @@ oper
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
--
@@ -525,16 +524,13 @@ oper
-- 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} ;
complSentVerb : SentenceVerb -> Sentence -> VerbGroup = \say,johnruns ->
let {thatjohnruns = optStr "that" ++ johnruns.s} in
{s = \\b,v => if_then_Str b (say.s ! v) (contractNot (verbP3Do.s ! v)) ;
s2 = \\b,_ => if_then_Str b thatjohnruns (say.s ! InfImp ++ thatjohnruns) ;
isAuxT = False ;
isAuxF = True
} ;
--3 Verb-complement verbs
--
@@ -552,17 +548,26 @@ oper
-- The contraction of "not" is not provided, since it would require changing
-- the verb parameter type.
complVerbVerb : Bool -> VerbVerb -> VerbPhrase -> VerbPhrase = \b,try,run ->
let to = if_then_else Str try.isAux [] "to"
complVerbVerb : VerbVerb -> VerbGroup -> VerbGroup = \try,run ->
let
taux = try.isAux ;
to = if_then_Str taux [] "to" ;
dont = table VForm {v => if_then_Str taux
(try.s ! v ++ "not") -- can not
(contractNot (verbP3Do.s ! v)) -- doesn't ...
} ;
trnot = if_then_Str taux
[] --
(try.s ! InfImp ++ try.s1) ; -- ... try
in
if_then_else VerbPhrase b
{s = \\v => try.s ! v ++ try.s1 ++ to ++ run.s ! InfImp ;
s2 = run.s2 ;
isAux = try.isAux
}
{s = \\v => try.s ! v ++ "not" ;
s2 = \\n => run.s ! InfImp ++ run.s2 ! n ;
isAux = True
{s = \\b,v => if_then_Str b
(try.s ! v ++ try.s1 ++ to ++ run.s ! True ! InfImp)
(dont ! v) ;
s2 = \\b,v => if_then_Str b
(run.s2 ! True ! v)
(trnot ++ run.s ! True ! InfImp ++ run.s2 ! True ! v) ;
isAuxT = taux ;
isAuxF = True
} ;
-- The three most important example auxiliaries.
@@ -769,7 +774,7 @@ oper
Sg => nameNounPhrase (nameReg "there") ;
Pl => {s = \\_ => "there" ; n = Pl ; p = P3}
})
(predNounPhrase True (indefNounPhraseNum n num bar)) ;
(predVerbGroup True (predNounPhrase (indefNounPhraseNum n num bar))) ;
--3 Wh-questions

View File

@@ -0,0 +1,210 @@
--# -path=.:../nabstract:../../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} ;
VG = Verb ** {s2 : Bool => Str ; s3 : Gender => Number => Str} ;
VP = Verb ** {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 ;
ThereIsCN A = predVerbPhrase npDet
(predVerbGroup True
(complTransVerb (mkDirectVerb verbFinnas)
(indefNounPhrase singular A))) ;
ThereAreCN n A = predVerbPhrase npDet
(predVerbGroup True
(complTransVerb (mkDirectVerb verbFinnas)
(indefNounPhraseNum plural n 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 ;
IsThereCN A = questVerbPhrase npDet
(predVerbGroup True
(complTransVerb (mkDirectVerb verbFinnas)
(indefNounPhrase singular A))) ;
AreThereCN n A = questVerbPhrase npDet
(predVerbGroup True
(complTransVerb (mkDirectVerb verbFinnas)
(indefNounPhraseNum plural n 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 ;
} ;

View File

@@ -0,0 +1,115 @@
--# -path=.:../nabstract:../../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 ;
ItNP = pronNounPhrase det_40 ; ----
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} ;
EveryDet = varjeDet ;
AllsDet = mkDeterminerPlNum "alla" IndefP ;
WhichDet = vilkenDet ;
MostDet = flestaDet ;
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" ;
}

View File

@@ -129,10 +129,10 @@ oper
mkDeterminerSg : DetSg -> SpeciesP -> Determiner = \en, b ->
{s = en ; n = Sg ; b = b} ;
mkDeterminerPl : DetPl -> SpeciesP -> Determiner = \alla ->
mkDeterminerPlNum alla noNum ;
mkDeterminerPl : DetPl -> SpeciesP -> Determiner = \alla,b ->
mkDeterminerPlNum alla b noNum ;
mkDeterminerPlNum : DetPl -> Numeral -> SpeciesP -> Determiner = \alla,n,b ->
mkDeterminerPlNum : DetPl -> SpeciesP -> Numeral -> Determiner = \alla,b,n ->
{s = \\_,_ => alla ++ n.s ! Nom ;
n = Pl ;
b = b
@@ -202,7 +202,7 @@ oper
detNounPhrase
(mkDeterminerSgGender (table {g => artDef ! cn.p ! ASg g}) (DefP Def)) cn ;
deDet : Numeral -> CommNounPhrase -> NounPhrase = \n,cn ->
detNounPhrase (mkDeterminerPlNum (artDef ! cn.p ! APl) n (DefP Def)) cn ;
detNounPhrase (mkDeterminerPlNum (artDef ! cn.p ! APl) (DefP Def) n) cn ;
-- It is useful to have macros for indefinite and definite, singular and plural
-- noun-phrase-like syncategorematic expressions.
@@ -447,50 +447,53 @@ oper
-- to account for word order variations.
VerbPhrase : Type = Verb ** {s2 : Str ; s3 : Gender => Number => Str} ;
VerbGroup : Type = Verb ** {s2 : Bool => Str ; s3 : Gender => Number => Str} ;
predVerbGroup : Bool -> VerbGroup -> VerbPhrase = \b,vg -> {
s = vg.s ;
s2 = vg.s2 ! b ;
s3 = vg.s3
} ;
-- 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 "inte" are not grammatical.
predVerb : Bool -> Verb -> VerbPhrase = \b,se ->
predVerb : Verb -> VerbGroup = \se ->
se ** {
s2 = negation b ;
s2 = negation ;
s3 = \\_,_ => []
} ;
negation : Bool -> Str = \b -> if_then_else Str b [] "inte" ;
-- Sometimes we want to extract the verb part of a verb phrase.
verbOfPhrase : VerbPhrase -> Verb = \v -> {s = v.s} ;
negation : Bool => Str = \\b => if_then_Str b [] "inte" ;
-- Verb phrases can also be formed from adjectives ("är snäll"),
-- common nouns ("är en man"), and noun phrases ("är den yngste mannen").
-- The third rule is overgenerating: "är varje man" has to be ruled out
-- on semantic grounds.
predAdjective : Bool -> Adjective -> VerbPhrase = \b,arg ->
predAdjective : Adjective -> VerbGroup = \arg ->
verbVara ** {
s2 = negation b ;
s2 = negation ;
s3 = \\g,n => arg.s ! mkAdjForm Indef n g NoMasc ! Nom
} ;
predCommNoun : Bool -> CommNounPhrase -> VerbPhrase = \b,man ->
predCommNoun : CommNounPhrase -> VerbGroup = \man ->
verbVara ** {
s2 = negation b ;
s2 = negation ;
s3 = \\_,n => indefNoun n man
} ;
predNounPhrase : Bool -> NounPhrase -> VerbPhrase = \b,john ->
predNounPhrase : NounPhrase -> VerbGroup = \john ->
verbVara ** {
s2 = negation b ;
s2 = negation ;
s3 = \\_,_ => john.s ! PNom
} ;
predAdverb : Bool -> Adverb -> VerbPhrase = \b,ute ->
predAdverb : Adverb -> VerbGroup = \ute ->
verbVara ** {
s2 = negation b ;
s2 = negation ;
s3 = \\_,_ => ute.s
} ;
@@ -517,9 +520,9 @@ oper
-- The rule for using transitive verbs is the complementization rule:
complTransVerb : Bool -> TransVerb -> NounPhrase -> VerbPhrase = \b,se,dig ->
complTransVerb : TransVerb -> NounPhrase -> VerbGroup = \se,dig ->
{s = se.s ;
s2 = negation b ;
s2 = negation ;
s3 = \\_,_ => se.s2 ++ dig.s ! PAcc
} ;
@@ -529,9 +532,9 @@ oper
-- The syntax is the same as for active verbs, with the choice of the
-- "s" passive form.
passVerb : Bool -> Verb -> VerbPhrase = \b,se -> ---- passive not yet
passVerb : Verb -> VerbGroup = \se -> ---- passive not yet
{s = table {VPres m _ => se.s ! VPres m Pass} ;
s2 = negation b ;
s2 = negation ;
s3 = \\_,_ => []
} ;
@@ -552,10 +555,9 @@ oper
v ** {s2 = p1 ; s3 = p2} ;
complDitransVerb :
Bool -> DitransVerb -> NounPhrase -> NounPhrase -> VerbPhrase =
\b,ge,dig,vin ->
DitransVerb -> NounPhrase -> NounPhrase -> VerbGroup = \ge,dig,vin ->
{s = ge.s ;
s2 = negation b ;
s2 = negation ;
s3 = \\_,_ => ge.s2 ++ dig.s ! PAcc ++ ge.s3 ++ vin.s ! PAcc
} ;
@@ -635,10 +637,6 @@ oper
}
} ;
-- This is a macro for simultaneous predication and complementation.
predTransVerb : Bool -> NounPhrase -> TransVerb -> NounPhrase -> Sentence =
\b,jag,ser,dig -> predVerbPhrase jag (complTransVerb b ser dig) ;
--3 Sentence-complement verbs
--
@@ -646,9 +644,27 @@ oper
SentenceVerb : Type = Verb ;
complSentVerb : Bool -> SentenceVerb -> Sentence -> VerbPhrase = \b,se,duler ->
{s = se.s ; s2 = negation b ; s3 = \\_,_ => optStr "att" ++ duler.s ! Main} ;
complSentVerb : SentenceVerb -> Sentence -> VerbGroup = \se,duler ->
{s = se.s ;
s2 = negation ;
s3 = \\_,_ => optStr "att" ++ duler.s ! Main
} ;
--3 Verb-complement verbs
--
-- Sentence-complement verbs take verb phrases as complements.
-- They can be auxiliaries ("kan", "måste") or ordinary verbs
-- ("försöka"); this distinction cannot be done in the multilingual
-- API and leads to some anomalies in Swedish, but less so than in English.
VerbVerb : Type = Verb ** {isAux : Bool} ;
complVerbVerb : VerbVerb -> VerbGroup -> VerbGroup = \vilja, simma ->
{s = vilja.s ;
s2 = negation ;
s3 = \\g,n => if_then_Str vilja.isAux [] "att" ++
simma.s ! VPres Infinit Act ++ simma.s2 ! True ++ simma.s3 ! g ! n
} ;
--2 Sentences missing noun phrases
@@ -668,7 +684,7 @@ oper
let {
jag = Jag.s ! PNom ;
ser = se.s ! VPres Indicat Act ;
inte = negation b
inte = negation ! b
} in
{s = table {
Main => jag ++ ser ++ inte ;

View File

@@ -0,0 +1,46 @@
--# -path=.:../nabstract:../../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") ;
Married = extAdjective (aAbstrakt "gift") ** {s2 = "med"} ;
Man = extCommNoun Masc man_1144 ;
Woman = extCommNoun NoMasc (sApa "kvinn") ;
Car = extCommNoun NoMasc (sBil "bil") ;
House = extCommNoun NoMasc (sHus "hus") ;
Light = extCommNoun NoMasc (sHus "ljus") ;
Walk = extVerb Act gå_1174 ;
Run = extVerb Act (vFinna "spring" "sprang" "sprung") ;
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 = extTransVerb (vVända "tän") [] ;
SwitchOff = extTransVerb (vLeka "släck") [] ;
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 ;
} ;