newly organized resource with tense in lib

This commit is contained in:
aarne
2004-11-16 16:28:22 +00:00
parent 7a16b4501f
commit 2bef5f7a1c
21 changed files with 3941 additions and 0 deletions

View File

@@ -0,0 +1,154 @@
--1 Abstract Syntax Categories for Multilingual Resource Grammar
--
-- Aarne Ranta 2002 -- 2004
--
-- Although concrete syntax differs a lot between different languages,
-- many structures can be treated as common, on the level
-- of abstraction that GF provides.
-- What we will present in the following is a linguistically oriented abstract
-- syntax that has been successfully defined for the following languages:
--
--* $Eng$lish
--* $Fin$nish
--* $Fre$nch
--* $Ger$man
--* $Ita$lian
--* $Rus$sian
--* $Swe$dish
--
-- The three-letter prefixes are used in file names all over the resource
-- grammar library; we refer to them commonly as $X$ below.
--!
-- The grammar has been applied to define language
-- fragments on technical or near-to-technical domains: database queries,
-- video recorder dialogue systems, software specifications, and a
-- health-related phrase book. Each new application helped to identify some
-- missing structures in the resource and suggested some additions, but the
-- number of required additions was usually small.
--
-- To use the resource in applications, you need the following
-- $cat$ and $fun$ rules in $oper$ form, completed by taking the
-- $lincat$ and $lin$ judgements of a particular language. This is done
-- by using, instead of this module, the $reuse$ module which has the name
-- $ResourceX$. It is located in the subdirectory
-- $lib/resource/lang$ where $lang$ is the full name of the language.
abstract Categories = PredefAbs ** {
--!
--2 Categories
--
-- The categories of this resource grammar are mostly 'standard' categories
-- of linguistics. Their is no claim that they correspond to semantic categories
-- definable in type theory: to define such correspondences is the business
-- of applications grammars. In general, the correspondence between linguistic
-- and semantic categories is many-to-many.
--
-- Categories that may look special are $A2$, $N2$, and $V2$. They are all
-- instances of endowing another category with a complement, which can be either
-- a direct object (whose case may vary) or a prepositional phrase. Prepositional
-- phrases that are not complements belong to the category
-- $Adv$ of adverbs.
--
-- In each group below, some categories are *lexical* in the sense of only
-- containing atomic elements. These elements are not necessarily expressed by
-- one word in all languages; the essential thing is that they have no
-- constituents. Thus they have no productions in this part of the
-- resource grammar. The $ParadigmsX$ grammars provide ways of defining
-- lexical elements.
--
-- Lexical categories are listed before other categories
-- in each group and divided by an empty line.
--!
--3 Nouns and noun phrases
--
cat
N ; -- simple common noun, e.g. "car"
CN ; -- common noun phrase, e.g. "red car", "car that John owns"
N2 ; -- function word, e.g. "mother (of)"
N3 ; -- two-place function, e.g. "flight (from) (to)"
PN ; -- proper name, e.g. "John", "New York"
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
--
A1 ; -- one-place adjective, e.g. "even"
A2 ; -- two-place adjective, e.g. "divisible (by)"
ADeg ; -- degree adjective, e.g. "big/bigger/biggest"
AP ; -- adjective phrase, e.g. "divisible by two", "bigger than John"
-- The difference between $A1$ and $ADeg$ is that the former has no
-- comparison forms.
--!
--3 Verbs and verb phrases
--
V ; -- one-place verb, e.g. "walk"
V2 ; -- two-place verb, e.g. "love", "wait (for)", "switch on"
V3 ; -- three-place verb, e.g. "give", "prefer (stg) (to stg)"
VS ; -- sentence-compl. verb, e.g. "say", "prove"
VV ; -- verb-compl. verb, e.g. "can", "want"
VG ; -- verbal group, e.g. "switch the light on"
VP ; -- verb phrase, e.g. "switch the light on", "don't run"
--!
--3 Adverbs and prepositions/cases
--
Adv ; -- adverbial e.g. "now", "in the house"
AdA ; -- ad-adjective e.g. "very"
AdS ; -- sentence adverbial e.g. "therefore", "otherwise"
PP ; -- prepositional phrase e.g. "in London"
Prep ; -- pre/postposition, case e.g. "after", Adessive
--!
--3 Sentences and relative clauses
--
-- This group has no lexical categories.
S ; -- sentence (fixed tense) e.g. "John walks", "John walked"
Cl ; -- clause (variable tense) e.g. "John walks"/"John walked"
Slash ; -- sentence without NP, e.g. "John waits for (...)"
RP ; -- relative pronoun, e.g. "which", "the mother of whom"
RC ; -- relative clause, e.g. "who walks", "that I wait for"
--!
--3 Questions and imperatives
--
-- This group has no lexical categories.
IP ; -- interrogative pronoun, e.g. "who", "whose mother", "which yellow car"
IAdv ; -- interrogative adverb., e.g. "when", "why"
Qu ; -- question, e.g. "who walks"
Imp ; -- imperative, e.g. "walk!"
--!
--3 Coordination and subordination
--
Conj ; -- conjunction, e.g. "and"
ConjD ; -- distributed conj. e.g. "both - and"
Subj ; -- subjunction, e.g. "if", "when"
ListS ; -- list of sentences
ListAP ; -- list of adjectival phrases
ListNP ; -- list of noun phrases
--!
--3 Complete utterances
--
-- This group has no lexical categories.
Phr ; -- full phrase, e.g. "John walks.","Who walks?", "Wait for me!"
Text ; -- sequence of phrases e.g. "One is odd. Therefore, two is even."
}

