forked from GitHub/gf-core
Working on with new resource API.
This commit is contained in:
@@ -16,11 +16,11 @@ lincat
|
|||||||
Name = PN ;
|
Name = PN ;
|
||||||
|
|
||||||
lin
|
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) ;
|
IsThere A = QuestPhrase (IsThereCN A) ;
|
||||||
AreThere A = QuestPhrase (AreThereCN A) ;
|
AreThere A = QuestPhrase (AreThereCN NoNum A) ;
|
||||||
WhatIs val = QuestPhrase (IntVP WhatOne (PosNP val)) ;
|
WhatIs val = QuestPhrase (IntVP WhatOne (PosVG (PredNP val))) ;
|
||||||
IsIt Q A = QuestPhrase (QuestVP Q (PosA A)) ;
|
IsIt Q A = QuestPhrase (QuestVP Q (PosVG (PredAP A))) ;
|
||||||
|
|
||||||
MoreThan = ComparAdjP ;
|
MoreThan = ComparAdjP ;
|
||||||
TheMost = SuperlNP ;
|
TheMost = SuperlNP ;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ oper
|
|||||||
|
|
||||||
-- parametric order between two strings
|
-- parametric order between two strings
|
||||||
preOrPost : Bool -> Str -> Str -> Str = \pr,x,y ->
|
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
|
-- Booleans
|
||||||
|
|
||||||
@@ -59,6 +59,7 @@ oper
|
|||||||
orB : (_,_ : Bool) -> Bool = \a,b -> if_then_else Bool a True b ;
|
orB : (_,_ : Bool) -> Bool = \a,b -> if_then_else Bool a True b ;
|
||||||
notB : Bool -> Bool = \a -> if_then_else Bool a False True ;
|
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)
|
-- zero, one, two, or more (elements in a list etc)
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,23 @@
|
|||||||
-- Aarne Ranta 2002 -- 2003
|
-- Aarne Ranta 2002 -- 2003
|
||||||
--
|
--
|
||||||
-- Although concrete syntax differs a lot between different languages,
|
-- Although concrete syntax differs a lot between different languages,
|
||||||
-- many structures can be found that are common, on a certain level
|
-- many structures can be treated as common, on the level
|
||||||
-- of abstraction. What we will present in the following is an abstract
|
-- of abstraction that GF provides.
|
||||||
-- syntax that has been successfully defined for English, Finnish, French, German,
|
-- What we will present in the following is a linguistically oriented abstract
|
||||||
-- Italian, Russian, and Swedish. It has been applied to define language
|
-- 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,
|
-- fragments on technical or near-to-technical domains: database queries,
|
||||||
-- video recorder dialogue systems, software specifications, and a
|
-- video recorder dialogue systems, software specifications, and a
|
||||||
-- health-related phrase book. Each new application helped to identify some
|
-- 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
|
-- To use the resource in applications, you need the following
|
||||||
-- $cat$ and $fun$ rules in $oper$ form, completed by taking the
|
-- $cat$ and $fun$ rules in $oper$ form, completed by taking the
|
||||||
-- $lincat$ and $lin$ judgements of a particular language. This is done
|
-- $lincat$ and $lin$ judgements of a particular language. This is done
|
||||||
-- by using the $reuse$ module with the desired concrete syntax of
|
-- by using, instead of this module, the $reuse$ module which has the name
|
||||||
-- $ResAbs$ as argument.
|
-- $ResourceX$
|
||||||
|
|
||||||
|
|
||||||
|
abstract Combinations = PredefAbs ** {
|
||||||
|
--!
|
||||||
--2 Categories
|
--2 Categories
|
||||||
--
|
--
|
||||||
-- The categories of this resource grammar are mostly 'standard' categories
|
-- The categories of this resource grammar are mostly 'standard' categories
|
||||||
-- of linguistics. Their is no claim that they correspond to semantic categories
|
-- of linguistics. Their is no claim that they correspond to semantic categories
|
||||||
-- definable in type theory: to define such correspondences is the business
|
-- 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
|
-- 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
|
-- 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
|
-- a direct object (whose case may vary) or a prepositional phrase. Prepositional
|
||||||
-- with the category $Adv$, removes the need of a category of
|
-- phrases that are not complements belong to the category
|
||||||
-- 'prepositional phrases', which is too language-dependent to make sense
|
-- $AdV$ of adverbials.
|
||||||
-- on this level of abstraction.
|
|
||||||
--
|
--
|
||||||
|
-- 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
|
--3 Nouns and noun phrases
|
||||||
--
|
--
|
||||||
|
|
||||||
cat
|
cat
|
||||||
N ; -- simple common noun, e.g. "car"
|
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"
|
PN ; -- proper name, e.g. "John", "New York"
|
||||||
Det ; -- determiner, e.g. "every", "all"
|
|
||||||
Fun ; -- function word, e.g. "mother (of)"
|
Fun ; -- function word, e.g. "mother (of)"
|
||||||
Fun2 ; -- two-place function, e.g. "flight (from) (to)"
|
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"
|
Num ; -- numeral, e.g. "three", "879"
|
||||||
|
|
||||||
|
--!
|
||||||
--3 Adjectives and adjectival phrases
|
--3 Adjectives and adjectival phrases
|
||||||
--
|
--
|
||||||
|
|
||||||
Adj1 ; -- one-place adjective, e.g. "even"
|
Adj1 ; -- one-place adjective, e.g. "even"
|
||||||
Adj2 ; -- two-place adjective, e.g. "divisible (by)"
|
Adj2 ; -- two-place adjective, e.g. "divisible (by)"
|
||||||
AdjDeg ; -- degree adjective, e.g. "big/bigger/biggest"
|
AdjDeg ; -- degree adjective, e.g. "big/bigger/biggest"
|
||||||
|
|
||||||
AP ; -- adjective phrase, e.g. "divisible by two", "bigger than John"
|
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
|
--3 Verbs and verb phrases
|
||||||
--
|
--
|
||||||
|
|
||||||
@@ -65,33 +94,42 @@ cat
|
|||||||
TV ; -- two-place verb, e.g. "love", "wait (for)", "switch on"
|
TV ; -- two-place verb, e.g. "love", "wait (for)", "switch on"
|
||||||
V3 ; -- three-place verb, e.g. "give", "prefer (stg) (to stg)"
|
V3 ; -- three-place verb, e.g. "give", "prefer (stg) (to stg)"
|
||||||
VS ; -- sentence-compl. verb, e.g. "say", "prove"
|
VS ; -- sentence-compl. verb, e.g. "say", "prove"
|
||||||
--- VV ; -- verb-compl. verb, e.g. "can", "want"
|
VV ; -- verb-compl. verb, e.g. "can", "want"
|
||||||
VP ; -- verb phrase, e.g. "switch the light on"
|
|
||||||
|
|
||||||
|
VG ; -- verbal group, e.g. "switch the light on"
|
||||||
|
VP ; -- verb phrase, e.g. "switch the light on", "don't run"
|
||||||
|
|
||||||
|
--!
|
||||||
--3 Adverbials
|
--3 Adverbials
|
||||||
--
|
--
|
||||||
|
-- This group has no lexical categories.
|
||||||
|
|
||||||
AdV ; -- adverbial e.g. "now", "in the house"
|
AdV ; -- adverbial e.g. "now", "in the house"
|
||||||
AdA ; -- ad-adjective e.g. "very"
|
AdA ; -- ad-adjective e.g. "very"
|
||||||
AdS ; -- sentence adverbial e.g. "therefore", "otherwise"
|
AdS ; -- sentence adverbial e.g. "therefore", "otherwise"
|
||||||
Prep ; -- pre/postposition, case e.g. "after", Adessive
|
Prep ; -- pre/postposition, case e.g. "after", Adessive
|
||||||
|
|
||||||
|
--!
|
||||||
--3 Sentences and relative clauses
|
--3 Sentences and relative clauses
|
||||||
--
|
--
|
||||||
|
-- This group has no lexical categories.
|
||||||
|
|
||||||
S ; -- sentence, e.g. "John walks"
|
S ; -- sentence, e.g. "John walks"
|
||||||
Slash ; -- sentence without NP, e.g. "John waits for (...)"
|
Slash ; -- sentence without NP, e.g. "John waits for (...)"
|
||||||
RP ; -- relative pronoun, e.g. "which", "the mother of whom"
|
RP ; -- relative pronoun, e.g. "which", "the mother of whom"
|
||||||
RC ; -- relative clause, e.g. "who walks", "that I wait for"
|
RC ; -- relative clause, e.g. "who walks", "that I wait for"
|
||||||
|
|
||||||
|
--!
|
||||||
--3 Questions and imperatives
|
--3 Questions and imperatives
|
||||||
--
|
--
|
||||||
|
-- This group has no lexical categories.
|
||||||
|
|
||||||
IP ; -- interrogative pronoun, e.g. "who", "whose mother", "which yellow car"
|
IP ; -- interrogative pronoun, e.g. "who", "whose mother", "which yellow car"
|
||||||
IAdv ; -- interrogative adverb., e.g. "when", "why"
|
IAdv ; -- interrogative adverb., e.g. "when", "why"
|
||||||
Qu ; -- question, e.g. "who walks"
|
Qu ; -- question, e.g. "who walks"
|
||||||
Imp ; -- imperative, e.g. "walk!"
|
Imp ; -- imperative, e.g. "walk!"
|
||||||
|
|
||||||
|
--!
|
||||||
--3 Coordination and subordination
|
--3 Coordination and subordination
|
||||||
--
|
--
|
||||||
|
|
||||||
@@ -103,13 +141,15 @@ cat
|
|||||||
ListAP ; -- list of adjectival phrases
|
ListAP ; -- list of adjectival phrases
|
||||||
ListNP ; -- list of noun phrases
|
ListNP ; -- list of noun phrases
|
||||||
|
|
||||||
|
--!
|
||||||
--3 Complete utterances
|
--3 Complete utterances
|
||||||
--
|
--
|
||||||
|
-- This group has no lexical categories.
|
||||||
|
|
||||||
Phr ; -- full phrase, e.g. "John walks.","Who walks?", "Wait for me!"
|
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."
|
Text ; -- sequence of phrases e.g. "One is odd. Therefore, two is even."
|
||||||
|
|
||||||
|
--!
|
||||||
--2 Rules
|
--2 Rules
|
||||||
--
|
--
|
||||||
-- This set of rules is minimal, in the sense of defining the simplest combinations
|
-- This set of rules is minimal, in the sense of defining the simplest combinations
|
||||||
@@ -118,11 +158,16 @@ cat
|
|||||||
-- access it through an intermediate library that defines more rules as
|
-- access it through an intermediate library that defines more rules as
|
||||||
-- 'macros' for combinations of the ones below.
|
-- 'macros' for combinations of the ones below.
|
||||||
|
|
||||||
|
--!
|
||||||
--3 Nouns and noun phrases
|
--3 Nouns and noun phrases
|
||||||
--
|
--
|
||||||
|
|
||||||
fun
|
fun
|
||||||
UseN : N -> CN ; -- "car"
|
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"
|
ModAdj : AP -> CN -> CN ; -- "red car"
|
||||||
DetNP : Det -> CN -> NP ; -- "every car"
|
DetNP : Det -> CN -> NP ; -- "every car"
|
||||||
MassNP : CN -> NP ; -- "wine"
|
MassNP : CN -> NP ; -- "wine"
|
||||||
@@ -132,38 +177,47 @@ fun
|
|||||||
DefManyNP : Num -> CN -> NP ; -- "the cars", "the 86 cars"
|
DefManyNP : Num -> CN -> NP ; -- "the cars", "the 86 cars"
|
||||||
ModGenOne : NP -> CN -> NP ; -- "John's car"
|
ModGenOne : NP -> CN -> NP ; -- "John's car"
|
||||||
ModGenMany : Num -> NP -> CN -> NP ; -- "John's cars", "John's 86 cars"
|
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"
|
AppFun : Fun -> NP -> CN ; -- "successor of zero"
|
||||||
AppFun2 : Fun2 -> NP -> Fun ; -- "flight from Paris"
|
AppFun2 : Fun2 -> NP -> Fun ; -- "flight from Paris"
|
||||||
CNthatS : CN -> S -> CN ; -- "idea that the Earth is flat"
|
CNthatS : CN -> S -> CN ; -- "idea that the Earth is flat"
|
||||||
UseInt : Int -> Num ; -- "32" --- assumes i > 1
|
|
||||||
NoNum : Num ; -- no numeral modifier
|
NoNum : Num ; -- no numeral modifier
|
||||||
|
|
||||||
|
--!
|
||||||
--3 Adjectives and adjectival phrases
|
--3 Adjectives and adjectival phrases
|
||||||
--
|
--
|
||||||
|
|
||||||
AdjP1 : Adj1 -> AP ; -- "red"
|
AdjP1 : Adj1 -> AP ; -- "red"
|
||||||
ComplAdj : Adj2 -> NP -> AP ; -- "divisible by two"
|
|
||||||
PositAdjP : AdjDeg -> AP ; -- "old"
|
PositAdjP : AdjDeg -> AP ; -- "old"
|
||||||
|
|
||||||
|
ComplAdj : Adj2 -> NP -> AP ; -- "divisible by two"
|
||||||
ComparAdjP : AdjDeg -> NP -> AP ; -- "older than John"
|
ComparAdjP : AdjDeg -> NP -> AP ; -- "older than John"
|
||||||
SuperlNP : AdjDeg -> CN -> NP ; -- "the oldest man"
|
SuperlNP : AdjDeg -> CN -> NP ; -- "the oldest man"
|
||||||
|
|
||||||
|
--!
|
||||||
--3 Verbs and verb phrases
|
--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"
|
PredV : V -> VG ; -- "walk", "doesn't walk"
|
||||||
PosA, NegA : AP -> VP ; -- "is old", "isn't old"
|
PredPassV : V -> VG ; -- "is seen", "is not seen"
|
||||||
PosCN, NegCN : CN -> VP ; -- "is a man", "isn't a man"
|
PredTV : TV -> NP -> VG ; -- "sees John", "doesn't see John"
|
||||||
PosTV, NegTV : TV -> NP -> VP ; -- "sees John", "doesn't see John"
|
PredVS : VS -> S -> VG ; -- "says that I run", "doesn't say..."
|
||||||
PosPassV, NegPassV : V -> VP ; -- "is seen", "is not seen"
|
PredVV : VV -> VG -> VG ; -- "can run", "can't run", "tries to run"
|
||||||
PosNP, NegNP : NP -> VP ; -- "is John", "is not John"
|
PredV3 : V3 -> NP -> NP -> VG ; -- "prefers wine to beer"
|
||||||
PosAdV, NegAdV : AdV -> VP ; -- "is everywhere", "is not in France"
|
|
||||||
PosVS, NegVS : VS -> S -> VP ; -- "says that I run", "doesn't say..."
|
PredNP : NP -> VG ; -- "is John", "is not John"
|
||||||
--- PosVV, NegVV : VV -> VP -> VP ; -- "can run", "can't run", "tries to run"
|
PredAdV : AdV -> VG ; -- "is everywhere", "is not in France"
|
||||||
PosV3, NegV3 : V3 -> NP -> NP -> VP ; -- "prefers wine to beer"
|
PredAP : AP -> VG ; -- "is old", "isn't old"
|
||||||
|
PredCN : CN -> VG ; -- "is a man", "isn't a man"
|
||||||
VTrans : TV -> V ; -- "loves"
|
VTrans : TV -> V ; -- "loves"
|
||||||
|
|
||||||
|
PosVG,NegVG : VG -> VP ; --
|
||||||
|
|
||||||
|
--!
|
||||||
--3 Adverbials
|
--3 Adverbials
|
||||||
--
|
--
|
||||||
-- Here is how complex adverbials can be formed and used.
|
-- Here is how complex adverbials can be formed and used.
|
||||||
@@ -175,7 +229,7 @@ fun
|
|||||||
AdvCN : CN -> AdV -> CN ; -- "house in London", "house today"
|
AdvCN : CN -> AdV -> CN ; -- "house in London", "house today"
|
||||||
AdvAP : AdA -> AP -> AP ; -- "very good"
|
AdvAP : AdA -> AP -> AP ; -- "very good"
|
||||||
|
|
||||||
|
--!
|
||||||
--3 Sentences and relative clauses
|
--3 Sentences and relative clauses
|
||||||
--
|
--
|
||||||
|
|
||||||
@@ -187,11 +241,12 @@ fun
|
|||||||
|
|
||||||
IdRP : RP ; -- "which"
|
IdRP : RP ; -- "which"
|
||||||
FunRP : Fun -> RP -> RP ; -- "the successor of 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"
|
RelSlash : RP -> Slash -> RC ; -- "that I wait for"/"for which I wait"
|
||||||
ModRC : CN -> RC -> CN ; -- "man who walks"
|
ModRC : CN -> RC -> CN ; -- "man who walks"
|
||||||
RelSuch : S -> RC ; -- "such that it is even"
|
RelSuch : S -> RC ; -- "such that it is even"
|
||||||
|
|
||||||
|
--!
|
||||||
--3 Questions and imperatives
|
--3 Questions and imperatives
|
||||||
--
|
--
|
||||||
|
|
||||||
@@ -200,7 +255,7 @@ fun
|
|||||||
FunIP : Fun -> IP -> IP ; -- "the mother of whom"
|
FunIP : Fun -> IP -> IP ; -- "the mother of whom"
|
||||||
NounIPOne, NounIPMany : CN -> IP ; -- "which car", "which cars"
|
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"
|
IntVP : IP -> VP -> Qu ; -- "who walks"
|
||||||
IntSlash : IP -> Slash -> Qu ; -- "whom does John see"
|
IntSlash : IP -> Slash -> Qu ; -- "whom does John see"
|
||||||
QuestAdv : IAdv -> NP -> VP -> Qu ; -- "why do you walk"
|
QuestAdv : IAdv -> NP -> VP -> Qu ; -- "why do you walk"
|
||||||
@@ -215,6 +270,7 @@ fun
|
|||||||
|
|
||||||
AdvS : AdS -> S -> Phr ; -- "Therefore, 2 is prime."
|
AdvS : AdS -> S -> Phr ; -- "Therefore, 2 is prime."
|
||||||
|
|
||||||
|
--!
|
||||||
--3 Coordination
|
--3 Coordination
|
||||||
--
|
--
|
||||||
-- We consider "n"-ary coordination, with "n" > 1. To this end, we have introduced
|
-- We consider "n"-ary coordination, with "n" > 1. To this end, we have introduced
|
||||||
@@ -243,6 +299,7 @@ fun
|
|||||||
TwoNP : NP -> NP -> ListNP ;
|
TwoNP : NP -> NP -> ListNP ;
|
||||||
ConsNP : ListNP -> NP -> ListNP ;
|
ConsNP : ListNP -> NP -> ListNP ;
|
||||||
|
|
||||||
|
--!
|
||||||
--3 Subordination
|
--3 Subordination
|
||||||
--
|
--
|
||||||
-- Subjunctions are different from conjunctions, but form
|
-- Subjunctions are different from conjunctions, but form
|
||||||
@@ -253,6 +310,7 @@ fun
|
|||||||
SubjQu : Subj -> S -> Qu -> Qu ; -- "if you are new, who are you?"
|
SubjQu : Subj -> S -> Qu -> Qu ; -- "if you are new, who are you?"
|
||||||
SubjVP : VP -> Subj -> S -> VP ; -- "(a man who) sings when he runs"
|
SubjVP : VP -> Subj -> S -> VP ; -- "(a man who) sings when he runs"
|
||||||
|
|
||||||
|
--!
|
||||||
--2 One-word utterances
|
--2 One-word utterances
|
||||||
--
|
--
|
||||||
-- These are, more generally, *one-phrase utterances*. The list below
|
-- These are, more generally, *one-phrase utterances*. The list below
|
||||||
@@ -263,6 +321,7 @@ fun
|
|||||||
PhrIP : IAdv -> Phr ; -- "Who?"
|
PhrIP : IAdv -> Phr ; -- "Who?"
|
||||||
PhrIAdv : IAdv -> Phr ; -- "Why?"
|
PhrIAdv : IAdv -> Phr ; -- "Why?"
|
||||||
|
|
||||||
|
--!
|
||||||
--2 Text formation
|
--2 Text formation
|
||||||
--
|
--
|
||||||
-- A text is a sequence of phrases. It is defined like a non-empty list.
|
-- A text is a sequence of phrases. It is defined like a non-empty list.
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
--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
|
-- Here we have some words belonging to closed classes and appearing
|
||||||
-- in all languages we have considered.
|
-- in all languages we have considered.
|
||||||
@@ -8,35 +10,67 @@
|
|||||||
abstract Structural = Combinations ** {
|
abstract Structural = Combinations ** {
|
||||||
|
|
||||||
fun
|
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
|
EveryDet, WhichDet, AllDet, -- every, sg which, sg all
|
||||||
SomeDet, AnyDet, NoDet, -- sg some, any, no
|
SomeDet, AnyDet, NoDet, -- sg some, any, no
|
||||||
MostDet, MostsDet, ManyDet, MuchDet : Det ; -- sg most, pl most, many, much
|
MostDet, MostsDet, ManyDet, MuchDet : Det ; -- sg most, pl most, many, much
|
||||||
ThisDet, ThatDet : Det ; -- this, that
|
ThisDet, ThatDet : Det ; -- this, that
|
||||||
|
|
||||||
-- Many plural determiners can take a numeral modifier.
|
|
||||||
|
|
||||||
AllsDet, WhichsDet, -- pl all, which (86)
|
AllsDet, WhichsDet, -- pl all, which (86)
|
||||||
SomesDet, AnysDet, NosDet, -- pl some, any, no
|
SomesDet, AnysDet, NosDet, -- pl some, any, no
|
||||||
TheseDet, ThoseDet : Num -> Det ; -- these, those (86)
|
TheseDet, ThoseDet : Num -> Det ; -- these, those (86)
|
||||||
|
|
||||||
ThisNP, ThatNP : NP ; -- this, that
|
ThisNP, ThatNP : NP ; -- this, that
|
||||||
TheseNP, ThoseNP : Num -> NP ; -- these, those (86)
|
TheseNP, ThoseNP : Num -> NP ; -- these, those (86)
|
||||||
INP, ThouNP, HeNP, SheNP, ItNP : NP ; -- personal pronouns in singular
|
INP, ThouNP, HeNP, SheNP, ItNP : NP ; -- personal pronouns in singular
|
||||||
WeNP, YeNP : Num -> NP ; -- these pronouns can take numeral
|
WeNP, YeNP : Num -> NP ; -- these pronouns can take numeral
|
||||||
TheyNP : NP ; -- personal pronouns in plural
|
TheyNP : NP ; YouNP : NP ; -- they, the polite you
|
||||||
YouNP : NP ; -- the polite you
|
|
||||||
EverybodyNP, SomebodyNP, NobodyNP, -- everybody, somebody, nobody
|
EverybodyNP, SomebodyNP, NobodyNP, -- everybody, somebody, nobody
|
||||||
EverythingNP, SomethingNP, NothingNP : NP ; -- everything, something, nothing
|
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
|
WhenIAdv,WhereIAdv,WhyIAdv,HowIAdv : IAdv ; -- when, where, why, how
|
||||||
EverywhereNP, SomewhereNP,NowhereNP : AdV ; -- everywhere, somewhere, nowhere
|
EverywhereNP, SomewhereNP,NowhereNP : AdV ; -- everywhere, somewhere, nowhere
|
||||||
AndConj, OrConj : Conj ; -- and, or
|
|
||||||
BothAnd, EitherOr, NeitherNor : ConjD ; -- both-and, either-or, neither-nor
|
|
||||||
IfSubj, WhenSubj, AlthoughSubj : Subj ; -- if, when, although
|
|
||||||
PhrYes, PhrNo : Phr ; -- yes, no
|
|
||||||
VeryAdv, TooAdv : AdA ; -- very, too
|
VeryAdv, TooAdv : AdA ; -- very, too
|
||||||
AlmostAdv, QuiteAdv : AdA ; -- almost, quite
|
AlmostAdv, QuiteAdv : AdA ; -- almost, quite
|
||||||
OtherwiseAdv, ThereforeAdv : AdS ; -- therefore, otherwise
|
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
|
InPrep, OnPrep, ToPrep, FromPrep, -- spatial relations
|
||||||
ThroughPrep, AbovePrep, UnderPrep,
|
ThroughPrep, AbovePrep, UnderPrep,
|
||||||
InFrontPrep, BehindPrep, BetweenPrep : Prep ;
|
InFrontPrep, BehindPrep, BetweenPrep : Prep ;
|
||||||
@@ -44,4 +78,13 @@ fun
|
|||||||
WithPrep, WithoutPrep, ByMeansPrep : Prep ; -- some other relations
|
WithPrep, WithoutPrep, ByMeansPrep : Prep ; -- some other relations
|
||||||
PartPrep : Prep ; -- partitive "of" ("bottle of wine")
|
PartPrep : Prep ; -- partitive "of" ("bottle of wine")
|
||||||
AgentPrep : Prep ; -- agent "by" in passive constructions
|
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
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,36 @@
|
|||||||
-- added 19/11/2003
|
-- added 19/11/2003 -- 21/11
|
||||||
|
|
||||||
-- Combinations.gf
|
-- Combinations.gf
|
||||||
cat
|
cat
|
||||||
Prep ; -- pre/postposition and/or case e.g.
|
Prep ; -- pre/postposition and/or case e.g.
|
||||||
Num ; -- numeral, e.g. "three", "879"
|
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
|
fun
|
||||||
ThereIsCN : CN -> S ; -- "there is a bar", "there are bars"
|
ThereIsCN : CN -> S ; -- "there is a bar", "there are bars"
|
||||||
ThereAreCN : Num -> CN -> S ; -- "there are 86 bars"
|
ThereAreCN : Num -> CN -> S ; -- "there are 86 bars"
|
||||||
PrepNP : Prep -> NP -> AdV ; -- "in London", "after the war" (replace LocNP)
|
PrepNP : Prep -> NP -> AdV ; -- "in London", "after the war" (replace LocNP)
|
||||||
MassNP : CN -> NP ; -- "wine"
|
MassNP : CN -> NP ; -- "wine"
|
||||||
--- PosVV, NegVV : VV -> VP -> VP ; -- "can run", "can't run", "tries to run"
|
PredAdV : AdV -> VP ; -- "is everywhere", "is not in France"
|
||||||
PosAdV, NegAdV : AdV -> VP ; -- "is everywhere", "is not in France"
|
|
||||||
AdjAdv : AP -> AdV ; -- "freely", "more consciously than you"
|
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
|
-- changed type signatures: added Num
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ lincat
|
|||||||
|
|
||||||
V = Verb ;
|
V = Verb ;
|
||||||
-- = {s : VForm => Str ; s1 : Particle}
|
-- = {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} ;
|
VP = {s : VForm => Str ; s2 : Number => Str ; isAux : Bool} ;
|
||||||
TV = TransVerb ;
|
TV = TransVerb ;
|
||||||
-- = Verb ** {s3 : Preposition} ;
|
-- = Verb ** {s3 : Preposition} ;
|
||||||
@@ -103,26 +105,19 @@ lin
|
|||||||
NoNum = noNum ;
|
NoNum = noNum ;
|
||||||
|
|
||||||
PredVP = predVerbPhrase ;
|
PredVP = predVerbPhrase ;
|
||||||
PosV = predVerb True ;
|
PosVG = predVerbGroup True ;
|
||||||
NegV = predVerb False ;
|
NegVG = predVerbGroup False ;
|
||||||
PosA = predAdjective True ;
|
|
||||||
NegA = predAdjective False ;
|
PredV = predVerb ;
|
||||||
PosCN = predCommNoun True ;
|
PredAP = predAdjective ;
|
||||||
NegCN = predCommNoun False ;
|
PredCN = predCommNoun ;
|
||||||
PosTV = complTransVerb True ;
|
PredTV = complTransVerb ;
|
||||||
NegTV = complTransVerb False ;
|
PredV3 = complDitransVerb ;
|
||||||
PosV3 = complDitransVerb True ;
|
PredPassV = passVerb ;
|
||||||
NegV3 = complDitransVerb False ;
|
PredNP = predNounPhrase ;
|
||||||
PosPassV = passVerb True ;
|
PredAdV = predAdverb ;
|
||||||
NegPassV = passVerb False ;
|
PredVS = complSentVerb ;
|
||||||
PosNP = predNounPhrase True ;
|
PredVV = complVerbVerb ;
|
||||||
NegNP = predNounPhrase False ;
|
|
||||||
PosAdV = predAdverb True ;
|
|
||||||
NegAdV = predAdverb False ;
|
|
||||||
PosVS = complSentVerb True ;
|
|
||||||
NegVS = complSentVerb False ;
|
|
||||||
--- PosVV = complVerbVerb True ;
|
|
||||||
--- NegVV = complVerbVerb False ;
|
|
||||||
VTrans = transAsVerb ;
|
VTrans = transAsVerb ;
|
||||||
|
|
||||||
AdjAdv a = advPost (a.s ! AAdv) ;
|
AdjAdv a = advPost (a.s ! AAdv) ;
|
||||||
|
|||||||
@@ -49,10 +49,10 @@ concrete StructuralEng of Structural =
|
|||||||
SomethingNP = nameNounPhrase (nameReg "something") ;
|
SomethingNP = nameNounPhrase (nameReg "something") ;
|
||||||
NothingNP = nameNounPhrase (nameReg "nothing") ;
|
NothingNP = nameNounPhrase (nameReg "nothing") ;
|
||||||
|
|
||||||
--- CanVV = vvCan ;
|
CanVV = vvCan ;
|
||||||
--- CanKnowVV = vvCan ;
|
CanKnowVV = vvCan ;
|
||||||
--- MustVV = vvMust ;
|
MustVV = vvMust ;
|
||||||
--- WantVV = verbNoPart (regVerbP3 "want") ** {isAux = False} ;
|
WantVV = verbNoPart (regVerbP3 "want") ** {isAux = False} ;
|
||||||
|
|
||||||
HowIAdv = ss "how" ;
|
HowIAdv = ss "how" ;
|
||||||
WhenIAdv = ss "when" ;
|
WhenIAdv = ss "when" ;
|
||||||
|
|||||||
@@ -294,8 +294,21 @@ oper
|
|||||||
-- There's also a parameter telling if the verb is an auxiliary:
|
-- There's also a parameter telling if the verb is an auxiliary:
|
||||||
-- this is needed in question.
|
-- 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} ;
|
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
|
-- From the inflection table, we selecting the finite form as function
|
||||||
-- of person and number:
|
-- of person and number:
|
||||||
|
|
||||||
@@ -309,15 +322,15 @@ oper
|
|||||||
-- N.B. negation is *not* a function applicable to a verb phrase, since
|
-- N.B. negation is *not* a function applicable to a verb phrase, since
|
||||||
-- double negations with "don't" are not grammatical.
|
-- double negations with "don't" are not grammatical.
|
||||||
|
|
||||||
predVerb : Bool -> Verb -> VerbPhrase = \b,walk ->
|
predVerb : Verb -> VerbGroup = \walk ->
|
||||||
if_then_else VerbPhrase b
|
{s = \\b,v => if_then_Str b
|
||||||
{s = \\v => walk.s ! v ++ walk.s1 ;
|
(walk.s ! v ++ walk.s1)
|
||||||
s2 = \\_ => [] ;
|
(contractNot (verbP3Do.s ! v)) ;
|
||||||
isAux = False
|
s2 = \\b,_ => if_then_Str b
|
||||||
}
|
[]
|
||||||
{s = \\v => contractNot (verbP3Do.s ! v) ;
|
(walk.s ! InfImp ++ walk.s1) ;
|
||||||
s2 = \\_ => walk.s ! InfImp ++ walk.s1 ;
|
isAuxT = False ;
|
||||||
isAux = True
|
isAuxF = True
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
-- Sometimes we want to extract the verb part of a verb phrase.
|
-- 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
|
-- The third rule is overgenerating: "is every man" has to be ruled out
|
||||||
-- on semantic grounds.
|
-- on semantic grounds.
|
||||||
|
|
||||||
predAdjective : Bool -> Adjective -> VerbPhrase = \b,old ->
|
predAdjective : Adjective -> VerbGroup = \old ->
|
||||||
{s = beOrNotBe b ;
|
{s = beOrNotBe ;
|
||||||
s2 = \\_ => old.s ! AAdj ;
|
s2 = \\_,_ => old.s ! AAdj ;
|
||||||
isAux = True
|
isAuxT, isAuxF = True
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
predCommNoun : Bool -> CommNoun -> VerbPhrase = \b,man ->
|
predCommNoun : CommNoun -> VerbGroup = \man ->
|
||||||
{s = beOrNotBe b ;
|
{s = beOrNotBe ;
|
||||||
s2 = \\n => indefNoun n man ;
|
s2 = \\_,n => indefNoun n man ;
|
||||||
isAux = True
|
isAuxT, isAuxF = True
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
predNounPhrase : Bool -> NounPhrase -> VerbPhrase = \b,john ->
|
predNounPhrase : NounPhrase -> VerbGroup = \john ->
|
||||||
{s = beOrNotBe b ;
|
{s = beOrNotBe ;
|
||||||
s2 = \\_ => john.s ! NomP ;
|
s2 = \\_,_ => john.s ! NomP ;
|
||||||
isAux = True
|
isAuxT, isAuxF = True
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
predAdverb : Bool -> Adverb -> VerbPhrase = \b,elsewhere ->
|
predAdverb : Adverb -> VerbGroup = \elsewhere ->
|
||||||
{s = beOrNotBe b ;
|
{s = beOrNotBe ;
|
||||||
s2 = \\_ => elsewhere.s ;
|
s2 = \\_,_ => elsewhere.s ;
|
||||||
isAux = True
|
isAuxT, isAuxF = True
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
-- We use an auxiliary giving all forms of "be".
|
-- 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
|
if_then_else (VForm => Str) b
|
||||||
verbBe.s
|
verbBe.s
|
||||||
(table {
|
(table {
|
||||||
@@ -378,16 +391,13 @@ oper
|
|||||||
-- Particles produce free variation: before or after the complement
|
-- Particles produce free variation: before or after the complement
|
||||||
-- ("I switch on the TV" / "I switch the TV on").
|
-- ("I switch on the TV" / "I switch the TV on").
|
||||||
|
|
||||||
complTransVerb : Bool -> TransVerb -> NounPhrase -> VerbPhrase =
|
complTransVerb : TransVerb -> NounPhrase -> VerbGroup = \lookat,john ->
|
||||||
\b,lookat,john ->
|
let lookatjohn = bothWays lookat.s1 (lookat.s3 ++ john.s ! AccP)
|
||||||
let {lookatjohn = bothWays lookat.s1 (lookat.s3 ++ john.s ! AccP)} in
|
in {s = \\b,v => if_then_Str b (lookat.s ! v) (contractNot (verbP3Do.s ! v)) ;
|
||||||
if_then_else VerbPhrase b
|
s2 = \\b,_ => if_then_Str b lookatjohn (lookat.s ! InfImp ++ lookatjohn) ;
|
||||||
{s = lookat.s ;
|
isAuxT = False ;
|
||||||
s2 = \\_ => lookatjohn ;
|
isAuxF = True
|
||||||
isAux = False}
|
} ;
|
||||||
{s = \\v => contractNot (verbP3Do.s ! v) ;
|
|
||||||
s2 = \\_ => lookat.s ! InfImp ++ lookatjohn ;
|
|
||||||
isAux = True} ;
|
|
||||||
|
|
||||||
|
|
||||||
-- Verbs that take direct object and a particle:
|
-- 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.
|
-- Therefore, the function can also be used for "he is swum", etc.
|
||||||
-- The syntax is the same as for adjectival predication.
|
-- The syntax is the same as for adjectival predication.
|
||||||
|
|
||||||
passVerb : Bool -> Verb -> VerbPhrase = \b,love ->
|
passVerb : Verb -> VerbGroup = \love ->
|
||||||
predAdjective b (adj2adjPhrase (regAdjective (love.s ! PPart))) ;
|
predAdjective (adj2adjPhrase (regAdjective (love.s ! PPart))) ;
|
||||||
|
|
||||||
-- Transitive verbs can be used elliptically as verbs. The semantics
|
-- Transitive verbs can be used elliptically as verbs. The semantics
|
||||||
-- is left to applications. The definition is trivial, due to record
|
-- is left to applications. The definition is trivial, due to record
|
||||||
@@ -426,20 +436,15 @@ oper
|
|||||||
mkDitransVerb : Verb -> Preposition -> Preposition -> DitransVerb = \v,p1,p2 ->
|
mkDitransVerb : Verb -> Preposition -> Preposition -> DitransVerb = \v,p1,p2 ->
|
||||||
v ** {s3 = p1 ; s4 = p2} ;
|
v ** {s3 = p1 ; s4 = p2} ;
|
||||||
|
|
||||||
complDitransVerb :
|
complDitransVerb : DitransVerb -> NounPhrase -> NounPhrase -> VerbGroup =
|
||||||
Bool -> DitransVerb -> NounPhrase -> NounPhrase -> VerbPhrase =
|
\give,you,beer ->
|
||||||
\b,give,you,beer ->
|
let
|
||||||
let {
|
|
||||||
youbeer = give.s1 ++ give.s3 ++ you.s ! AccP ++ give.s4 ++ beer.s ! AccP
|
youbeer = give.s1 ++ give.s3 ++ you.s ! AccP ++ give.s4 ++ beer.s ! AccP
|
||||||
} in
|
in
|
||||||
if_then_else VerbPhrase b
|
{s = \\b,v => if_then_Str b (give.s ! v) (contractNot (verbP3Do.s ! v)) ;
|
||||||
{s = give.s ;
|
s2 = \\b,_ => if_then_Str b youbeer (give.s ! InfImp ++ youbeer) ;
|
||||||
s2 = \\_ => youbeer ;
|
isAuxT = False ;
|
||||||
isAux = False
|
isAuxF = True
|
||||||
}
|
|
||||||
{s = \\v => contractNot (verbP3Do.s ! v) ;
|
|
||||||
s2 = \\_ => give.s ! InfImp ++ youbeer ;
|
|
||||||
isAux = True
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
@@ -510,12 +515,6 @@ oper
|
|||||||
walks.s2 ! john.n) ;
|
walks.s2 ! john.n) ;
|
||||||
|
|
||||||
|
|
||||||
-- This is a macro for simultaneous predication and complementization.
|
|
||||||
|
|
||||||
predTransVerb : Bool -> NounPhrase -> TransVerb -> NounPhrase -> Sentence =
|
|
||||||
\b,you,see,john ->
|
|
||||||
predVerbPhrase you (complTransVerb b see john) ;
|
|
||||||
|
|
||||||
|
|
||||||
--3 Sentence-complement verbs
|
--3 Sentence-complement verbs
|
||||||
--
|
--
|
||||||
@@ -525,16 +524,13 @@ oper
|
|||||||
|
|
||||||
-- To generate "says that John walks" / "doesn't say that John walks":
|
-- To generate "says that John walks" / "doesn't say that John walks":
|
||||||
|
|
||||||
complSentVerb : Bool -> SentenceVerb -> Sentence -> VerbPhrase =
|
complSentVerb : SentenceVerb -> Sentence -> VerbGroup = \say,johnruns ->
|
||||||
\b,say,johnruns ->
|
|
||||||
let {thatjohnruns = optStr "that" ++ johnruns.s} in
|
let {thatjohnruns = optStr "that" ++ johnruns.s} in
|
||||||
if_then_else VerbPhrase b
|
{s = \\b,v => if_then_Str b (say.s ! v) (contractNot (verbP3Do.s ! v)) ;
|
||||||
{s = say.s ;
|
s2 = \\b,_ => if_then_Str b thatjohnruns (say.s ! InfImp ++ thatjohnruns) ;
|
||||||
s2 = \\_ => thatjohnruns ;
|
isAuxT = False ;
|
||||||
isAux = False}
|
isAuxF = True
|
||||||
{s = \\v => contractNot (verbP3Do.s ! v) ;
|
} ;
|
||||||
s2 = \\_ => say.s ! InfImp ++ thatjohnruns ;
|
|
||||||
isAux = True} ;
|
|
||||||
|
|
||||||
--3 Verb-complement verbs
|
--3 Verb-complement verbs
|
||||||
--
|
--
|
||||||
@@ -552,17 +548,26 @@ oper
|
|||||||
-- The contraction of "not" is not provided, since it would require changing
|
-- The contraction of "not" is not provided, since it would require changing
|
||||||
-- the verb parameter type.
|
-- the verb parameter type.
|
||||||
|
|
||||||
complVerbVerb : Bool -> VerbVerb -> VerbPhrase -> VerbPhrase = \b,try,run ->
|
complVerbVerb : VerbVerb -> VerbGroup -> VerbGroup = \try,run ->
|
||||||
let to = if_then_else Str try.isAux [] "to"
|
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
|
in
|
||||||
if_then_else VerbPhrase b
|
{s = \\b,v => if_then_Str b
|
||||||
{s = \\v => try.s ! v ++ try.s1 ++ to ++ run.s ! InfImp ;
|
(try.s ! v ++ try.s1 ++ to ++ run.s ! True ! InfImp)
|
||||||
s2 = run.s2 ;
|
(dont ! v) ;
|
||||||
isAux = try.isAux
|
s2 = \\b,v => if_then_Str b
|
||||||
}
|
(run.s2 ! True ! v)
|
||||||
{s = \\v => try.s ! v ++ "not" ;
|
(trnot ++ run.s ! True ! InfImp ++ run.s2 ! True ! v) ;
|
||||||
s2 = \\n => run.s ! InfImp ++ run.s2 ! n ;
|
isAuxT = taux ;
|
||||||
isAux = True
|
isAuxF = True
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
-- The three most important example auxiliaries.
|
-- The three most important example auxiliaries.
|
||||||
@@ -769,7 +774,7 @@ oper
|
|||||||
Sg => nameNounPhrase (nameReg "there") ;
|
Sg => nameNounPhrase (nameReg "there") ;
|
||||||
Pl => {s = \\_ => "there" ; n = Pl ; p = P3}
|
Pl => {s = \\_ => "there" ; n = Pl ; p = P3}
|
||||||
})
|
})
|
||||||
(predNounPhrase True (indefNounPhraseNum n num bar)) ;
|
(predVerbGroup True (predNounPhrase (indefNounPhraseNum n num bar))) ;
|
||||||
|
|
||||||
|
|
||||||
--3 Wh-questions
|
--3 Wh-questions
|
||||||
|
|||||||
210
grammars/resource/swedish/CombinationsSwe.gf
Normal file
210
grammars/resource/swedish/CombinationsSwe.gf
Normal 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 ;
|
||||||
|
|
||||||
|
} ;
|
||||||
115
grammars/resource/swedish/StructuralSwe.gf
Normal file
115
grammars/resource/swedish/StructuralSwe.gf
Normal 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" ;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -129,10 +129,10 @@ oper
|
|||||||
mkDeterminerSg : DetSg -> SpeciesP -> Determiner = \en, b ->
|
mkDeterminerSg : DetSg -> SpeciesP -> Determiner = \en, b ->
|
||||||
{s = en ; n = Sg ; b = b} ;
|
{s = en ; n = Sg ; b = b} ;
|
||||||
|
|
||||||
mkDeterminerPl : DetPl -> SpeciesP -> Determiner = \alla ->
|
mkDeterminerPl : DetPl -> SpeciesP -> Determiner = \alla,b ->
|
||||||
mkDeterminerPlNum alla noNum ;
|
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 ;
|
{s = \\_,_ => alla ++ n.s ! Nom ;
|
||||||
n = Pl ;
|
n = Pl ;
|
||||||
b = b
|
b = b
|
||||||
@@ -202,7 +202,7 @@ oper
|
|||||||
detNounPhrase
|
detNounPhrase
|
||||||
(mkDeterminerSgGender (table {g => artDef ! cn.p ! ASg g}) (DefP Def)) cn ;
|
(mkDeterminerSgGender (table {g => artDef ! cn.p ! ASg g}) (DefP Def)) cn ;
|
||||||
deDet : Numeral -> CommNounPhrase -> NounPhrase = \n,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
|
-- It is useful to have macros for indefinite and definite, singular and plural
|
||||||
-- noun-phrase-like syncategorematic expressions.
|
-- noun-phrase-like syncategorematic expressions.
|
||||||
@@ -447,50 +447,53 @@ oper
|
|||||||
-- to account for word order variations.
|
-- to account for word order variations.
|
||||||
|
|
||||||
VerbPhrase : Type = Verb ** {s2 : Str ; s3 : Gender => Number => Str} ;
|
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.
|
-- 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.
|
-- 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
|
-- N.B. negation is *not* a function applicable to a verb phrase, since
|
||||||
-- double negations with "inte" are not grammatical.
|
-- double negations with "inte" are not grammatical.
|
||||||
|
|
||||||
predVerb : Bool -> Verb -> VerbPhrase = \b,se ->
|
predVerb : Verb -> VerbGroup = \se ->
|
||||||
se ** {
|
se ** {
|
||||||
s2 = negation b ;
|
s2 = negation ;
|
||||||
s3 = \\_,_ => []
|
s3 = \\_,_ => []
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
negation : Bool -> Str = \b -> if_then_else Str b [] "inte" ;
|
negation : Bool => Str = \\b => if_then_Str b [] "inte" ;
|
||||||
|
|
||||||
-- Sometimes we want to extract the verb part of a verb phrase.
|
|
||||||
|
|
||||||
verbOfPhrase : VerbPhrase -> Verb = \v -> {s = v.s} ;
|
|
||||||
|
|
||||||
-- Verb phrases can also be formed from adjectives ("är snäll"),
|
-- Verb phrases can also be formed from adjectives ("är snäll"),
|
||||||
-- common nouns ("är en man"), and noun phrases ("är den yngste mannen").
|
-- 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
|
-- The third rule is overgenerating: "är varje man" has to be ruled out
|
||||||
-- on semantic grounds.
|
-- on semantic grounds.
|
||||||
|
|
||||||
predAdjective : Bool -> Adjective -> VerbPhrase = \b,arg ->
|
predAdjective : Adjective -> VerbGroup = \arg ->
|
||||||
verbVara ** {
|
verbVara ** {
|
||||||
s2 = negation b ;
|
s2 = negation ;
|
||||||
s3 = \\g,n => arg.s ! mkAdjForm Indef n g NoMasc ! Nom
|
s3 = \\g,n => arg.s ! mkAdjForm Indef n g NoMasc ! Nom
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
predCommNoun : Bool -> CommNounPhrase -> VerbPhrase = \b,man ->
|
predCommNoun : CommNounPhrase -> VerbGroup = \man ->
|
||||||
verbVara ** {
|
verbVara ** {
|
||||||
s2 = negation b ;
|
s2 = negation ;
|
||||||
s3 = \\_,n => indefNoun n man
|
s3 = \\_,n => indefNoun n man
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
predNounPhrase : Bool -> NounPhrase -> VerbPhrase = \b,john ->
|
predNounPhrase : NounPhrase -> VerbGroup = \john ->
|
||||||
verbVara ** {
|
verbVara ** {
|
||||||
s2 = negation b ;
|
s2 = negation ;
|
||||||
s3 = \\_,_ => john.s ! PNom
|
s3 = \\_,_ => john.s ! PNom
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
predAdverb : Bool -> Adverb -> VerbPhrase = \b,ute ->
|
predAdverb : Adverb -> VerbGroup = \ute ->
|
||||||
verbVara ** {
|
verbVara ** {
|
||||||
s2 = negation b ;
|
s2 = negation ;
|
||||||
s3 = \\_,_ => ute.s
|
s3 = \\_,_ => ute.s
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
@@ -517,9 +520,9 @@ oper
|
|||||||
|
|
||||||
-- The rule for using transitive verbs is the complementization rule:
|
-- 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 ;
|
{s = se.s ;
|
||||||
s2 = negation b ;
|
s2 = negation ;
|
||||||
s3 = \\_,_ => se.s2 ++ dig.s ! PAcc
|
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
|
-- The syntax is the same as for active verbs, with the choice of the
|
||||||
-- "s" passive form.
|
-- "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} ;
|
{s = table {VPres m _ => se.s ! VPres m Pass} ;
|
||||||
s2 = negation b ;
|
s2 = negation ;
|
||||||
s3 = \\_,_ => []
|
s3 = \\_,_ => []
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
@@ -552,10 +555,9 @@ oper
|
|||||||
v ** {s2 = p1 ; s3 = p2} ;
|
v ** {s2 = p1 ; s3 = p2} ;
|
||||||
|
|
||||||
complDitransVerb :
|
complDitransVerb :
|
||||||
Bool -> DitransVerb -> NounPhrase -> NounPhrase -> VerbPhrase =
|
DitransVerb -> NounPhrase -> NounPhrase -> VerbGroup = \ge,dig,vin ->
|
||||||
\b,ge,dig,vin ->
|
|
||||||
{s = ge.s ;
|
{s = ge.s ;
|
||||||
s2 = negation b ;
|
s2 = negation ;
|
||||||
s3 = \\_,_ => ge.s2 ++ dig.s ! PAcc ++ ge.s3 ++ vin.s ! PAcc
|
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
|
--3 Sentence-complement verbs
|
||||||
--
|
--
|
||||||
@@ -646,9 +644,27 @@ oper
|
|||||||
|
|
||||||
SentenceVerb : Type = Verb ;
|
SentenceVerb : Type = Verb ;
|
||||||
|
|
||||||
complSentVerb : Bool -> SentenceVerb -> Sentence -> VerbPhrase = \b,se,duler ->
|
complSentVerb : SentenceVerb -> Sentence -> VerbGroup = \se,duler ->
|
||||||
{s = se.s ; s2 = negation b ; s3 = \\_,_ => optStr "att" ++ duler.s ! Main} ;
|
{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
|
--2 Sentences missing noun phrases
|
||||||
@@ -668,7 +684,7 @@ oper
|
|||||||
let {
|
let {
|
||||||
jag = Jag.s ! PNom ;
|
jag = Jag.s ! PNom ;
|
||||||
ser = se.s ! VPres Indicat Act ;
|
ser = se.s ! VPres Indicat Act ;
|
||||||
inte = negation b
|
inte = negation ! b
|
||||||
} in
|
} in
|
||||||
{s = table {
|
{s = table {
|
||||||
Main => jag ++ ser ++ inte ;
|
Main => jag ++ ser ++ inte ;
|
||||||
|
|||||||
46
grammars/resource/swedish/TestResourceSwe.gf
Normal file
46
grammars/resource/swedish/TestResourceSwe.gf
Normal 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 ;
|
||||||
|
} ;
|
||||||
Reference in New Issue
Block a user