View File

@@ -0,0 +1,34 @@
-- numerals from 1 to 999999 in decimal notation
abstract Numerals = {
flags startcat=Numeral ;
cat
Numeral ; -- 0..
Digit ; -- 2..9
Sub10 ; -- 1..9
Sub100 ; -- 1..99
Sub1000 ; -- 1..999
Sub1000000 ; -- 1..999999
fun
num : Sub1000000 -> Numeral ;
n2, n3, n4, n5, n6, n7, n8, n9 : Digit ;
pot01 : Sub10 ; -- 1
pot0 : Digit -> Sub10 ; -- d * 1
pot110 : Sub100 ; -- 10
pot111 : Sub100 ; -- 11
pot1to19 : Digit -> Sub100 ; -- 10 + d
pot0as1 : Sub10 -> Sub100 ; -- coercion of 1..9
pot1 : Digit -> Sub100 ; -- d * 10
pot1plus : Digit -> Sub10 -> Sub100 ; -- d * 10 + n
pot1as2 : Sub100 -> Sub1000 ; -- coercion of 1..99
pot2 : Sub10 -> Sub1000 ; -- m * 100
pot2plus : Sub10 -> Sub100 -> Sub1000 ; -- m * 100 + n
pot2as3 : Sub1000 -> Sub1000000 ; -- coercion of 1..999
pot3 : Sub1000 -> Sub1000000 ; -- m * 1000
pot3plus : Sub1000 -> Sub1000 -> Sub1000000 ; -- m * 1000 + n
}

View File

@@ -0,0 +1,195 @@
--!
--2 Rules
--
-- This set of rules is minimal, in the sense of defining the simplest combinations
-- of categories and not having redundant rules.
-- When the resource grammar is used as a library, it will often be useful to
-- access it through an intermediate library that defines more rules as
-- 'macros' for combinations of the ones below.
abstract Rules = Categories, Numerals ** {
--!
--3 Nouns and noun phrases
--
fun
UseN : N -> CN ; -- "car"
UsePN : PN -> NP ; -- "John"
SymbPN : String -> PN ; -- "x"
SymbCN : CN -> String -> CN ; -- "number x"
IndefOneNP : CN -> NP ; -- "a car", "cars"
IndefNumNP : Num -> CN -> NP ; -- "houses", "86 houses"
DefOneNP : CN -> NP ; -- "the car"
DefNumNP : Num -> CN -> NP ; -- "the cars", "the 86 cars"
DetNP : Det -> CN -> NP ; -- "every car"
MassNP : CN -> NP ; -- "wine"
AppN2 : N2 -> NP -> CN ; -- "successor of zero"
AppN3 : N3 -> NP -> N2 ; -- "flight from Paris"
UseN2 : N2 -> CN ; -- "successor"
ModAdj : AP -> CN -> CN ; -- "red car"
CNthatS : CN -> S -> CN ; -- "idea that the Earth is flat"
ModGenOne : NP -> CN -> NP ; -- "John's car"
ModGenNum : Num -> NP -> CN -> NP ; -- "John's cars", "John's 86 cars"
UseInt : Int -> Num ; -- "32" --- assumes i > 1
UseNumeral : Numeral -> Num ; -- "thirty-two" --- assumes i > 1
NoNum : Num ; -- no numeral modifier
--!
--3 Adjectives and adjectival phrases
--
UseA1 : A1 -> AP ; -- "red"
ComplA2 : A2 -> NP -> AP ; -- "divisible by two"
PositADeg : ADeg -> AP ; -- "old"
ComparADeg : ADeg -> NP -> AP ; -- "older than John"
SuperlADeg : ADeg -> AP ; -- "the oldest"
--!
--3 Verbs and verb phrases
--
-- The principal way of forming sentences ($S$) is by combining a noun phrase
-- with a verb phrase (the $PredVP$ rule below). In addition to this, verb
-- phrases have uses in relative clauses and questions. Verb phrases already
-- have (or have not) a negation, but they are formed from verbal groups
-- ($VG$), which have both positive and negative forms.
PredV : V -> VG ; -- "walk", "doesn't walk"
PredPassV : V -> VG ; -- "is seen", "is not seen"
PredV2 : V2 -> NP -> VG ; -- "sees John", "doesn't see John"
PredV3 : V3 -> NP -> NP -> VG ; -- "prefers wine to beer"
PredVS : VS -> S -> VG ; -- "says that I run", "doesn't say..."
PredVV : VV -> VG -> VG ; -- "can run", "can't run", "tries to run"
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 : V2 -> V ; -- "loves"
PosVG,NegVG : VG -> VP ; --
PredVG : NP -> VG -> Cl ; -- preserves all pol/tense variation
--!
--3 Adverbs
--
-- Here is how complex adverbs can be formed and used.
AdjAdv : AP -> Adv ; -- "freely", "more consciously than you"
AdvPP : PP -> Adv ; -- "in London", "after the war"
PrepNP : Prep -> NP -> PP ; -- "in London", "after the war"
AdvVP : VP -> Adv -> VP ; -- "always walks", "walks in the park"
AdvCN : CN -> PP -> CN ; -- "house in London"
AdvAP : AdA -> AP -> AP ; -- "very good"
--!
--3 Sentences and relative clauses
--
PredVP : NP -> VP -> S ; -- "John walks"
PosSlashV2,NegSlashV2 : NP -> V2 -> Slash ; -- "John sees", "John doesn't see"
OneVP : VP -> S ; -- "one walks"
ThereNP : NP -> S ; -- "there is a bar","there are 86 bars"
IdRP : RP ; -- "which"
FunRP : N2 -> RP -> RP ; -- "the successor of which"
RelVP : RP -> VP -> RC ; -- "who walks", "who doesn't walk"
RelSlash : RP -> Slash -> RC ; -- "that I wait for"/"for which I wait"
ModRC : CN -> RC -> CN ; -- "man who walks"
RelSuch : S -> RC ; -- "such that it is even"
--!
--3 Questions and imperatives
--
WhoOne, WhoMany : IP ; -- "who (is)", "who (are)"
WhatOne, WhatMany : IP ; -- "what (is)", "what (are)"
FunIP : N2 -> IP -> IP ; -- "the mother of whom"
NounIPOne, NounIPMany : CN -> IP ; -- "which car", "which cars"
QuestVP : NP -> VP -> Qu ; -- "does John walk"; "doesn't John walk"
IntVP : IP -> VP -> Qu ; -- "who walks"
IntSlash : IP -> Slash -> Qu ; -- "whom does John see"
QuestAdv : IAdv -> NP -> VP -> Qu ; -- "why do you walk"
IsThereNP : NP -> Qu ; -- "is there a bar", "are there (86) bars"
ImperVP : VP -> Imp ; -- "be a man"
IndicPhrase : S -> Phr ; -- "I walk."
QuestPhrase : Qu -> Phr ; -- "Do I walk?"
ImperOne, ImperMany : Imp -> Phr ; -- "Be a man!", "Be men!"
PrepS : PP -> AdS ; -- "in Sweden, (there are bears)"
AdvS : AdS -> S -> Phr ; -- "Therefore, 2 is prime."
--!
--3 Coordination
--
-- We consider "n"-ary coordination, with "n" > 1. To this end, we have introduced
-- a *list category* $ListX$ for each category $X$ whose expressions we want to
-- conjoin. Each list category has two constructors, the base case being $TwoX$.
-- We have not defined coordination of all possible categories here,
-- since it can be tricky in many languages. For instance, $VP$ coordination
-- is linguistically problematic in German because $VP$ is a discontinuous
-- category.
ConjS : Conj -> ListS -> S ; -- "John walks and Mary runs"
ConjAP : Conj -> ListAP -> AP ; -- "even and prime"
ConjNP : Conj -> ListNP -> NP ; -- "John or Mary"
ConjDS : ConjD -> ListS -> S ; -- "either John walks or Mary runs"
ConjDAP : ConjD -> ListAP -> AP ; -- "both even and prime"
ConjDNP : ConjD -> ListNP -> NP ; -- "either John or Mary"
TwoS : S -> S -> ListS ;
ConsS : ListS -> S -> ListS ;
TwoAP : AP -> AP -> ListAP ;
ConsAP : ListAP -> AP -> ListAP ;
TwoNP : NP -> NP -> ListNP ;
ConsNP : ListNP -> NP -> ListNP ;
--!
--3 Subordination
--
-- Subjunctions are different from conjunctions, but form
-- a uniform category among themselves.
SubjS : Subj -> S -> S -> S ; -- "if 2 is odd, 3 is even"
SubjImper : Subj -> S -> Imp -> Imp ; -- "if it is hot, use a glove!"
SubjQu : Subj -> S -> Qu -> Qu ; -- "if you are new, who are you?"
SubjVP : VP -> Subj -> S -> VP ; -- "(a man who) sings when he runs"
--!
--2 One-word utterances
--
-- These are, more generally, *one-phrase utterances*. The list below
-- is very incomplete.
PhrNP : NP -> Phr ; -- "Some man.", "John."
PhrOneCN, PhrManyCN : CN -> Phr ; -- "A car.", "Cars."
PhrIP : IAdv -> Phr ; -- "Who?"
PhrIAdv : IAdv -> Phr ; -- "Why?"
--!
--2 Text formation
--
-- A text is a sequence of phrases. It is defined like a non-empty list.
OnePhr : Phr -> Text ;
ConsPhr : Phr -> Text -> Text ;
} ;

View File

@@ -0,0 +1,91 @@
--1 GF Resource Grammar API for Structural Words
--
-- AR 21/11/2003
--
-- Here we have some words belonging to closed classes and appearing
-- in all languages we have considered.
-- Sometimes they are not really meaningful, e.g. $TheyNP$ in French
-- should really be replaced by masculine and feminine variants.
abstract Structural = Categories ** {
fun
--!
--2 Determiners and noun phrases
--
-- Many plural determiners can take a numeral modifier. So can the plural
-- pronouns "we" and "you".
EveryDet, WhichDet, AllMassDet, -- 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
AllNumDet, WhichNumDet, -- pl all, which (86)
SomeNumDet, AnyNumDet, NoNumDet, -- pl some, any, no
TheseNumDet, ThoseNumDet : Num -> Det ; -- these, those (86)
ThisNP, ThatNP : NP ; -- this, that
TheseNumNP, ThoseNumNP : Num -> NP ; -- these, those (86)
INP, ThouNP, HeNP, SheNP, ItNP : NP ; -- personal pronouns in singular
WeNumNP, YeNumNP : Num -> NP ; -- these pronouns can take numeral
TheyNP : NP ; YouNP : NP ; -- they, the polite you
EverybodyNP, SomebodyNP, NobodyNP, -- everybody, somebody, nobody
EverythingNP, SomethingNP, NothingNP : NP ; -- everything, something, nothing
--!
--2 Auxiliary verbs
--
-- Depending on language, all, some, or none of there verbs belong to
-- a separate class of *auxiliary* verbs. The list is incomplete.
CanVV, CanKnowVV, MustVV : VV ; -- can (pouvoir,savoir), must
WantVV : VV ; -- want (to do)
--!
--2 Adverbials
--
WhenIAdv,WhereIAdv,WhyIAdv,HowIAdv : IAdv ; -- when, where, why, how
EverywhereNP, SomewhereNP,NowhereNP : Adv ; -- everywhere, somewhere, nowhere
VeryAdv, TooAdv : AdA ; -- very, too
AlmostAdv, QuiteAdv : AdA ; -- almost, quite
OtherwiseAdv, ThereforeAdv : AdS ; -- therefore, otherwise
--!
--2 Conjunctions and subjunctions
--
AndConj, OrConj : Conj ; -- and, or
BothAnd, EitherOr, NeitherNor : ConjD ; -- both-and, either-or, neither-nor
IfSubj, WhenSubj, AlthoughSubj : Subj ; -- if, when, although
--!
--2 Prepositions
--
-- We have chosen a set of semantic relations expressible
-- by prepositions in some languages, by cases or postpositions in
-- others. Complement uses of prepositions are not included, and
-- should be treated by the use of many-place verbs, adjectives, and
-- functions.
InPrep, OnPrep, ToPrep, FromPrep, -- spatial relations
ThroughPrep, AbovePrep, UnderPrep,
InFrontPrep, BehindPrep, BetweenPrep : Prep ;
BeforePrep, DuringPrep, AfterPrep : Prep ; -- temporal relations
WithPrep, WithoutPrep, ByMeansPrep : Prep ; -- some other relations
PossessPrep : Prep ; -- possessive/genitive
PartPrep : Prep ; -- partitive "of" ("bottle of wine")
AgentPrep : Prep ; -- agent "by" in passive constructions
--!
--2 Affirmation and negation
--
-- The negative-positive (French "si", German "doch") is missing.
PhrYes, PhrNo : Phr ; -- yes, no
}

View File

@@ -0,0 +1,18 @@
abstract TestResource = Rules, Structural ** {
-- a random sample of lexicon to test resource grammar with
fun
Big, Happy, Small, Old, Young : ADeg ;
American, Finnish : A1 ;
Married : A2 ;
Man, Woman, Car, House, Light, Bar, Bottle, Wine : N ;
Walk, Run : V ;
Send, Wait, Love, Drink, SwitchOn, SwitchOff : V2 ;
Give, Prefer : V3 ;
Say, Prove : VS ;
Mother, Uncle : N2 ;
Connection : N3 ;
Well, Always : Adv ;
John, Mary : PN ;
} ;

View File

@@ -0,0 +1,83 @@
--# -path=.:../abstract:../../prelude
--1 The Top-Level Swedish Resource Grammar: Combination Rules
--
-- Aarne Ranta 2002 -- 2003
--
-- This is the Swedish concrete syntax of the multilingual resource
-- grammar. Most of the work is done in the file $SyntaxSwe.gf$.
-- However, for the purpose of documentation, we make here explicit the
-- linearization types of each category, so that their structures and
-- dependencies can be seen.
-- Another substantial part are the linearization rules of some
-- structural words.
--
-- The users of the resource grammar should not look at this file for the
-- linearization rules, which are in fact hidden in the document version.
-- They should use $resource.Abs.gf$ to access the syntactic rules.
-- This file can be consulted in those, hopefully rare, occasions in which
-- one has to know how the syntactic categories are
-- implemented. The parameter types are defined in $TypesSwe.gf$.
concrete CategoriesSwe of Categories = 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} ;
N2 = Function ;
-- = CommNoun ** {s2 : Preposition} ;
N3 = Function ** {s3 : Preposition} ;
Num = {s : Case => Str} ;
Prep = {s : Str} ;
A1 = Adjective ;
-- = {s : AdjFormPos => Case => Str} ;
A2 = Adjective ** {s2 : Preposition} ;
ADeg = {s : AdjForm => Str} ;
AP = Adjective ** {p : IsPostfixAdj} ;
V = Verb ;
-- = {s : VerbForm => Str ; s1 : Str} ;
VG = {s : SForm => Str ; s2 : Bool => Str ; s3 : SForm => Gender => Number => Str} ;
VP = {s : SForm => Str ; s2 : Str ; s3 : SForm => Gender => Number => Str} ;
V2 = TransVerb ;
-- = Verb ** {s2 : Preposition} ;
V3 = TransVerb ** {s3 : Preposition} ;
VS = Verb ;
VV = Verb ** {isAux : Bool} ;
Adv = Adverb ;
-- = {s : Str ; isPost : Bool} ;
PP = Adverb ;
S = Sentence ;
-- = {s : Order => Str} ;
Cl = Clause ;
-- = {s : Bool => SForm => 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} ;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,34 @@
concrete NumeralsSwe of Numerals = open MorphoSwe, Prelude in {
lincat
Digit = {s : DForm => Str} ;
Sub10 = {s : DForm => Str} ;
lin
num x = x ;
n2 = mkTal "två" "tolv" "tjugo" ;
n3 = mkTal "tre" "tretton" "trettio" ;
n4 = mkTal "fyra" "fjorton" "fyrtio" ;
n5 = regTal "fem" ;
n6 = regTal "sex" ;
n7 = mkTal "sju" "sjutton" "sjuttio" ;
n8 = mkTal "åtta" "arton" "åttio" ;
n9 = mkTal "nio" "nitton" "nittio" ;
pot01 = {s = table {f => "ett"}} ;
pot0 d = {s = table {f => d.s ! f}} ;
pot110 = ss "tio" ;
pot111 = ss "elva" ;
pot1to19 d = ss (d.s ! ton) ;
pot0as1 n = ss (n.s ! ental) ;
pot1 d = ss (d.s ! tiotal) ;
pot1plus d e = ss (d.s ! tiotal ++ e.s ! ental) ;
pot1as2 n = n ;
pot2 d = ss (d.s ! ental ++ "hundra") ;
pot2plus d e = ss (d.s ! ental ++ "hundra" ++ e.s) ;
pot2as3 n = n ;
pot3 n = ss (n.s ++ "tusen") ;
pot3plus n m = ss (n.s ++ "tusen" ++ m.s) ;
}

View File

@@ -0,0 +1,134 @@
concrete RulesSwe of Rules = CategoriesSwe, NumeralsSwe ** open Prelude, SyntaxSwe in {
lin
UseN = noun2CommNounPhrase ;
ModAdj = modCommNounPhrase ;
ModGenOne = npGenDet singular noNum ;
ModGenNum = npGenDet plural ;
UsePN = nameNounPhrase ;
UseN2 = funAsCommNounPhrase ;
AppN2 = appFunComm ;
AppN3 = appFun2 ;
UseA1 = adj2adjPhrase ;
ComplA2 = complAdj ;
PositADeg = positAdjPhrase ;
ComparADeg = comparAdjPhrase ;
SuperlADeg = superlAdjPhrase ;
DetNP = detNounPhrase ;
IndefOneNP = indefNounPhrase singular ;
IndefNumNP = indefNounPhraseNum plural ;
DefOneNP = defNounPhrase singular ;
DefNumNP = defNounPhraseNum plural ;
MassNP = detNounPhrase (mkDeterminerSg (detSgInvar []) IndefP) ;
UseInt i = {s = table {Nom => i.s ; Gen => i.s ++ "s"}} ; ---
UseNumeral i = {s = table {Nom => i.s ; Gen => i.s ++ "s"}} ; ---
NoNum = noNum ;
SymbPN i = {s = \\_ => i.s ; g = Neutr ; x = NoMasc} ;
SymbCN cn s =
{s = \\a,n,c => cn.s ! a ! n ! c ++ s.s ;
g = cn.g ;
x = cn.x ;
p = cn.p
} ;
CNthatS = nounThatSentence ;
PredVP = predVerbPhrase ;
PosVG = predVerbGroup True ;
NegVG = predVerbGroup False ;
PredVG = predVerbGroupClause ;
PredV = predVerb ;
PredAP = predAdjective ;
PredCN = predCommNoun ;
PredV2 = complTransVerb ;
PredV3 = complDitransVerb ;
PredPassV = passVerb ;
PredNP = predNounPhrase ;
PredAdv = predAdverb ;
PredVS = complSentVerb ;
PredVV = complVerbVerb ;
VTrans = transAsVerb ;
AdjAdv a = advPost (a.s ! adverbForm ! Nom) ;
AdvPP p = p ;
PrepNP p = prepPhrase p.s ; ---
AdvVP = adVerbPhrase ;
AdvCN = advCommNounPhrase ;
AdvAP = advAdjPhrase ;
ThereNP A = predVerbPhrase npDet
(predVerbGroup True
(complTransVerb (mkDirectVerb (deponentVerb verbFinnas)) A)) ;
PosSlashV2 = slashTransVerb True ;
NegSlashV2 = slashTransVerb False ;
OneVP = predVerbPhrase npMan ;
IdRP = identRelPron ;
FunRP = funRelPron ;
RelVP = relVerbPhrase ;
RelSlash = relSlash ;
ModRC = modRelClause ;
RelSuch = relSuch ;
WhoOne = intPronWho singular ;
WhoMany = intPronWho plural ;
WhatOne = intPronWhat singular ;
WhatMany = intPronWhat plural ;
FunIP = funIntPron ;
NounIPOne = nounIntPron singular ;
NounIPMany = nounIntPron plural ;
QuestVP = questVerbPhrase ;
IntVP = intVerbPhrase ;
IntSlash = intSlash ;
QuestAdv = questAdverbial ;
IsThereNP A = questVerbPhrase npDet
(predVerbGroup True
(complTransVerb (mkDirectVerb (deponentVerb verbFinnas)) A)) ;
ImperVP = imperVerbPhrase ;
IndicPhrase = indicUtt ;
QuestPhrase = interrogUtt ;
ImperOne = imperUtterance singular ;
ImperMany = imperUtterance plural ;
PrepS p = ss (p.s ++ ",") ;
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,114 @@
--# -path=.:../abstract:../../prelude
--1 The Top-Level Swedish Resource Grammar: Structural Words
--
-- Aarne Ranta 2002 -- 2004
--
concrete StructuralSwe of Structural =
CategoriesSwe ** open Prelude, SyntaxSwe in {
lin
INP = pronNounPhrase jag_32 ;
ThouNP = pronNounPhrase du_33 ;
HeNP = pronNounPhrase han_34 ;
SheNP = pronNounPhrase hon_35 ;
WeNumNP n = pronNounPhrase (pronWithNum vi_36 n) ;
YeNumNP n = pronNounPhrase (pronWithNum ni_37 n) ;
TheyNP = pronNounPhrase de_38 ;
YouNP = let {ni = pronNounPhrase ni_37 } in {s = ni.s ; g = ni.g ; n = Sg} ;
ItNP = pronNounPhrase det_40 ; ----
ThisNP = regNameNounPhrase ["det här"] Neutr NoMasc ;
ThatNP = regNameNounPhrase ["det där"] Neutr NoMasc ;
TheseNumNP n =
{s = \\c => ["det här"] ++ n.s ! npCase c ; g = Neutr ; n = Pl} ;
ThoseNumNP n =
{s = \\c => ["det där"] ++ n.s ! npCase c ; g = Neutr ; n = Pl} ;
EveryDet = varjeDet ;
AllMassDet = mkDeterminerSgGender2 "all" "allt" IndefP ;
AllNumDet = mkDeterminerPlNum "alla" IndefP ;
AnyDet = mkDeterminerSgGender2 "någon" "något" IndefP ;
AnyNumDet = mkDeterminerPlNum "några" IndefP ;
SomeDet = mkDeterminerSgGender2 "någon" "något" IndefP ;
SomeNumDet = mkDeterminerPlNum "några" IndefP ;
ManyDet = mkDeterminerPl "många" IndefP ;
NoDet = mkDeterminerSgGender2 "ingen" "inget" IndefP ;
NoNumDet = mkDeterminerPlNum "inga" IndefP ;
WhichNumDet = mkDeterminerPlNum "vilka" IndefP ;
WhichDet = vilkenDet ;
MostDet = mkDeterminerSgGender2 ["den mesta"] ["det mesta"] (DefP Def) ;
MostsDet = flestaDet ;
MuchDet = mkDeterminerSg (detSgInvar "mycket") IndefP ;
ThisDet = mkDeterminerSgGender2 ["den här"] ["det här"] (DefP Def) ;
ThatDet = mkDeterminerSgGender2 ["den där"] ["det där"] (DefP Def) ;
TheseNumDet = mkDeterminerPlNum ["de här"] (DefP Def) ;
ThoseNumDet = mkDeterminerPlNum ["de där"] (DefP Def) ;
HowIAdv = ss "hur" ;
WhenIAdv = ss "när" ;
WhereIAdv = ss "var" ;
WhyIAdv = ss "varför" ;
AndConj = ss "och" ** {n = Pl} ;
OrConj = ss "eller" ** {n = Sg} ;
BothAnd = sd2 "både" "och" ** {n = Pl} ;
EitherOr = sd2 "antingen" "eller" ** {n = Sg} ;
NeitherNor = sd2 "varken" "eller" ** {n = Sg} ;
IfSubj = ss "om" ;
WhenSubj = ss "när" ;
PhrYes = ss ["Ja ."] ;
PhrNo = ss ["Nej ."] ;
VeryAdv = ss "mycket" ;
TooAdv = ss "för" ;
OtherwiseAdv = ss "annars" ;
ThereforeAdv = ss "därför" ;
EverybodyNP = let alla = table {Nom => "alla" ; Gen => "allas"} in
{s = \\c => alla ! npCase c ; g = Utr ; n = Pl} ;
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" "kunde" "kunnat" ** {isAux = True} ; ---
---- CanKnowVV = mkVerb "kunna" "kan" "kunn" "kunde" "kunnat" ** {isAux = True} ; ---
---- MustVV = mkVerb "få" "måste" "få" "fick" "måst" ** {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" ;
PossessPrep = ss "av" ;
PartPrep = ss "av" ;
AgentPrep = ss "av" ;
}

File diff suppressed because it is too large Load Diff

View File

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

View File

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