mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 19:42:50 -06:00
Rebuilding resource libraries.
Rebuilding resource libraries. Working with resource interfaces.
This commit is contained in:
@@ -5,22 +5,26 @@
|
|||||||
-- 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 found that are common, on a certain level
|
||||||
-- of abstraction. What we will present in the following is an abstract
|
-- of abstraction. What we will present in the following is an abstract
|
||||||
-- syntax that has been successfully defined for English, French, German,
|
-- syntax that has been successfully defined for English, Finnish, French, German,
|
||||||
-- Italian, Russian, and Swedish. It has been applied to define language
|
-- Italian, Russian, and Swedish. It 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.
|
-- health-related phrase book. Each new application helped to identify some
|
||||||
--
|
-- missing structures in the resource and suggested some additions, but the
|
||||||
|
-- number of them was usually small.
|
||||||
|
--
|
||||||
-- To use the resource in applications, you need the following
|
-- 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. There is
|
-- $lincat$ and $lin$ judgements of a particular language. This is done
|
||||||
-- a GF command for making this translation automatically.
|
-- by using the $reuse$ module with the desired concrete syntax of
|
||||||
|
-- $ResAbs$ as argument.
|
||||||
|
|
||||||
|
|
||||||
--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 it the business
|
-- definable in type theory: to define such correspondences is the business
|
||||||
-- of applications grammars.
|
-- of applications grammars.
|
||||||
--
|
--
|
||||||
-- 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
|
||||||
@@ -102,13 +106,14 @@ cat
|
|||||||
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 defining the simplest combinations
|
-- This set of rules is minimal, in the sense of defining the simplest combinations
|
||||||
-- of categories and of not having redundant rules.
|
-- of categories and not having redundant rules.
|
||||||
-- When the resource grammar is used as a library, it will often be useful to
|
-- 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
|
-- access it through an intermediate library that defines more rules as
|
||||||
-- combinations of the ones below.
|
-- 'macros' for combinations of the ones below.
|
||||||
|
|
||||||
--3 Nouns and noun phrases
|
--3 Nouns and noun phrases
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
-- This resource morphology contains definitions needed in the resource
|
-- This resource morphology contains definitions needed in the resource
|
||||||
-- syntax. It moreover contains the most usual inflectional patterns.
|
-- syntax. It moreover contains the most usual inflectional patterns.
|
||||||
--
|
--
|
||||||
-- We use the parameter types and word classes defined in $types.Eng.gf$.
|
-- We use the parameter types and word classes defined in $Types.gf$.
|
||||||
|
|
||||||
resource Morpho = Types ** open Prelude in {
|
resource Morpho = Types ** open Prelude in {
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
-- However, it only includes those parameters that are needed for
|
-- However, it only includes those parameters that are needed for
|
||||||
-- analysing individual words: such parameters are defined in syntax modules.
|
-- analysing individual words: such parameters are defined in syntax modules.
|
||||||
--
|
--
|
||||||
-- we use the language-independent prelude.
|
-- We use the language-independent prelude.
|
||||||
|
|
||||||
resource Types = open Prelude in {
|
resource Types = open Prelude in {
|
||||||
|
|
||||||
|
|||||||
654
grammars/resource/finnish/Morpho.gf
Normal file
654
grammars/resource/finnish/Morpho.gf
Normal file
@@ -0,0 +1,654 @@
|
|||||||
|
--1 A Simple Finnish Resource Morphology
|
||||||
|
--
|
||||||
|
-- Aarne Ranta 2002
|
||||||
|
--
|
||||||
|
-- This resource morphology contains definitions needed in the resource
|
||||||
|
-- syntax. It moreover contains the most usual inflectional patterns.
|
||||||
|
--
|
||||||
|
-- We use the parameter types and word classes defined in $Types.gf$.
|
||||||
|
|
||||||
|
resource Morpho = Types ** open (Predef = Predef), Prelude in {
|
||||||
|
|
||||||
|
--2 Nouns
|
||||||
|
--
|
||||||
|
|
||||||
|
oper
|
||||||
|
|
||||||
|
-- worst-case macro
|
||||||
|
|
||||||
|
mkSubst : Str -> (_,_,_,_,_,_,_,_,_,_ : Str) -> CommonNoun =
|
||||||
|
\a,vesi,vede,vete,vetta,veteen,vetii,vesii,vesien,vesia,vesiin ->
|
||||||
|
{s = table {
|
||||||
|
NCase Sg Nom => vesi ;
|
||||||
|
NCase Sg Gen => vede + "n" ;
|
||||||
|
NCase Sg Part => vetta ;
|
||||||
|
NCase Sg Transl => vede + "ksi" ;
|
||||||
|
NCase Sg Ess => vete + ("n" + a) ;
|
||||||
|
NCase Sg Iness => vede + ("ss" + a) ;
|
||||||
|
NCase Sg Elat => vede + ("st" + a) ;
|
||||||
|
NCase Sg Illat => veteen ;
|
||||||
|
NCase Sg Adess => vede + ("ll" + a) ;
|
||||||
|
NCase Sg Ablat => vede + ("lt" + a) ;
|
||||||
|
NCase Sg Allat => vede + "lle" ;
|
||||||
|
|
||||||
|
NCase Pl Nom => vede + "t" ;
|
||||||
|
NCase Pl Gen => vesien ;
|
||||||
|
NCase Pl Part => vesia ;
|
||||||
|
NCase Pl Transl => vesii + "ksi" ;
|
||||||
|
NCase Pl Ess => vetii + ("n" + a) ;
|
||||||
|
NCase Pl Iness => vesii + ("ss" + a) ;
|
||||||
|
NCase Pl Elat => vesii + ("st" + a) ;
|
||||||
|
NCase Pl Illat => vesiin ;
|
||||||
|
NCase Pl Adess => vesii + ("ll" + a) ;
|
||||||
|
NCase Pl Ablat => vesii + ("lt" + a) ;
|
||||||
|
NCase Pl Allat => vesii + "lle" ;
|
||||||
|
|
||||||
|
NPossNom => vete ;
|
||||||
|
NPossGenPl => Predef.tk 1 vesien ;
|
||||||
|
NPossTransl Sg => vede + "kse" ;
|
||||||
|
NPossTransl Pl => vesii + "kse" ;
|
||||||
|
NPossIllat Sg => Predef.tk 1 veteen ;
|
||||||
|
NPossIllat Pl => Predef.tk 1 vesiin
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
|
||||||
|
-- A user-friendly variant takes existing forms and infers the vowel harmony.
|
||||||
|
|
||||||
|
mkNoun : (_,_,_,_,_,_,_,_,_,_ : Str) -> CommonNoun =
|
||||||
|
\talo,talon,talona,taloa,taloon,taloina,taloissa,talojen,taloja,taloihin ->
|
||||||
|
mkSubst (ifTok Str (Predef.dp 1 talona) "a" "a" "ä")
|
||||||
|
talo (Predef.tk 1 talon) (Predef.tk 2 talona) taloa taloon
|
||||||
|
(Predef.tk 2 taloina) (Predef.tk 3 taloissa) talojen taloja taloihin ;
|
||||||
|
|
||||||
|
-- Here some useful special cases; more will be given in $paradigms.Fin.gf$.
|
||||||
|
--
|
||||||
|
-- Nouns with partitive "a"/"ä" ;
|
||||||
|
-- to account for grade and vowel alternation, three forms are usually enough
|
||||||
|
-- Examples: "talo", "kukko", "huippu", "koira", "kukka", "syylä",...
|
||||||
|
|
||||||
|
sKukko : (_,_,_ : Str) -> CommonNoun = \kukko,kukon,kukkoja ->
|
||||||
|
let {
|
||||||
|
o = Predef.dp 1 kukko ;
|
||||||
|
a = Predef.dp 1 kukkoja ;
|
||||||
|
kukkoj = Predef.tk 1 kukkoja ;
|
||||||
|
i = Predef.dp 1 kukkoj ;
|
||||||
|
ifi = ifTok Str i "i" ;
|
||||||
|
kukkoi = ifi kukkoj (Predef.tk 1 kukkoj) ;
|
||||||
|
e = Predef.dp 1 kukkoi ;
|
||||||
|
kukoi = Predef.tk 2 kukon + Predef.dp 1 kukkoi
|
||||||
|
}
|
||||||
|
in
|
||||||
|
mkSubst a
|
||||||
|
kukko
|
||||||
|
(Predef.tk 1 kukon)
|
||||||
|
kukko
|
||||||
|
(kukko + a)
|
||||||
|
(kukko + o + "n")
|
||||||
|
(kukkoi + ifi "" "i")
|
||||||
|
(kukoi + ifi "" "i")
|
||||||
|
(ifTok Str e "e" (Predef.tk 1 kukkoi + "ien") (kukkoi + ifi "en" "jen"))
|
||||||
|
kukkoja
|
||||||
|
(kukkoi + ifi "in" "ihin") ;
|
||||||
|
|
||||||
|
-- The special case with no alternations: the vowel harmony is inferred from the
|
||||||
|
-- last letter - which must be one of "o", "u", "ö", "y".
|
||||||
|
|
||||||
|
sTalo : Str -> CommonNoun = \talo ->
|
||||||
|
let {a = getHarmony (Predef.dp 1 talo)} in
|
||||||
|
sKukko talo (talo + "n") (talo + ("j" + a)) ;
|
||||||
|
|
||||||
|
-- Loan words ending in consonants are actually similar to words like
|
||||||
|
-- "malli"/"mallin"/"malleja", with the exception that the "i" is not attached
|
||||||
|
-- to the singular nominative.
|
||||||
|
|
||||||
|
sLinux : Str -> CommonNoun = \linuxia ->
|
||||||
|
let {
|
||||||
|
linux = Predef.tk 2 linuxia ;
|
||||||
|
a = getHarmony (Predef.dp 1 linuxia) ;
|
||||||
|
linuxi = linux + "i"
|
||||||
|
} in
|
||||||
|
mkSubst a
|
||||||
|
linux
|
||||||
|
linuxi
|
||||||
|
linuxi
|
||||||
|
(linuxi + a)
|
||||||
|
(linuxi + "in")
|
||||||
|
(linux + "ei")
|
||||||
|
(linux + "ei")
|
||||||
|
(linux + "ien")
|
||||||
|
(linux + "eja")
|
||||||
|
(linux + "eihin") ;
|
||||||
|
|
||||||
|
-- Nouns of at least 3 syllables ending with "a" or "ä", like "peruna", "rytinä".
|
||||||
|
|
||||||
|
sPeruna : Str -> CommonNoun = \peruna ->
|
||||||
|
let {
|
||||||
|
a = Predef.dp 1 peruna ;
|
||||||
|
perun = Predef.tk 1 peruna ;
|
||||||
|
perunoi = perun + (ifTok Str a "a" "o" "ö" + "i")
|
||||||
|
}
|
||||||
|
in
|
||||||
|
mkSubst a
|
||||||
|
peruna
|
||||||
|
peruna
|
||||||
|
peruna
|
||||||
|
(peruna + a)
|
||||||
|
(peruna + a + "n")
|
||||||
|
perunoi
|
||||||
|
perunoi
|
||||||
|
(perunoi + "den")
|
||||||
|
(perunoi + ("t" + a))
|
||||||
|
(perunoi + "hin") ;
|
||||||
|
|
||||||
|
-- Surpraisingly, making the test for the partitive, this not only covers
|
||||||
|
-- "rae", "perhe", "savuke", but also "rengas", "lyhyt" (except $Sg Illat$), etc.
|
||||||
|
|
||||||
|
sRae : (_,_ : Str) -> CommonNoun = \rae,rakeena ->
|
||||||
|
let {
|
||||||
|
a = Predef.dp 1 rakeena ;
|
||||||
|
rakee = Predef.tk 2 rakeena ;
|
||||||
|
rakei = Predef.tk 1 rakee + "i" ;
|
||||||
|
raet = rae + (ifTok Str (Predef.dp 1 rae) "e" "t" [])
|
||||||
|
}
|
||||||
|
in
|
||||||
|
mkSubst a
|
||||||
|
rae
|
||||||
|
rakee
|
||||||
|
rakee
|
||||||
|
(raet + ("t" + a))
|
||||||
|
(rakee + "seen")
|
||||||
|
rakei
|
||||||
|
rakei
|
||||||
|
(rakei + "den")
|
||||||
|
(rakei + ("t" + a))
|
||||||
|
(rakei + "siin") ;
|
||||||
|
|
||||||
|
sSusi : (_,_,_ : Str) -> CommonNoun = \susi,suden,sutena ->
|
||||||
|
let {
|
||||||
|
a = Predef.dp 1 sutena ;
|
||||||
|
sude = Predef.tk 1 suden ;
|
||||||
|
sute = Predef.tk 2 sutena
|
||||||
|
}
|
||||||
|
in
|
||||||
|
mkSubst a
|
||||||
|
susi
|
||||||
|
sude
|
||||||
|
sute
|
||||||
|
(Predef.tk 1 sute + ("t" + a))
|
||||||
|
(sute + "en")
|
||||||
|
susi
|
||||||
|
susi
|
||||||
|
(susi + "en")
|
||||||
|
(susi + a)
|
||||||
|
(susi + "in") ;
|
||||||
|
|
||||||
|
sPuu : Str -> CommonNoun = \puu ->
|
||||||
|
let {
|
||||||
|
u = Predef.dp 1 puu ;
|
||||||
|
a = getHarmony u ;
|
||||||
|
pu = Predef.tk 1 puu ;
|
||||||
|
pui = pu + "i"
|
||||||
|
}
|
||||||
|
in
|
||||||
|
mkSubst a
|
||||||
|
puu
|
||||||
|
puu
|
||||||
|
puu
|
||||||
|
(puu + ("t" + a))
|
||||||
|
(puu + ("h" + u + "n"))
|
||||||
|
pui
|
||||||
|
pui
|
||||||
|
(pui + "den")
|
||||||
|
(pui + ("t" + a))
|
||||||
|
(pui + "hin") ;
|
||||||
|
|
||||||
|
sSuo : Str -> CommonNoun = \suo ->
|
||||||
|
let {
|
||||||
|
o = Predef.dp 1 suo ;
|
||||||
|
a = getHarmony o ;
|
||||||
|
soi = Predef.tk 2 suo + (o + "i")
|
||||||
|
}
|
||||||
|
in
|
||||||
|
mkSubst a
|
||||||
|
suo
|
||||||
|
suo
|
||||||
|
suo
|
||||||
|
(suo + ("t" + a))
|
||||||
|
(suo + ("h" + o + "n"))
|
||||||
|
soi
|
||||||
|
soi
|
||||||
|
(soi + "den")
|
||||||
|
(soi + ("t" + a))
|
||||||
|
(soi + "hin") ;
|
||||||
|
|
||||||
|
-- Here in fact it is handy to use the partitive form as the only stem.
|
||||||
|
|
||||||
|
sNainen : Str -> CommonNoun = \naista ->
|
||||||
|
let {
|
||||||
|
nainen = Predef.tk 3 naista + "nen" ;
|
||||||
|
nais = Predef.tk 2 naista ;
|
||||||
|
naise = nais + "e" ;
|
||||||
|
naisi = nais + "i" ;
|
||||||
|
a = Predef.dp 1 naista
|
||||||
|
}
|
||||||
|
in
|
||||||
|
mkSubst a
|
||||||
|
nainen
|
||||||
|
naise
|
||||||
|
naise
|
||||||
|
(nais + ("t" + a))
|
||||||
|
(nais + "een")
|
||||||
|
naisi
|
||||||
|
naisi
|
||||||
|
(nais + "ten")
|
||||||
|
(nais + ("i" + a))
|
||||||
|
(nais + "iin") ;
|
||||||
|
|
||||||
|
-- The following covers: "tilaus", "kaulin", "paimen", "laidun", "sammal",
|
||||||
|
-- "kyynel" (excep $Sg Iness$ for the last two?).
|
||||||
|
|
||||||
|
sTilaus : (_,_ : Str) -> CommonNoun = \tilaus, tilauksena ->
|
||||||
|
let {
|
||||||
|
tilauks = Predef.tk 3 tilauksena ;
|
||||||
|
tilaukse = tilauks + "e" ;
|
||||||
|
tilauksi = tilauks + "i" ;
|
||||||
|
a = Predef.dp 1 tilauksena
|
||||||
|
}
|
||||||
|
in
|
||||||
|
mkSubst a
|
||||||
|
tilaus
|
||||||
|
tilaukse
|
||||||
|
tilaukse
|
||||||
|
(tilaus + ("t" + a))
|
||||||
|
(tilauks + "een")
|
||||||
|
tilauksi
|
||||||
|
tilauksi
|
||||||
|
(tilaus + "ten")
|
||||||
|
(tilauks + ("i" + a))
|
||||||
|
(tilauks + "iin") ;
|
||||||
|
|
||||||
|
-- The following covers nouns like "nauris" and adjectives like "kallis", "tyyris".
|
||||||
|
|
||||||
|
sNauris : (_ : Str) -> CommonNoun = \naurista ->
|
||||||
|
let {
|
||||||
|
a = Predef.dp 1 naurista ;
|
||||||
|
nauris = Predef.tk 2 naurista ;
|
||||||
|
nauri = Predef.tk 3 naurista ;
|
||||||
|
naurii = nauri + "i"
|
||||||
|
}
|
||||||
|
in
|
||||||
|
mkSubst a
|
||||||
|
nauris
|
||||||
|
naurii
|
||||||
|
naurii
|
||||||
|
(nauris + ("t" + a))
|
||||||
|
(naurii + "seen")
|
||||||
|
naurii
|
||||||
|
naurii
|
||||||
|
(naurii + "den")
|
||||||
|
(naurii + ("t" + a))
|
||||||
|
(naurii + "siin") ;
|
||||||
|
|
||||||
|
-- The following two are used for adjective comparison.
|
||||||
|
|
||||||
|
sSuurempi : Str -> CommonNoun = \suurempaa ->
|
||||||
|
let {
|
||||||
|
a = Predef.dp 1 suurempaa ;
|
||||||
|
suure = Predef.tk 4 suurempaa ;
|
||||||
|
suurempi = suure + "mpi" ;
|
||||||
|
suurempa = suure + ("mp" + a) ;
|
||||||
|
suuremm = suure + "mm"
|
||||||
|
}
|
||||||
|
in
|
||||||
|
mkSubst a
|
||||||
|
suurempi
|
||||||
|
(suuremm + a)
|
||||||
|
suurempa
|
||||||
|
(suurempa + a)
|
||||||
|
(suurempa + (a + "n"))
|
||||||
|
suurempi
|
||||||
|
(suuremm + "i")
|
||||||
|
(suurempi + "en")
|
||||||
|
(suurempi + a)
|
||||||
|
(suurempi + "in") ;
|
||||||
|
|
||||||
|
sSuurin : Str -> CommonNoun = \suurinta ->
|
||||||
|
let {
|
||||||
|
a = Predef.dp 1 suurinta ;
|
||||||
|
suuri = Predef.tk 3 suurinta ;
|
||||||
|
suurin = suuri + "n" ;
|
||||||
|
suurimma = suuri + ("mm" + a) ;
|
||||||
|
suurimpa = suuri + ("mp" + a) ;
|
||||||
|
suurimpi = suuri + "mpi" ;
|
||||||
|
suurimmi = suuri + "mmi"
|
||||||
|
}
|
||||||
|
in
|
||||||
|
mkSubst a
|
||||||
|
suurin
|
||||||
|
suurimma
|
||||||
|
suurimpa
|
||||||
|
(suurin + ("t" + a))
|
||||||
|
(suurimpa + (a + "n"))
|
||||||
|
suurimpi
|
||||||
|
suurimmi
|
||||||
|
(suurimpi + "en")
|
||||||
|
(suurimpi + a)
|
||||||
|
(suurimpi + "in") ;
|
||||||
|
|
||||||
|
-- This auxiliary resolves vowel harmony from a given letter.
|
||||||
|
|
||||||
|
getHarmony : Str -> Str = \u ->
|
||||||
|
ifTok Str u "a" "a" (
|
||||||
|
ifTok Str u "o" "a" (
|
||||||
|
ifTok Str u "u" "a" "ä")) ;
|
||||||
|
|
||||||
|
|
||||||
|
-- We could use an extension of the following for grade alternation, but we don't;
|
||||||
|
-- in general, *whether there is* grade alternation must be given in the lexicon
|
||||||
|
-- anyway (cf. "auto" - "auton", not "audon").
|
||||||
|
|
||||||
|
weakGrade : Str -> Str = \kukko ->
|
||||||
|
let {
|
||||||
|
ku = Predef.tk 3 kukko ;
|
||||||
|
kk = Predef.tk 1 (Predef.dp 3 kukko) ;
|
||||||
|
o = Predef.dp 1 kukko ;
|
||||||
|
ifkk = ifTok Str kk ;
|
||||||
|
k =
|
||||||
|
ifkk "kk" "k" (
|
||||||
|
ifkk "pp" "p" (
|
||||||
|
ifkk "tt" "t" (
|
||||||
|
ifkk "nt" "nn" (
|
||||||
|
ifkk "mp" "mm" (
|
||||||
|
ifkk "rt" "rr" (
|
||||||
|
ifkk "lt" "ll" (
|
||||||
|
kk)))))))
|
||||||
|
}
|
||||||
|
in ku + k + o ;
|
||||||
|
|
||||||
|
|
||||||
|
--3 Proper names
|
||||||
|
--
|
||||||
|
-- Proper names are similar to common nouns in the singular.
|
||||||
|
|
||||||
|
mkProperName : CommonNoun -> ProperName = \jussi ->
|
||||||
|
{s = \\c => jussi.s ! NCase Sg c} ;
|
||||||
|
|
||||||
|
--2 Pronouns
|
||||||
|
--
|
||||||
|
-- Here we define personal and relative pronouns.
|
||||||
|
|
||||||
|
mkPronoun : (_,_,_,_,_ : Str) -> Number -> Person -> Pronoun =
|
||||||
|
\mina, minun, minua, minuna, minuun, n, p ->
|
||||||
|
let {
|
||||||
|
minu = Predef.tk 2 minuna ;
|
||||||
|
a = Predef.dp 1 minuna
|
||||||
|
} in
|
||||||
|
{s = table {
|
||||||
|
PCase Nom => mina ;
|
||||||
|
PCase Gen => minun ;
|
||||||
|
PCase Part => minua ;
|
||||||
|
PCase Transl => minu + "ksi" ;
|
||||||
|
PCase Ess => minuna ;
|
||||||
|
PCase Iness => minu + ("ss" + a) ;
|
||||||
|
PCase Elat => minu + ("st" + a) ;
|
||||||
|
PCase Illat => minuun ;
|
||||||
|
PCase Adess => minu + ("ll" + a) ;
|
||||||
|
PCase Ablat => minu + ("lt" + a) ;
|
||||||
|
PCase Allat => minu + "lle" ;
|
||||||
|
PAcc => Predef.tk 1 minun + "t"
|
||||||
|
} ;
|
||||||
|
n = n ; p = p} ;
|
||||||
|
|
||||||
|
pronMina = mkPronoun "minä" "minun" "minua" "minuna" "minuun" Sg P1 ;
|
||||||
|
pronSina = mkPronoun "sinä" "sinun" "sinua" "sinuna" "sinuun" Sg P2 ;
|
||||||
|
pronHan = mkPronoun "hän" "hänen" "häntä" "hänenä" "häneen" Sg P3 ;
|
||||||
|
pronMe = mkPronoun "me" "meidän" "meitä" "meinä" "meihin" Pl P1 ;
|
||||||
|
pronTe = mkPronoun "te" "teidän" "teitä" "teinä" "teihin" Pl P2 ;
|
||||||
|
pronHe = mkPronoun "he" "heidän" "heitä" "heinä" "heihin" Pl P3 ;
|
||||||
|
pronNe = mkPronoun "ne" "niiden" "niitä" "niinä" "niihin" Pl P3 ;
|
||||||
|
|
||||||
|
-- The non-human pronoun "se" ('it') is even more irregular,
|
||||||
|
-- Its accusative cases do not
|
||||||
|
-- have a special form with "t", but have the normal genitive/nominative variation.
|
||||||
|
-- We use the type $ProperName$ for "se", because of the accusative but also
|
||||||
|
-- because the person and number are as for proper names.
|
||||||
|
|
||||||
|
pronSe : ProperName = {
|
||||||
|
s = table {
|
||||||
|
Nom => "se" ;
|
||||||
|
Gen => "sen" ;
|
||||||
|
Part => "sitä" ;
|
||||||
|
Transl => "siksi" ;
|
||||||
|
Ess => "sinä" ;
|
||||||
|
Iness => "siinä" ;
|
||||||
|
Elat => "siitä" ;
|
||||||
|
Illat => "siihen" ;
|
||||||
|
Adess => "sillä" ;
|
||||||
|
Ablat => "siltä" ;
|
||||||
|
Allat => "sille"
|
||||||
|
} ;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
-- The possessive suffixes will be needed in syntax. It will show up
|
||||||
|
-- as a separate word ("auto &ni"), which needs unlexing. Unlexing also
|
||||||
|
-- has to fix the vowel harmony in cases like "äiti &nsä".
|
||||||
|
|
||||||
|
suff : Str -> Str = \ni -> "&" + ni ;
|
||||||
|
|
||||||
|
possSuffix : Number => Person => Str = \\n,p =>
|
||||||
|
suff (case <n,p> of {
|
||||||
|
<Sg,P1> => "ni" ;
|
||||||
|
<Sg,P2> => "si" ;
|
||||||
|
<Sg,P3> => "nsa" ;
|
||||||
|
<Pl,P1> => "mme" ;
|
||||||
|
<Pl,P2> => "nne" ;
|
||||||
|
<Pl,P3> => "nsa"
|
||||||
|
} ) ;
|
||||||
|
|
||||||
|
-- The relative pronoun, "joka", is inflected in case and number,
|
||||||
|
-- like common nouns, but it does not take possessive suffixes.
|
||||||
|
-- The inflextion shows a surprising similarity with "suo".
|
||||||
|
|
||||||
|
relPron : RelPron =
|
||||||
|
let {jo = sSuo "jo"} in {s =
|
||||||
|
table {
|
||||||
|
Sg => table {
|
||||||
|
Nom => "joka" ;
|
||||||
|
Gen => "jonka" ;
|
||||||
|
c => jo.s ! NCase Sg c
|
||||||
|
} ;
|
||||||
|
Pl => table {
|
||||||
|
Nom => "jotka" ;
|
||||||
|
c => "j" + (jo.s ! NCase Pl c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
|
||||||
|
mikaInt : Number => Case => Str =
|
||||||
|
let {
|
||||||
|
mi = sSuo "mi"
|
||||||
|
} in
|
||||||
|
table {
|
||||||
|
Sg => table {
|
||||||
|
Nom => "mikä" ;
|
||||||
|
Gen => "minkä" ;
|
||||||
|
c => mi.s ! NCase Sg c
|
||||||
|
} ;
|
||||||
|
Pl => table {
|
||||||
|
Nom => "mitkä" ;
|
||||||
|
Gen => "mittenkä" ;
|
||||||
|
c => mi.s ! NCase Sg c
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
|
||||||
|
kukaInt : Number => Case => Str =
|
||||||
|
let {
|
||||||
|
ku = sRae "kuka" "kenenä" ;
|
||||||
|
ket = sRae "kuka" "keinä"} in
|
||||||
|
table {
|
||||||
|
Sg => table {
|
||||||
|
Nom => "kuka" ;
|
||||||
|
Part => "ketä" ;
|
||||||
|
Illat => "keneen" ;
|
||||||
|
c => ku.s ! NCase Sg c
|
||||||
|
} ;
|
||||||
|
Pl => table {
|
||||||
|
Nom => "ketkä" ;
|
||||||
|
Illat => "keihin" ;
|
||||||
|
c => ket.s ! NCase Pl c
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
|
||||||
|
caseTable : Number -> CommonNoun -> Case => Str = \n,cn ->
|
||||||
|
\\c => cn.s ! NCase n c ;
|
||||||
|
|
||||||
|
|
||||||
|
--2 Adjectives
|
||||||
|
--
|
||||||
|
-- For the comparison of adjectives, three noun declensions
|
||||||
|
-- are needed in the worst case.
|
||||||
|
|
||||||
|
mkAdjDegr : (_,_,_ : CommonNoun) -> AdjDegr = \hyva,parempi,paras ->
|
||||||
|
{s = table {
|
||||||
|
Pos => hyva.s ;
|
||||||
|
Comp => parempi.s ;
|
||||||
|
Sup => paras.s
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
|
||||||
|
-- However, it is usually enough to give the positive declension and
|
||||||
|
-- the characteristic forms of comparative and superlative.
|
||||||
|
|
||||||
|
regAdjDegr : CommonNoun -> Str -> Str -> AdjDegr = \kiva, kivempaa, kivinta ->
|
||||||
|
mkAdjDegr kiva (sSuurempi kivempaa) (sSuurin kivinta) ;
|
||||||
|
|
||||||
|
|
||||||
|
--3 Verbs
|
||||||
|
--
|
||||||
|
|
||||||
|
mkVerb : (_,_,_,_,_ : Str) -> Verb = \tulla,tulen,tulee,tulevat,tulkaa ->
|
||||||
|
let {
|
||||||
|
tule = Predef.tk 1 tulen ;
|
||||||
|
a = Predef.dp 1 tulkaa
|
||||||
|
} in
|
||||||
|
{s = table {
|
||||||
|
Inf => tulla ;
|
||||||
|
Ind Sg P1 => tulen ;
|
||||||
|
Ind Sg P2 => tule + "t" ;
|
||||||
|
Ind Sg P3 => tulee ;
|
||||||
|
Ind Pl P1 => tule + "mme" ;
|
||||||
|
Ind Pl P2 => tule + "tte" ;
|
||||||
|
Ind Pl P3 => tulevat ;
|
||||||
|
Imper Sg => tule ;
|
||||||
|
Imper Pl => tulkaa ;
|
||||||
|
ImpNegPl => Predef.tk 2 tulkaa + (ifTok Str a "a" "o" "ö")
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
|
||||||
|
-- For "sanoa", "valua", "kysyä".
|
||||||
|
|
||||||
|
vSanoa : Str -> Verb = \sanoa ->
|
||||||
|
let {
|
||||||
|
a = Predef.dp 1 sanoa ;
|
||||||
|
sano = Predef.tk 1 sanoa ;
|
||||||
|
o = Predef.dp 1 sano
|
||||||
|
} in
|
||||||
|
mkVerb
|
||||||
|
sanoa
|
||||||
|
(sano + "n")
|
||||||
|
(sano + o)
|
||||||
|
(sano + (("v" + a) + "t"))
|
||||||
|
(sano + (("k" + a) + a)) ;
|
||||||
|
|
||||||
|
-- For "ottaa", "käyttää", "löytää", "huoltaa", "hiihtää", "siirtää".
|
||||||
|
|
||||||
|
vOttaa : (_,_ : Str) -> Verb = \ottaa,otan ->
|
||||||
|
let {
|
||||||
|
a = Predef.dp 1 ottaa ;
|
||||||
|
ota = Predef.tk 1 otan ;
|
||||||
|
otta = Predef.tk 1 ottaa
|
||||||
|
} in
|
||||||
|
mkVerb
|
||||||
|
ottaa
|
||||||
|
(ota + "n")
|
||||||
|
ottaa
|
||||||
|
(otta + (("v" + a) + "t"))
|
||||||
|
(otta + (("k" + a) + a)) ;
|
||||||
|
|
||||||
|
-- For "poistaa", "ryystää".
|
||||||
|
|
||||||
|
vPoistaa : Str -> Verb = \poistaa ->
|
||||||
|
vOttaa poistaa (Predef.tk 1 poistaa + "n") ;
|
||||||
|
|
||||||
|
-- For "juosta", "piestä", "nousta", "rangaista", "kävellä", "surra", "panna".
|
||||||
|
|
||||||
|
vJuosta : (_,_ : Str) -> Verb = \juosta,juoksen ->
|
||||||
|
let {
|
||||||
|
a = Predef.dp 1 juosta ;
|
||||||
|
juokse = Predef.tk 1 juoksen ;
|
||||||
|
juos = Predef.tk 2 juosta
|
||||||
|
} in
|
||||||
|
mkVerb
|
||||||
|
juosta
|
||||||
|
juoksen
|
||||||
|
(juokse + "e")
|
||||||
|
(juokse + (("v" + a) + "t"))
|
||||||
|
(juos + (("k" + a) + a)) ;
|
||||||
|
|
||||||
|
-- For "juoda", "syödä".
|
||||||
|
|
||||||
|
vJuoda : Str -> Verb = \juoda ->
|
||||||
|
let {
|
||||||
|
a = Predef.dp 1 juoda ;
|
||||||
|
juo = Predef.tk 2 juoda
|
||||||
|
} in
|
||||||
|
mkVerb
|
||||||
|
juoda
|
||||||
|
(juo + "n")
|
||||||
|
juo
|
||||||
|
(juo + (("v" + a) + "t"))
|
||||||
|
(juo + (("k" + a) + a)) ;
|
||||||
|
|
||||||
|
|
||||||
|
verbOlla : Verb = mkVerb "olla" "olen" "on" "ovat" "olkaa" ;
|
||||||
|
|
||||||
|
-- The negating operator "ei" is actually a verb, which has has present
|
||||||
|
-- indicative and imperative forms, but no infinitive.
|
||||||
|
|
||||||
|
verbEi : Verb =
|
||||||
|
let {ei = mkVerb nonExist "en" "ei" "eivät" "älkää"} in
|
||||||
|
{s = table {
|
||||||
|
Ind Pl P3 => "eivät" ;
|
||||||
|
v => ei.s ! v
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
--2 Some structural words
|
||||||
|
|
||||||
|
kuinConj = "kuin" ;
|
||||||
|
|
||||||
|
conjEtta = "että" ;
|
||||||
|
advSiten = "siten" ;
|
||||||
|
|
||||||
|
mikakukaInt : Gender => Number => Case => Str =
|
||||||
|
table {
|
||||||
|
NonHuman => mikaInt ;
|
||||||
|
Human => kukaInt
|
||||||
|
} ;
|
||||||
|
|
||||||
|
kaikkiPron : Case => Str =
|
||||||
|
let {kaiket = caseTable Pl (sKukko "kaikki" "kaiken" "kaikkia")} in
|
||||||
|
table {
|
||||||
|
Nom => "kaikki" ;
|
||||||
|
c => kaiket ! c
|
||||||
|
} ;
|
||||||
|
|
||||||
|
stopPunct = "." ;
|
||||||
|
commaPunct = "," ;
|
||||||
|
questPunct = "?" ;
|
||||||
|
exclPunct = "!" ;
|
||||||
|
|
||||||
|
koPart = suff "ko" ;
|
||||||
|
|
||||||
|
} ;
|
||||||
215
grammars/resource/finnish/ResFin.gf
Normal file
215
grammars/resource/finnish/ResFin.gf
Normal file
@@ -0,0 +1,215 @@
|
|||||||
|
--1 The Top-Level Finnish Resource Grammar
|
||||||
|
--
|
||||||
|
-- Aarne Ranta 2002 -- 2003
|
||||||
|
--
|
||||||
|
-- This is the Finnish concrete syntax of the multilingual resource
|
||||||
|
-- grammar. Most of the work is done in the file $syntax.Fin.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 $types.Fin.gf$.
|
||||||
|
|
||||||
|
concrete ResFin of ResAbs = open Prelude, Syntax in {
|
||||||
|
|
||||||
|
flags
|
||||||
|
startcat=Phr ;
|
||||||
|
parser=chart ;
|
||||||
|
|
||||||
|
lincat
|
||||||
|
N = CommNoun ;
|
||||||
|
-- = {s : NForm => Str ; g : Gender}
|
||||||
|
CN = CommNounPhrase ;
|
||||||
|
NP = {s : NPForm => Str ; n : Number ; p : NPPerson} ;
|
||||||
|
PN = {s : Case => Str} ;
|
||||||
|
Det = {s : Gender => Case => Str ; n : Number} ;
|
||||||
|
Fun = Function ;
|
||||||
|
-- = CommNounPhrase ** {c : NPForm} ;
|
||||||
|
Fun2 = Function ** {c2 : NPForm} ;
|
||||||
|
|
||||||
|
Adj1 = Adjective ;
|
||||||
|
-- = CommonNoun
|
||||||
|
Adj2 = Adjective ** {c : NPForm} ;
|
||||||
|
AdjDeg = {s : Degree => NForm => Str} ;
|
||||||
|
AP = {s : AdjPos => Number => Case => Str} ;
|
||||||
|
|
||||||
|
V = Verb ;
|
||||||
|
-- = {s : VForm => Str}
|
||||||
|
VP = Verb ** {s2 : VForm => Str} ;
|
||||||
|
TV = TransVerb ;
|
||||||
|
-- = Verb ** {s3, s4 : Str ; c : ComplCase} ;
|
||||||
|
V3 = TransVerb ** {s5, s6 : Str ; c2 : ComplCase} ;
|
||||||
|
VS = Verb ;
|
||||||
|
|
||||||
|
AdV = {s : Str} ;
|
||||||
|
|
||||||
|
S = Sentence ;
|
||||||
|
-- = {s : Str} ;
|
||||||
|
Slash = Sentence ** {s2 : Str ; c : Case} ;
|
||||||
|
|
||||||
|
RP = {s : Number => Case => Str} ;
|
||||||
|
RC = {s : Number => Str} ;
|
||||||
|
|
||||||
|
IP = {s : NPForm => Str ; n : Number} ;
|
||||||
|
Qu = {s : Str} ;
|
||||||
|
Imp = {s : Number => Str} ;
|
||||||
|
Phr = {s : Str} ;
|
||||||
|
|
||||||
|
Conj = {s : Str ; n : Number} ;
|
||||||
|
ConjD = {s1 : Str ; s2 : Str ; n : Number} ;
|
||||||
|
|
||||||
|
ListS = {s1 : Str ; s2 : Str} ;
|
||||||
|
ListAP = {s1,s2 : AdjPos => Number => Case => Str} ;
|
||||||
|
ListNP = {s1,s2 : NPForm => Str ; n : Number ; p : NPPerson} ;
|
||||||
|
|
||||||
|
--.
|
||||||
|
|
||||||
|
lin
|
||||||
|
UseN = noun2CommNounPhrase ;
|
||||||
|
ModAdj = modCommNounPhrase ;
|
||||||
|
ModGenOne = npGenDet singular ;
|
||||||
|
ModGenMany = npGenDet plural ;
|
||||||
|
UsePN = nameNounPhrase ;
|
||||||
|
UseFun = funAsCommNounPhrase ;
|
||||||
|
AppFun = appFunComm ;
|
||||||
|
AppFun2 = appFun2 ;
|
||||||
|
AdjP1 = adj2adjPhrase ;
|
||||||
|
ComplAdj = complAdj ;
|
||||||
|
PositAdjP = positAdjPhrase ;
|
||||||
|
ComparAdjP = comparAdjPhrase ;
|
||||||
|
SuperlNP = superlNounPhrase ;
|
||||||
|
|
||||||
|
DetNP = detNounPhrase ;
|
||||||
|
IndefOneNP = indefNounPhrase singular ;
|
||||||
|
IndefManyNP = indefNounPhrase plural ;
|
||||||
|
DefOneNP = defNounPhrase singular ;
|
||||||
|
DefManyNP = defNounPhrase plural ;
|
||||||
|
|
||||||
|
PredVP = predVerbPhrase ;
|
||||||
|
PosV = predVerb True ;
|
||||||
|
NegV = predVerb False ;
|
||||||
|
PosA = predAdjective True ;
|
||||||
|
NegA = predAdjective False ;
|
||||||
|
PosCN = predCommNoun True ;
|
||||||
|
NegCN = predCommNoun False ;
|
||||||
|
PosTV = complTransVerb True ;
|
||||||
|
NegTV = complTransVerb False ;
|
||||||
|
PosV3 = complDitransVerb True ;
|
||||||
|
NegV3 = complDitransVerb False ;
|
||||||
|
PosNP = predNounPhrase True ;
|
||||||
|
NegNP = predNounPhrase False ;
|
||||||
|
PosVS = complSentVerb True ;
|
||||||
|
NegVS = complSentVerb False ;
|
||||||
|
VTrans = transAsVerb ;
|
||||||
|
|
||||||
|
AdvVP = adVerbPhrase ;
|
||||||
|
LocNP = locativeNounPhrase ;
|
||||||
|
AdvCN = advCommNounPhrase ;
|
||||||
|
AdvAP = advAdjPhrase ;
|
||||||
|
|
||||||
|
PosSlashTV = slashTransVerb True ;
|
||||||
|
NegSlashTV = slashTransVerb False ;
|
||||||
|
|
||||||
|
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 ;
|
||||||
|
|
||||||
|
ImperVP = imperVerbPhrase ;
|
||||||
|
|
||||||
|
IndicPhrase = indicUtt ;
|
||||||
|
QuestPhrase = interrogUtt ;
|
||||||
|
ImperOne = imperUtterance singular ;
|
||||||
|
ImperMany = imperUtterance plural ;
|
||||||
|
|
||||||
|
AdvS = advSentence ;
|
||||||
|
|
||||||
|
lin
|
||||||
|
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 ;
|
||||||
|
|
||||||
|
PhrNP = useNounPhrase ;
|
||||||
|
PhrOneCN = useCommonNounPhrase singular ;
|
||||||
|
PhrManyCN = useCommonNounPhrase plural ;
|
||||||
|
PhrIP ip = ip ;
|
||||||
|
PhrIAdv ia = ia ;
|
||||||
|
|
||||||
|
OnePhr p = p ;
|
||||||
|
ConsPhr = cc2 ;
|
||||||
|
|
||||||
|
lin
|
||||||
|
INP = pronNounPhrase pronMina ;
|
||||||
|
ThouNP = pronNounPhrase pronSina ;
|
||||||
|
HeNP = pronNounPhrase pronHan ;
|
||||||
|
SheNP = pronNounPhrase pronHan ;
|
||||||
|
ItNP = nameNounPhrase pronSe ;
|
||||||
|
WeNP = pronNounPhrase pronMe ;
|
||||||
|
YeNP = pronNounPhrase pronTe ;
|
||||||
|
YouNP = pronNounPhrase pronTe ;
|
||||||
|
TheyNP = pronNounPhrase pronHe ; --- ne
|
||||||
|
|
||||||
|
EveryDet = jokainenDet ;
|
||||||
|
AllDet = kaikkiDet ;
|
||||||
|
WhichDet = mikaDet ;
|
||||||
|
MostDet = useimmatDet ;
|
||||||
|
|
||||||
|
HowIAdv = ss "kuinka" ;
|
||||||
|
WhenIAdv = ss "koska" ;
|
||||||
|
WhereIAdv = ss "missä" ;
|
||||||
|
WhyIAdv = ss "miksi" ;
|
||||||
|
|
||||||
|
AndConj = ss "ja" ** {n = Pl} ;
|
||||||
|
OrConj = ss "tai" ** {n = Sg} ;
|
||||||
|
BothAnd = sd2 "sekä" "että" ** {n = Pl} ;
|
||||||
|
EitherOr = sd2 "joko" "tai" ** {n = Sg} ;
|
||||||
|
NeitherNor = sd2 "ei" "eikä" ** {n = Sg} ;
|
||||||
|
IfSubj = ss "jos" ;
|
||||||
|
WhenSubj = ss "kun" ;
|
||||||
|
|
||||||
|
PhrYes = ss ("Kyllä" ++ stopPunct) ;
|
||||||
|
PhrNo = ss ("Ei" ++ stopPunct) ;
|
||||||
|
|
||||||
|
VeryAdv = ss "hyvin" ;
|
||||||
|
TooAdv = ss "liian" ;
|
||||||
|
OtherwiseAdv = ss "muuten" ;
|
||||||
|
ThereforeAdv = ss "siksi" ;
|
||||||
|
|
||||||
|
} ;
|
||||||
974
grammars/resource/finnish/Syntax.gf
Normal file
974
grammars/resource/finnish/Syntax.gf
Normal file
@@ -0,0 +1,974 @@
|
|||||||
|
--1 A Small Finnish Resource Syntax
|
||||||
|
--
|
||||||
|
-- Aarne Ranta 2003
|
||||||
|
--
|
||||||
|
-- This resource grammar contains definitions needed to construct
|
||||||
|
-- indicative, interrogative, and imperative sentences in Finnish.
|
||||||
|
--
|
||||||
|
-- The following files are presupposed:
|
||||||
|
|
||||||
|
resource Syntax = Morpho ** open Prelude, (CO = Coordination) in {
|
||||||
|
|
||||||
|
--2 Common Nouns
|
||||||
|
--
|
||||||
|
-- Simple common nouns are defined as the type $CommNoun$ in $morpho.Fin.gf$.
|
||||||
|
|
||||||
|
--3 Common noun phrases
|
||||||
|
|
||||||
|
-- In Finnish, common noun phrases behave like simple common nouns, except that
|
||||||
|
-- we need a kind of a *gender* parameter telling if the noun is human or not.
|
||||||
|
-- This parameter regulates determiners such as "joku"/"jokin" ('some') and
|
||||||
|
-- "kuka"/"mikä" ('which').
|
||||||
|
--
|
||||||
|
-- A subtle reason forces us to distinguish the parameters of common noun phrases
|
||||||
|
-- from those of morphological common nouns: the parameter value $NPossNom$ is
|
||||||
|
-- syntactically applicable to each of $Sg Nom$, $Pl Nom$, $Sg Gen$. In morphology,
|
||||||
|
-- these forms are always the same ("autoni"), but with complex common nouns, we
|
||||||
|
-- have three different forms: "iso autoni", "isot autoni", "ison autoni".
|
||||||
|
|
||||||
|
oper
|
||||||
|
CommNoun = {s : NForm => Str ; g : Gender} ;
|
||||||
|
|
||||||
|
CommNounPhrase = {s : Bool => Number => Case => Str ; g : Gender} ;
|
||||||
|
|
||||||
|
noun2CommNounPhrase : CommNoun -> CommNounPhrase = \man ->
|
||||||
|
useCN man ** {g = man.g} ;
|
||||||
|
|
||||||
|
n2n = noun2CommNounPhrase ;
|
||||||
|
|
||||||
|
useCN : CommonNoun -> {s : Bool => Number => Case => Str} = \auto ->
|
||||||
|
{s = table {
|
||||||
|
True => \\n,c => case <n,c> of {
|
||||||
|
<_, Nom> => auto.s ! NPossNom ;
|
||||||
|
<Sg,Gen> => auto.s ! NPossNom ;
|
||||||
|
<Pl,Gen> => auto.s ! NPossGenPl ;
|
||||||
|
<_,Transl> => auto.s ! NPossTransl n ;
|
||||||
|
<_,Illat> => auto.s ! NPossIllat n ;
|
||||||
|
_ => auto.s ! NCase n c
|
||||||
|
} ;
|
||||||
|
False => \\n,c => auto.s ! NCase n c
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
|
||||||
|
cnNoHum : CommonNoun -> CommNoun = \cn -> cn ** {g = NonHuman} ;
|
||||||
|
cnHum : CommonNoun -> CommNoun = \cn -> cn ** {g = Human} ;
|
||||||
|
|
||||||
|
--2 Noun phrases
|
||||||
|
--
|
||||||
|
-- Two forms of *virtual accusative* are needed for nouns in singular,
|
||||||
|
-- the nominative and the genitive one ("ostan talon"/"osta talo").
|
||||||
|
-- For nouns in plural, only a nominative accusative exist. Pronouns
|
||||||
|
-- have a uniform, special accusative form ("minut", etc).
|
||||||
|
|
||||||
|
param
|
||||||
|
NPForm = NPCase Case | NPAccNom | NPAccGen ;
|
||||||
|
|
||||||
|
-- The *person* of a noun phrase is also special, to steer the use of
|
||||||
|
-- possessive suffixes. It expresses a distinction between pronominal and
|
||||||
|
-- non-pronominal noun phrases. The pronominal ones impose possessive suffixes
|
||||||
|
-- in genitival constructions ("minun taloni", "hänen talonsa"), the non-pronominal
|
||||||
|
-- ones don't ("Jussin talo"). As for verbal agreement, non-pronominal noun
|
||||||
|
-- phrases are third-person.
|
||||||
|
|
||||||
|
NPPerson = NP3 | NPP Person ;
|
||||||
|
|
||||||
|
oper
|
||||||
|
np2Person : NPPerson -> Person = \n -> case n of {
|
||||||
|
NP3 => P3 ;
|
||||||
|
NPP p => p
|
||||||
|
} ;
|
||||||
|
|
||||||
|
oper
|
||||||
|
npForm2Case : Number -> NPForm -> Case = \n,f -> case f of {
|
||||||
|
NPCase c => c ;
|
||||||
|
NPAccNom => Nom ;
|
||||||
|
NPAccGen => case n of {
|
||||||
|
Sg => Gen ;
|
||||||
|
Pl => Nom
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
|
||||||
|
npForm2PForm : NPForm -> PForm = \f -> case f of {
|
||||||
|
NPCase c => PCase c ;
|
||||||
|
_ => PAcc
|
||||||
|
} ;
|
||||||
|
|
||||||
|
NounPhrase : Type = {s : NPForm => Str ; n : Number ; p : NPPerson} ;
|
||||||
|
|
||||||
|
nameNounPhrase : ProperName -> NounPhrase = \jussi ->
|
||||||
|
{s = \\f => jussi.s ! npForm2Case Sg f ; n = Sg ; p = NP3} ;
|
||||||
|
|
||||||
|
singularNounPhrase : CommNounPhrase -> NounPhrase = \cn ->
|
||||||
|
{s = \\f => cn.s ! False ! Sg ! (npForm2Case Sg f) ; n = Sg ; p = NP3} ;
|
||||||
|
|
||||||
|
pluralNounPhrase : CommNounPhrase -> NounPhrase = \cn ->
|
||||||
|
{s = \\f => cn.s ! False ! Pl ! (npForm2Case Pl f) ; n = Pl ; p = NP3} ;
|
||||||
|
|
||||||
|
pronNounPhrase : Pronoun -> NounPhrase = \pron ->
|
||||||
|
{s = \\f => pron.s ! npForm2PForm f ; n = pron.n ; p = NPP pron.p} ;
|
||||||
|
|
||||||
|
-- *Partitive noun phrases* use the partitive instead of the nominative
|
||||||
|
-- and accusative forms.
|
||||||
|
|
||||||
|
npForm2CasePart : NPForm -> Case = \f -> case f of {
|
||||||
|
NPCase Nom => Part ;
|
||||||
|
NPCase c => c ;
|
||||||
|
_ => Part
|
||||||
|
} ;
|
||||||
|
|
||||||
|
partNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n, cn ->
|
||||||
|
{s = \\f => cn.s ! False ! n ! (npForm2CasePart f) ; n = n ; p = NP3} ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--2 Determiners
|
||||||
|
--
|
||||||
|
-- Most determiners are inflected like nouns. They have an inherent number
|
||||||
|
-- that is given to the noun that is being determined.
|
||||||
|
|
||||||
|
Determiner : Type = {s : Gender => Case => Str ; n : Number} ;
|
||||||
|
|
||||||
|
detNounPhrase : Determiner -> CommNounPhrase -> NounPhrase = \joku, mies ->
|
||||||
|
{s = \\f => let {c = npForm2Case joku.n f} in
|
||||||
|
joku.s ! mies.g ! c ++ mies.s ! False ! joku.n ! c ;
|
||||||
|
n = joku.n ;
|
||||||
|
p = NP3
|
||||||
|
} ;
|
||||||
|
|
||||||
|
mkDeterminerGen : Number -> (_,_ : Case => Str) -> Determiner = \n,mika,kuka ->
|
||||||
|
{s = table {
|
||||||
|
NonHuman => mika ;
|
||||||
|
Human => kuka
|
||||||
|
} ;
|
||||||
|
n = n
|
||||||
|
} ;
|
||||||
|
|
||||||
|
mkDeterminer : Number -> (Case => Str) -> Determiner = \n,kaikki ->
|
||||||
|
mkDeterminerGen n kaikki kaikki ;
|
||||||
|
|
||||||
|
jokainenDet = mkDeterminer Sg (caseTable Sg (sNainen "jokaista")) ;
|
||||||
|
kaikkiDet = mkDeterminer Pl kaikkiPron ;
|
||||||
|
useimmatDet = mkDeterminer Pl (caseTable Pl (sSuurin "useinta")) ;
|
||||||
|
mikaDet = mkDeterminerGen Sg (mikaInt ! Sg) (kukaInt ! Sg) ;
|
||||||
|
mitkaDet = mkDeterminerGen Pl (mikaInt ! Pl) (kukaInt ! Pl) ;
|
||||||
|
|
||||||
|
indefNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n,mies ->
|
||||||
|
case n of {
|
||||||
|
Sg => singularNounPhrase mies ;
|
||||||
|
Pl => partNounPhrase plural mies
|
||||||
|
} ;
|
||||||
|
|
||||||
|
defNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n,mies ->
|
||||||
|
case n of {
|
||||||
|
Sg => singularNounPhrase mies ;
|
||||||
|
Pl => pluralNounPhrase mies
|
||||||
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
-- Genitives of noun phrases can be used like determiners, to build noun phrases.
|
||||||
|
-- The number argument makes the difference between "Jussin talo" - "Jussin talot".
|
||||||
|
-- The NP person of the 'owner' decides if there is a possessive suffix.
|
||||||
|
|
||||||
|
npGenDet : Number -> NounPhrase -> CommNounPhrase -> NounPhrase = \n,jussi,talo ->
|
||||||
|
{s = \\c => jussi.s ! NPCase Gen ++
|
||||||
|
ifPossSuffix talo jussi.p jussi.n (npForm2Case n c) ;
|
||||||
|
n = n ;
|
||||||
|
p = NP3
|
||||||
|
} ;
|
||||||
|
|
||||||
|
ifPossSuffix : CommNounPhrase -> NPPerson -> Number -> Case -> Str =
|
||||||
|
\talo,np,n,c -> case np of {
|
||||||
|
NP3 => talo.s ! False ! n ! c ;
|
||||||
|
NPP p => talo.s ! True ! n ! c ++ possSuffix ! n ! p
|
||||||
|
} ;
|
||||||
|
|
||||||
|
-- *Bare plural noun phrases*, like "koivut" in "koivut ovat valkoisia",
|
||||||
|
-- are similar to definite plurals.
|
||||||
|
|
||||||
|
plurDet : CommNounPhrase -> NounPhrase = pluralNounPhrase ;
|
||||||
|
|
||||||
|
|
||||||
|
--2 Adjectives
|
||||||
|
--
|
||||||
|
-- Adjectival phrases are used either as attributes or in predicative position.
|
||||||
|
-- In the attributive position, all cases occur; in the predicative position, only
|
||||||
|
-- the nominative, partitive, translative, and essive - but we ignore this
|
||||||
|
-- restriction for simplicity. The important thing with the parameter is to
|
||||||
|
-- regulate the word order of complex adjectival phrases: cf. predicative
|
||||||
|
-- "(kuusi on) jaollinen kolmella" vs. attributive "kolmella jaollinen (luku)".
|
||||||
|
-- In comparatives, the whole construction is affected: "suurempi kuin kolme"
|
||||||
|
-- vs. "kolmea suurempi". (Actually, in the predicative position, the two
|
||||||
|
-- are in free variation, the distinguished one being the normal choice:
|
||||||
|
-- "kuusi on kolmella jaollinen" is possible, but not quite neutral.)
|
||||||
|
|
||||||
|
param
|
||||||
|
AdjPos = APred | AAttr ;
|
||||||
|
|
||||||
|
oper
|
||||||
|
AdjPhrase : Type = {s : AdjPos => Number => Case => Str} ;
|
||||||
|
|
||||||
|
adj2adjPhrase : Adjective -> AdjPhrase = \uusi ->
|
||||||
|
{s = \\_,n,c => uusi.s ! NCase n c} ;
|
||||||
|
|
||||||
|
|
||||||
|
--3 Comparison adjectives
|
||||||
|
--
|
||||||
|
-- Each of the comparison forms has a characteristic use:
|
||||||
|
--
|
||||||
|
-- Positive forms are used alone, as adjectival phrases ("iso").
|
||||||
|
|
||||||
|
positAdjPhrase : AdjDegr -> AdjPhrase = \iso ->
|
||||||
|
adj2adjPhrase {s = iso.s ! Pos} ;
|
||||||
|
|
||||||
|
-- Comparative forms are used with an object of comparison, as
|
||||||
|
-- adjectival phrases ("isompi kuin te"/"teitä isompi").
|
||||||
|
|
||||||
|
comparAdjPhrase : AdjDegr -> NounPhrase -> AdjPhrase = \iso, te ->
|
||||||
|
{s = let {teitaisompi : Number => Case => Str =
|
||||||
|
\\n,c => te.s ! NPCase Part ++ iso.s ! Comp ! NCase n c} in
|
||||||
|
table {
|
||||||
|
APred => variants {
|
||||||
|
\\n,c => iso.s ! Comp ! NCase n c ++ kuinConj ++ te.s ! NPCase Nom ;
|
||||||
|
teitaisompi
|
||||||
|
} ;
|
||||||
|
AAttr => teitaisompi
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
|
||||||
|
-- Superlative forms are used with a modified noun, picking out the
|
||||||
|
-- maximal representative of a domain ("isoin talo").
|
||||||
|
|
||||||
|
superlNounPhrase : AdjDegr -> CommNounPhrase -> NounPhrase = \iso,talo ->
|
||||||
|
{s = \\np => let {c = npForm2Case Sg np} in
|
||||||
|
iso.s ! Sup ! NCase Sg c ++ talo.s ! False ! Sg ! c ;
|
||||||
|
n = Sg ;
|
||||||
|
p = NP3
|
||||||
|
} ;
|
||||||
|
|
||||||
|
--3 Two-place adjectives
|
||||||
|
--
|
||||||
|
-- A two-place adjective is an adjective with a case used after (or before)
|
||||||
|
-- the complement. The case can be the genitival accusative, which is different
|
||||||
|
-- in the singular and the plural ("rajan ylittävä"/"rajat ylittävä").
|
||||||
|
-- The order of the adjective and its argument depends on the case: the local
|
||||||
|
-- cases favour Adj + Noun in the predicative position ("hyvä painissa",
|
||||||
|
-- "tyytyväinen vaalitulokseen", "jaollinen kolmella"), which is not a possible
|
||||||
|
-- order for the accusative case.
|
||||||
|
|
||||||
|
AdjCompl = Adjective ** {c : NPForm} ;
|
||||||
|
|
||||||
|
complAdj : AdjCompl -> NounPhrase -> AdjPhrase = \hyva,paini ->
|
||||||
|
let {
|
||||||
|
hyvat : Number => Case => Str = \\n,c => hyva.s ! NCase n c ;
|
||||||
|
painissa : Str = paini.s ! hyva.c
|
||||||
|
}
|
||||||
|
in
|
||||||
|
{s = table {
|
||||||
|
AAttr => \\n,c => painissa ++ hyvat ! n ! c ;
|
||||||
|
APred => \\n,c => if_then_else Str
|
||||||
|
(isLocalNPForm hyva.c)
|
||||||
|
(variants {
|
||||||
|
hyvat ! n ! c ++ painissa ;
|
||||||
|
painissa ++ hyvat ! n ! c
|
||||||
|
}
|
||||||
|
)
|
||||||
|
(painissa ++ hyvat ! n ! c)
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
|
||||||
|
isLocalNPForm : NPForm -> Bool = \c -> case c of {
|
||||||
|
NPCase Iness => True ;
|
||||||
|
NPCase Elat => True ;
|
||||||
|
NPCase Illat => True ;
|
||||||
|
NPCase Adess => True ;
|
||||||
|
NPCase Ablat => True ;
|
||||||
|
NPCase Allat => True ;
|
||||||
|
_ => False
|
||||||
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
--3 Modification of common nouns
|
||||||
|
--
|
||||||
|
-- The two main functions of adjective are in predication ("Jussi on iso")
|
||||||
|
-- and in modification ("iso mies"). Predication will be defined
|
||||||
|
-- later, in the chapter on verbs.
|
||||||
|
--
|
||||||
|
-- Modification uses the attributive form of an adjectival phrase.
|
||||||
|
-- The adjective always comes before the noun. The possessive suffix is
|
||||||
|
-- given to the noun.
|
||||||
|
|
||||||
|
modCommNounPhrase : AdjPhrase -> CommNounPhrase -> CommNounPhrase = \iso,mies ->
|
||||||
|
{s = \\p,n,c => iso.s ! AAttr ! n ! c ++ mies.s ! p ! n ! c ;
|
||||||
|
g = mies.g
|
||||||
|
} ;
|
||||||
|
|
||||||
|
--2 Function expressions
|
||||||
|
|
||||||
|
-- A function expression is a common noun together with the
|
||||||
|
-- case taken by its argument ("x'n vaimo").
|
||||||
|
-- The type is analogous to two-place adjectives and transitive verbs;
|
||||||
|
-- but here the genitive is by far the commonest case. The possessive suffix
|
||||||
|
-- is then needed with pronominal arguments.
|
||||||
|
|
||||||
|
Function = CommNounPhrase ** {c : NPForm} ;
|
||||||
|
|
||||||
|
-- The application of a function gives, in the first place, a common noun:
|
||||||
|
-- "Jussi vaimo/vaimot". From this, other rules of the resource grammar
|
||||||
|
-- give noun phrases, such as "Jussi vaimo", "Jussin vaimot",
|
||||||
|
-- "Jussin ja Marin äidit", and "Jussin ja Marin äiti" (the
|
||||||
|
-- latter two corresponding to distributive and collective functions,
|
||||||
|
-- respectively). Semantics will eventually tell when each
|
||||||
|
-- of the readings is meaningful.
|
||||||
|
|
||||||
|
appFunComm : Function -> NounPhrase -> CommNounPhrase = \vaimo, jussi ->
|
||||||
|
{s = \\p,n,c => case vaimo.c of {
|
||||||
|
NPCase Gen => jussi.s ! NPCase Gen ++
|
||||||
|
ifPossSuffix vaimo jussi.p jussi.n c ;
|
||||||
|
h => vaimo.s ! False ! n ! c ++ jussi.s ! h
|
||||||
|
} ;
|
||||||
|
g = vaimo.g
|
||||||
|
} ;
|
||||||
|
|
||||||
|
-- Notice the switched word order in other cases than the genitive, e.g.
|
||||||
|
-- "veli Jussille".
|
||||||
|
--
|
||||||
|
-- It is possible to use a function word as a common noun; the semantics is
|
||||||
|
-- often existential or indexical.
|
||||||
|
|
||||||
|
funAsCommNounPhrase : Function -> CommNounPhrase = \x -> x ;
|
||||||
|
|
||||||
|
-- The following is an aggregate corresponding to function application
|
||||||
|
-- producing "John's mother" and "the mother of John". It does not appear in the
|
||||||
|
-- resource grammar API as a primitive.
|
||||||
|
|
||||||
|
appFun : Bool -> Function -> NounPhrase -> NounPhrase = \coll, vaimo,jussi ->
|
||||||
|
let {n = jussi.n ; nf = if_then_else Number coll Sg n} in
|
||||||
|
npGenDet nf jussi vaimo ;
|
||||||
|
|
||||||
|
-- The commonest case is functions with the genitive case.
|
||||||
|
|
||||||
|
funGen : CommNounPhrase -> Function = \vaimo ->
|
||||||
|
vaimo ** {c = NPCase Gen} ;
|
||||||
|
|
||||||
|
-- Two-place functions add one argument place.
|
||||||
|
|
||||||
|
Function2 = Function ** {c2 : NPForm} ;
|
||||||
|
|
||||||
|
-- There application starts by filling the first place.
|
||||||
|
|
||||||
|
appFun2 : Function2 -> NounPhrase -> Function = \juna, turku ->
|
||||||
|
{s = \\p,n,c => juna.s ! False ! n ! c ++ turku.s ! juna.c ;
|
||||||
|
g = juna.g ;
|
||||||
|
c = juna.c2
|
||||||
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
--2 Verbs
|
||||||
|
--
|
||||||
|
--3 Verb phrases
|
||||||
|
--
|
||||||
|
-- Verb phrases are discontinuous: the two parts of a verb phrase are
|
||||||
|
-- (s) an inflected verb, (s2) a complement.
|
||||||
|
-- For instance: "on" - "kaunis" ; "ei" - "ole kaunis" ; "sisältää" - "rikkiä".
|
||||||
|
|
||||||
|
VerbPhrase = Verb ** {s2 : VForm => Str} ;
|
||||||
|
|
||||||
|
-- From the inflection table, we select the finite form as function
|
||||||
|
-- of person and number:
|
||||||
|
|
||||||
|
indicVerb : Verb -> Person -> Number -> Str = \v,p,n ->
|
||||||
|
v.s ! Ind n p ;
|
||||||
|
|
||||||
|
-- A simple verb can be made into a verb phrase with an empty complement, e.g.
|
||||||
|
-- "ui" - [].
|
||||||
|
-- There are two versions, depending on if we want to negate the verb.
|
||||||
|
-- In the negated form, the negative verb "ei" becomes the verb, and the
|
||||||
|
-- complement is a special infinite form of the verb (usually similar to the
|
||||||
|
-- 2nd person singular imperative): "ei" - "ui".
|
||||||
|
--
|
||||||
|
-- N.B. negation is *not* a function applicable to a verb phrase, since
|
||||||
|
-- double negations with "ei" are not grammatical.
|
||||||
|
|
||||||
|
predVerb : Bool -> Verb -> VerbPhrase = \b,walk ->
|
||||||
|
let {
|
||||||
|
noCompl : {s2 : VForm => Str} = {s2 = \\_ => []} ;
|
||||||
|
infCompl : {s2 : VForm => Str} = {s2 = table {
|
||||||
|
Imper Pl => walk.s ! ImpNegPl ;
|
||||||
|
_ => walk.s ! vFormNeg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
in if_then_else VerbPhrase b (walk ** noCompl) (verbEi ** infCompl) ;
|
||||||
|
|
||||||
|
-- (N.B. local definitions workaround for poor type inference in GF 1.2).
|
||||||
|
|
||||||
|
-- Sometimes we want to extract the verb part of a verb phrase. Not strictly
|
||||||
|
-- necessary since this is a consequence of record subtyping.
|
||||||
|
|
||||||
|
verbOfPhrase : VerbPhrase -> Verb = \v -> {s = v.s} ;
|
||||||
|
|
||||||
|
-- Verb phrases can also be formed from adjectives ("on vanha"),
|
||||||
|
-- common nouns ("on mies"), and noun phrases ("on Jussi").
|
||||||
|
-- The third rule is overgenerating: "on jokainen mies" has to be ruled out
|
||||||
|
-- on semantic grounds.
|
||||||
|
--
|
||||||
|
-- For adjectives and common nouns, notice the case difference in the complement
|
||||||
|
-- depending on number: "on kaunis" - "ovat kauniita". We ignore the forms
|
||||||
|
-- "on kaunista", used with mass terms, and "ovat kauniit", used in
|
||||||
|
-- constructions of the "plurale tantum" kind. The adjective rule can be defined
|
||||||
|
-- in terms of the common noun rule.
|
||||||
|
|
||||||
|
predAdjective : Bool -> AdjPhrase -> VerbPhrase = \b,iso ->
|
||||||
|
let {isot : CommNounPhrase = {s = \\_ => iso.s ! APred ; g = NonHuman}}
|
||||||
|
in predCommNoun b isot ;
|
||||||
|
|
||||||
|
predCommNoun : Bool -> CommNounPhrase -> VerbPhrase = \b,mies ->
|
||||||
|
let {
|
||||||
|
miehia : VForm => Str = \\v => case vform2number v of {
|
||||||
|
Sg => mies.s ! False ! Sg ! Nom ;
|
||||||
|
Pl => mies.s ! False ! Pl ! Part
|
||||||
|
} ;
|
||||||
|
olemiehia : VForm => Str =
|
||||||
|
\\v => verbOlla.s ! vFormNeg ++ miehia ! v
|
||||||
|
}
|
||||||
|
in if_then_else VerbPhrase b
|
||||||
|
(verbOlla ** {s2 = miehia})
|
||||||
|
(verbEi ** {s2 = olemiehia}) ;
|
||||||
|
|
||||||
|
predNounPhrase : Bool -> NounPhrase -> VerbPhrase = \b,jussi ->
|
||||||
|
let {jussia : Bool => Number => Case => Str = \\_,_,_ => jussi.s ! NPCase Nom}
|
||||||
|
in predCommNoun b {s = jussia ; g = Human} ; --- gender does not matter
|
||||||
|
|
||||||
|
|
||||||
|
--3 Transitive verbs
|
||||||
|
--
|
||||||
|
-- Transitive verbs are verbs with a case and, possibly, a preposition
|
||||||
|
-- or a postposition for the complement,
|
||||||
|
-- in analogy with two-place adjectives and functions.
|
||||||
|
-- One might prefer to use the term "2-place verb", since
|
||||||
|
-- "transitive" traditionally means that the inherent preposition is empty.
|
||||||
|
-- Such a verb is one with a *direct object*.
|
||||||
|
|
||||||
|
param
|
||||||
|
ComplCase = CCase Case | CAcc ;
|
||||||
|
|
||||||
|
oper
|
||||||
|
TransVerb : Type = Verb ** {s3, s4 : Str ; c : ComplCase} ;
|
||||||
|
|
||||||
|
-- The rule for using transitive verbs is the complementization rule.
|
||||||
|
--
|
||||||
|
-- N.B. One or both of the pre- and postposition are empty.
|
||||||
|
|
||||||
|
complTransVerb : Bool -> TransVerb -> NounPhrase -> VerbPhrase = \b,ostaa,talo ->
|
||||||
|
let {
|
||||||
|
ostan = predVerb b ostaa ;
|
||||||
|
talon : VForm => Str = \\v =>
|
||||||
|
ostaa.s3 ++ talo.s ! complementCase b ostaa.c v ++ ostaa.s4
|
||||||
|
}
|
||||||
|
in {
|
||||||
|
s = ostan.s ;
|
||||||
|
s2 = \\v => ostan.s2 ! v ++ talon ! v
|
||||||
|
} ;
|
||||||
|
|
||||||
|
-- N.B. If the case is accusative, it becomes partitive in negated verb phrases.
|
||||||
|
-- The choice between the nominative and genitive accusatives depends on the verb
|
||||||
|
-- form.
|
||||||
|
|
||||||
|
complementCase : Bool -> ComplCase -> VForm -> NPForm = \b,c,v -> case c of {
|
||||||
|
CCase k => NPCase k ;
|
||||||
|
CAcc => case b of {
|
||||||
|
True => case v of {
|
||||||
|
Inf => NPAccNom ;
|
||||||
|
Ind _ _ => NPAccGen ;
|
||||||
|
Imper _ => NPAccNom ;
|
||||||
|
ImpNegPl => NPCase Part
|
||||||
|
} ;
|
||||||
|
_ => NPCase Part
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
|
||||||
|
-- Verbs that take their object with a case other than the accusative,
|
||||||
|
-- without pre- or postposition:
|
||||||
|
|
||||||
|
mkTransVerbCase : Verb -> Case -> TransVerb = \nauraa,c ->
|
||||||
|
nauraa ** {s3 = [] ; s4 = [] ; c = CCase c} ;
|
||||||
|
|
||||||
|
-- Verbs that take direct object with the accusative:
|
||||||
|
|
||||||
|
mkTransVerbDir : Verb -> TransVerb = \ostaa ->
|
||||||
|
ostaa ** {s3 = [] ; s4 = [] ; c = CAcc} ;
|
||||||
|
|
||||||
|
-- Transitive verbs can be used elliptically as verbs. The semantics
|
||||||
|
-- is left to applications. The definition is trivial, due to record
|
||||||
|
-- subtyping.
|
||||||
|
|
||||||
|
transAsVerb : TransVerb -> Verb = \juoda ->
|
||||||
|
juoda ;
|
||||||
|
|
||||||
|
-- *Ditransitive verbs* are verbs with three argument places.
|
||||||
|
-- We treat so far only the rule in which the ditransitive
|
||||||
|
-- verb takes both complements to form a verb phrase.
|
||||||
|
|
||||||
|
DitransVerb = TransVerb ** {s5, s6 : Str ; c2 : ComplCase} ;
|
||||||
|
|
||||||
|
complDitransVerb :
|
||||||
|
Bool -> DitransVerb -> NounPhrase -> NounPhrase -> VerbPhrase =
|
||||||
|
\b,ostaa,talo,me ->
|
||||||
|
let {
|
||||||
|
ostan = predVerb b ostaa ;
|
||||||
|
talon : VForm => Str = \\v =>
|
||||||
|
ostaa.s3 ++ talo.s ! complementCase b ostaa.c v ++ ostaa.s4 ;
|
||||||
|
meille : VForm => Str = \\v =>
|
||||||
|
ostaa.s5 ++ me.s ! complementCase b ostaa.c2 v ++ ostaa.s6
|
||||||
|
}
|
||||||
|
in {
|
||||||
|
s = ostan.s ;
|
||||||
|
s2 = \\v => ostan.s2 ! v ++ talon ! v ++ meille ! v
|
||||||
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
--2 Adverbials
|
||||||
|
--
|
||||||
|
-- Adverbials are not inflected (we ignore comparison, and treat
|
||||||
|
-- compared adverbials as separate expressions; this could be done another way).
|
||||||
|
|
||||||
|
Adverb : Type = SS ;
|
||||||
|
|
||||||
|
-- This rule adds the adverbial as a prefix or a suffix to the complement,
|
||||||
|
-- in free variation.
|
||||||
|
|
||||||
|
adVerbPhrase : VerbPhrase -> Adverb -> VerbPhrase = \laulaa, hyvin ->
|
||||||
|
{s = laulaa.s ;
|
||||||
|
s2 = \\v => bothWays (laulaa.s2 ! v) hyvin.s
|
||||||
|
} ;
|
||||||
|
|
||||||
|
advAdjPhrase : Adverb -> AdjPhrase -> AdjPhrase = \liian, iso ->
|
||||||
|
{s = \\p,n,c => liian.s ++ iso.s ! p ! n ! c
|
||||||
|
} ;
|
||||||
|
|
||||||
|
-- Adverbials are typically generated by case, prepositions, or postpositions.
|
||||||
|
-- The rule for creating locative noun phrases by the inessive case
|
||||||
|
-- is a shaky, since the adessive is often required.
|
||||||
|
|
||||||
|
prepPhrase : Str -> Case -> NounPhrase -> Adverb = \ennen,c,talvi ->
|
||||||
|
ss (ennen ++ talvi.s ! NPCase c) ;
|
||||||
|
|
||||||
|
postpPhrase : Str -> Case -> NounPhrase -> Adverb = \aikana,c,talvi ->
|
||||||
|
ss (talvi.s ! NPCase c ++ aikana) ;
|
||||||
|
|
||||||
|
caseAdv : Case -> NounPhrase -> Adverb = prepPhrase [] ;
|
||||||
|
|
||||||
|
locativeNounPhrase : NounPhrase -> Adverb = \np -> --- caseAdv Iness ;
|
||||||
|
ss (np.s ! NPCase Iness) ;
|
||||||
|
|
||||||
|
-- This is a source of the "mann with a telescope" ambiguity, and may produce
|
||||||
|
-- strange things, like "autot aina" (while "autot tänään" is OK).
|
||||||
|
-- Semantics will have to make finer distinctions among adverbials.
|
||||||
|
|
||||||
|
advCommNounPhrase : CommNounPhrase -> Adverb -> CommNounPhrase = \auto,nyt ->
|
||||||
|
{s = \\b,n,c => auto.s ! b ! n ! c ++ nyt.s ;
|
||||||
|
g = auto.g
|
||||||
|
} ;
|
||||||
|
|
||||||
|
--2 Sentences
|
||||||
|
--
|
||||||
|
-- Sentences are not inflected in this fragment of Finnish without tense.
|
||||||
|
|
||||||
|
Sentence : Type = SS ;
|
||||||
|
|
||||||
|
-- This is the traditional $S -> NP VP$ rule. It takes care of
|
||||||
|
-- agreement between subject and verb. Recall that the VP may already
|
||||||
|
-- contain negation.
|
||||||
|
|
||||||
|
predVerbPhrase : NounPhrase -> VerbPhrase -> Sentence = \jussi,uida ->
|
||||||
|
let {p = np2Person jussi.p} in
|
||||||
|
ss (jussi.s ! NPCase Nom ++ uida.s ! Ind jussi.n p ++ uida.s2 ! Ind jussi.n p) ;
|
||||||
|
|
||||||
|
-- This is a macro for simultaneous predication and complementization.
|
||||||
|
|
||||||
|
predTransVerb : Bool -> NounPhrase -> TransVerb -> NounPhrase -> Sentence =
|
||||||
|
\b,you,see,john ->
|
||||||
|
predVerbPhrase you (complTransVerb b see john) ;
|
||||||
|
|
||||||
|
--3 Sentence-complement verbs
|
||||||
|
--
|
||||||
|
-- Sentence-complement verbs take sentences as complements.
|
||||||
|
|
||||||
|
SentenceVerb : Type = Verb ;
|
||||||
|
|
||||||
|
-- To generate "sanoo että Jussi ui" / "ei sano että Jussi ui"
|
||||||
|
|
||||||
|
complSentVerb : Bool -> SentenceVerb -> Sentence -> VerbPhrase =
|
||||||
|
\b,sanoa,jussiui ->
|
||||||
|
let {
|
||||||
|
sanon = predVerb b sanoa
|
||||||
|
}
|
||||||
|
in {
|
||||||
|
s = sanon.s ;
|
||||||
|
s2 = \\v => sanon.s2 ! v ++ conjEtta ++ jussiui.s
|
||||||
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
--2 Sentences missing noun phrases
|
||||||
|
--
|
||||||
|
-- This is one instance of Gazdar's *slash categories*, corresponding to his
|
||||||
|
-- $S/NP$.
|
||||||
|
-- We cannot have - nor would we want to have - a productive slash-category former.
|
||||||
|
-- Perhaps a handful more will be needed.
|
||||||
|
--
|
||||||
|
-- Notice that the slash category has a similar relation to sentences as
|
||||||
|
-- transitive verbs have to verbs: it's like a *sentence taking a complement*.
|
||||||
|
--
|
||||||
|
-- Interestingly, the distinction between prepositions and postpositions
|
||||||
|
-- neutralizes: even prepositions are attached after relative and interrogative
|
||||||
|
-- pronouns: "jota ennen" cf. "ennen talvea". Otherwise, the category and
|
||||||
|
-- the rules are very similar to transitive verbs. Notice that the case gets
|
||||||
|
-- fixed by the Boolean parameter and the subject.
|
||||||
|
|
||||||
|
SentenceSlashNounPhrase = Sentence ** {s2 : Str ; c : Case} ;
|
||||||
|
|
||||||
|
slashTransVerb : Bool -> NounPhrase -> TransVerb -> SentenceSlashNounPhrase =
|
||||||
|
\b,jussi,ostaa ->
|
||||||
|
predVerbPhrase jussi (predVerb b ostaa) ** {
|
||||||
|
s2 = ostaa.s3 ++ ostaa.s4 ;
|
||||||
|
c = npForm2Case jussi.n
|
||||||
|
(complementCase b ostaa.c (Ind jussi.n (np2Person jussi.p)))
|
||||||
|
} ;
|
||||||
|
|
||||||
|
--2 Relative pronouns and relative clauses
|
||||||
|
--
|
||||||
|
-- As described in $types.Fin.gf$, relative pronouns are inflected like
|
||||||
|
-- common nouns, in number and case.
|
||||||
|
--
|
||||||
|
-- We get the simple relative pronoun "joka" from $morpho.Fin.gf$.
|
||||||
|
|
||||||
|
identRelPron : RelPron = relPron ;
|
||||||
|
|
||||||
|
funRelPron : Function -> RelPron -> RelPron = \vaimo, joka ->
|
||||||
|
{s = \\n,c => joka.s ! n ! npForm2Case n vaimo.c ++ vaimo.s ! False ! n ! c} ;
|
||||||
|
|
||||||
|
-- Relative clauses can be formed from both verb phrases ("joka ui") and
|
||||||
|
-- slash expressions ("jonka sinä näet", "jonka kautta sinä käyt").
|
||||||
|
|
||||||
|
RelClause : Type = {s : Number => Str} ;
|
||||||
|
|
||||||
|
relVerbPhrase : RelPron -> VerbPhrase -> RelClause = \joka,ui ->
|
||||||
|
{s = \\n => joka.s ! n ! Nom ++ ui.s ! Ind n P3 ++ ui.s2 ! Ind n P3} ;
|
||||||
|
|
||||||
|
relSlash : RelPron -> SentenceSlashNounPhrase -> RelClause = \joka,saat ->
|
||||||
|
{s = \\n => joka.s ! n ! saat.c ++ saat.s2 ++ saat.s} ;
|
||||||
|
|
||||||
|
-- A 'degenerate' relative clause is the one often used in mathematics, e.g.
|
||||||
|
-- "luku x siten että x on parillinen".
|
||||||
|
|
||||||
|
relSuch : Sentence -> RelClause = \A ->
|
||||||
|
{s = \\_ => advSiten ++ conjEtta ++ A.s} ;
|
||||||
|
|
||||||
|
-- N.B. the construction "sellainen että" is not possible with the present
|
||||||
|
-- typing of the relative clause, since it should also be inflected in
|
||||||
|
-- case. Ordinary relative clauses have a fixed case.
|
||||||
|
--
|
||||||
|
-- The main use of relative clauses is to modify common nouns.
|
||||||
|
-- The result is a common noun, out of which noun phrases can be formed
|
||||||
|
-- by determiners. We use no comma before these relative clauses, even though
|
||||||
|
-- conservative standard Finnish does.
|
||||||
|
|
||||||
|
modRelClause : CommNounPhrase -> RelClause -> CommNounPhrase = \mies,jokaui ->
|
||||||
|
{s = \\b,n,c => mies.s ! b ! n ! c ++ jokaui.s ! n ;
|
||||||
|
g = mies.g
|
||||||
|
} ;
|
||||||
|
|
||||||
|
-- N.B: the possessive suffix, if attached here, comes to wrong place! Solution:
|
||||||
|
-- make $CommNounPhrase$ discontinuos.
|
||||||
|
|
||||||
|
|
||||||
|
--2 Interrogative pronouns
|
||||||
|
--
|
||||||
|
-- If relative pronouns are like common nouns (and adjectives),
|
||||||
|
-- interrogative pronouns are like noun phrases, having a fixed number.
|
||||||
|
-- They also need to handle an NP-like accusative case. But person is
|
||||||
|
-- not needed, since it is uniformly $NP3$.
|
||||||
|
|
||||||
|
IntPron : Type = {s : NPForm => Str ; n : Number} ;
|
||||||
|
|
||||||
|
-- In analogy with relative pronouns, we have a rule for applying a function
|
||||||
|
-- to a relative pronoun to create a new one.
|
||||||
|
|
||||||
|
funIntPron : Function -> IntPron -> IntPron = \vaimo,kuka ->
|
||||||
|
{s = \\c => kuka.s ! vaimo.c ++
|
||||||
|
vaimo.s ! False ! kuka.n ! npForm2Case kuka.n c ;
|
||||||
|
n = kuka.n
|
||||||
|
} ;
|
||||||
|
|
||||||
|
-- There is a variety of simple interrogative pronouns:
|
||||||
|
-- "mikä talo" / "kuka mies", "kuka", "mikä". The construction with a noun
|
||||||
|
-- is the reason why nouns in Finnish need a gender.
|
||||||
|
|
||||||
|
nounIntPron : Number -> CommNounPhrase -> IntPron = \n, talo ->
|
||||||
|
{s = \\c => let {nc = npForm2Case n c} in
|
||||||
|
mikakukaInt ! talo.g ! n ! nc ++ talo.s ! False ! n ! nc ;
|
||||||
|
n = n
|
||||||
|
} ;
|
||||||
|
|
||||||
|
intPronWho : Number -> IntPron = \num -> {
|
||||||
|
s = \\c => mikakukaInt ! Human ! num ! (npForm2Case num c) ;
|
||||||
|
n = num
|
||||||
|
} ;
|
||||||
|
|
||||||
|
intPronWhat : Number -> IntPron = \num -> {
|
||||||
|
s = \\c => mikakukaInt ! NonHuman ! num ! (npForm2Case num c) ;
|
||||||
|
n = num
|
||||||
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
--2 Utterances
|
||||||
|
|
||||||
|
-- By utterances we mean complete phrases, such as
|
||||||
|
-- 'can be used as moves in a language game': indicatives, questions, imperative,
|
||||||
|
-- and one-word utterances. The rules are far from complete.
|
||||||
|
--
|
||||||
|
-- N.B. we have not included rules for texts, which we find we cannot say much
|
||||||
|
-- about on this level. In semantically rich GF grammars, texts, dialogues, etc,
|
||||||
|
-- will of course play an important role as categories not reducible to utterances.
|
||||||
|
-- An example is proof texts, whose semantics show a dependence between premises
|
||||||
|
-- and conclusions. Another example is intersentential anaphora.
|
||||||
|
|
||||||
|
Utterance = SS ;
|
||||||
|
|
||||||
|
indicUtt : Sentence -> Utterance = \x -> ss (x.s ++ stopPunct) ;
|
||||||
|
interrogUtt : Question -> Utterance = \x -> ss (x.s ++ questPunct) ;
|
||||||
|
|
||||||
|
|
||||||
|
--2 Questions
|
||||||
|
--
|
||||||
|
-- Questions are either direct or indirect, but the forms in Finnish are
|
||||||
|
-- always identical. So we don't need a $QuestForm$ parameter as in other languages.
|
||||||
|
|
||||||
|
oper
|
||||||
|
Question = SS ;
|
||||||
|
|
||||||
|
--3 Yes-no questions
|
||||||
|
--
|
||||||
|
-- Yes-no questions are formed by inversed predication, with the clitic "ko" / "kö"
|
||||||
|
-- particle attached to the verb part of the verb phrase.
|
||||||
|
|
||||||
|
questVerbPhrase : NounPhrase -> VerbPhrase -> Question = \jussi,ui ->
|
||||||
|
let {np = Ind jussi.n (np2Person jussi.p)} in
|
||||||
|
ss (ui.s ! np ++ koPart ++ jussi.s ! NPCase Nom ++ ui.s2 ! np) ;
|
||||||
|
|
||||||
|
|
||||||
|
--3 Wh-questions
|
||||||
|
--
|
||||||
|
-- Wh-questions are of two kinds: ones that are like $NP - VP$ sentences
|
||||||
|
-- ("kuka ui?") others that are line $S/NP - NP$ sentences ("kenet sinä tapaat?").
|
||||||
|
|
||||||
|
intVerbPhrase : IntPron -> VerbPhrase -> Question = \kuka,ui ->
|
||||||
|
predVerbPhrase (kuka ** {p = NP3}) ui ;
|
||||||
|
|
||||||
|
intSlash : IntPron -> SentenceSlashNounPhrase -> Question = \kuka,tapaat ->
|
||||||
|
ss (kuka.s ! NPCase tapaat.c ++ tapaat.s2 ++ tapaat.s) ;
|
||||||
|
|
||||||
|
|
||||||
|
--3 Interrogative adverbials
|
||||||
|
--
|
||||||
|
-- These adverbials will be defined in the lexicon: they include
|
||||||
|
-- "koska", "missä", "kuinka", "miksi", etc, which are all invariant one-word
|
||||||
|
-- expressions. In addition, they can be formed by adding cases and postpositions
|
||||||
|
-- to interrogative pronouns, in the same way as adverbials are formed
|
||||||
|
-- from noun phrases; notice that even prepositions are used as postpositions
|
||||||
|
-- when attached to interrogative pronouns.
|
||||||
|
|
||||||
|
IntAdverb = SS ;
|
||||||
|
|
||||||
|
prepIntAdverb : Str -> Case -> IntPron -> IntAdverb = \ennen,c,kuka ->
|
||||||
|
ss (kuka.s ! NPCase c ++ ennen) ;
|
||||||
|
|
||||||
|
-- A question adverbial can be applied to anything, and whether this makes
|
||||||
|
-- sense is a semantic question. The syntax is very simple: just prefix the
|
||||||
|
-- adverbial to the predication.
|
||||||
|
|
||||||
|
questAdverbial : IntAdverb -> NounPhrase -> VerbPhrase -> Question =
|
||||||
|
\miksi, jussi, ui ->
|
||||||
|
cc2 miksi (predVerbPhrase jussi ui) ;
|
||||||
|
|
||||||
|
--2 Imperatives
|
||||||
|
--
|
||||||
|
-- We only consider second-person imperatives.
|
||||||
|
|
||||||
|
Imperative = SS1 Number ;
|
||||||
|
|
||||||
|
imperVerbPhrase : VerbPhrase -> Imperative = \ui ->
|
||||||
|
{s = \\n => ui.s ! Imper n ++ ui.s2 ! Imper n} ;
|
||||||
|
|
||||||
|
imperUtterance : Number -> Imperative -> Utterance = \n,I ->
|
||||||
|
ss (I.s ! n ++ exclPunct) ;
|
||||||
|
|
||||||
|
--2 Sentence adverbials
|
||||||
|
--
|
||||||
|
-- This class covers adverbials such as "muuten", "siksi", which are prefixed
|
||||||
|
-- to a sentence to form a phrase.
|
||||||
|
|
||||||
|
advSentence : Adverb -> Sentence -> Utterance = \siksi,sataa ->
|
||||||
|
ss (siksi.s ++ sataa.s ++ ".") ;
|
||||||
|
|
||||||
|
|
||||||
|
--2 Coordination
|
||||||
|
--
|
||||||
|
-- Coordination is to some extent orthogonal to the rest of syntax, and
|
||||||
|
-- has been treated in a generic way in the module $CO$ in the file
|
||||||
|
-- $coordination.gf$. The overall structure is independent of category,
|
||||||
|
-- but there can be differences in parameter dependencies.
|
||||||
|
--
|
||||||
|
--3 Conjunctions
|
||||||
|
--
|
||||||
|
-- Coordinated phrases are built by using conjunctions, which are either
|
||||||
|
-- simple ("ja", "tai") or distributed ("sekä - että", "joko - tai").
|
||||||
|
--
|
||||||
|
-- The conjunction has an inherent number, which is used when conjoining
|
||||||
|
-- noun phrases: "Jussi ja Mari ovat..." vs. "Jussi tai Mari on..."; in the
|
||||||
|
-- case of "tai", the result is however plural if any of the disjuncts is.
|
||||||
|
|
||||||
|
Conjunction = CO.Conjunction ** {n : Number} ;
|
||||||
|
ConjunctionDistr = CO.ConjunctionDistr ** {n : Number} ;
|
||||||
|
|
||||||
|
--3 Coordinating sentences
|
||||||
|
--
|
||||||
|
-- We need a category of lists of sentences. It is a discontinuous
|
||||||
|
-- category, the parts corresponding to 'init' and 'last' segments
|
||||||
|
-- (rather than 'head' and 'tail', because we have to keep track of the slot between
|
||||||
|
-- the last two elements of the list). A list has at least two elements.
|
||||||
|
|
||||||
|
ListSentence : Type = SD2 ;
|
||||||
|
|
||||||
|
twoSentence : (_,_ : Sentence) -> ListSentence = CO.twoSS ;
|
||||||
|
|
||||||
|
consSentence : ListSentence -> Sentence -> ListSentence =
|
||||||
|
CO.consSS CO.comma ;
|
||||||
|
|
||||||
|
-- To coordinate a list of sentences by a simple conjunction, we place
|
||||||
|
-- it between the last two elements; commas are put in the other slots,
|
||||||
|
-- e.g. "du rauchst, er trinkt und ich esse".
|
||||||
|
|
||||||
|
conjunctSentence : Conjunction -> ListSentence -> Sentence = \c,xs ->
|
||||||
|
ss (CO.conjunctX c xs) ;
|
||||||
|
|
||||||
|
-- To coordinate a list of sentences by a distributed conjunction, we place
|
||||||
|
-- the first part (e.g. "either") in front of the first element, the second
|
||||||
|
-- part ("or") between the last two elements, and commas in the other slots.
|
||||||
|
-- For sentences this is really not used.
|
||||||
|
|
||||||
|
conjunctDistrSentence : ConjunctionDistr -> ListSentence -> Sentence =
|
||||||
|
\c,xs ->
|
||||||
|
ss (CO.conjunctDistrX c xs) ;
|
||||||
|
|
||||||
|
|
||||||
|
--3 Coordinating adjective phrases
|
||||||
|
--
|
||||||
|
-- The structure is the same as for sentences. Parameters are passed to components.
|
||||||
|
|
||||||
|
ListAdjPhrase : Type =
|
||||||
|
{s1,s2 : AdjPos => Number => Case => Str} ;
|
||||||
|
|
||||||
|
twoAdjPhrase : (_,_ : AdjPhrase) -> ListAdjPhrase = \x,y ->
|
||||||
|
CO.twoTable3 AdjPos Number Case x y ;
|
||||||
|
|
||||||
|
consAdjPhrase : ListAdjPhrase -> AdjPhrase -> ListAdjPhrase = \xs,x ->
|
||||||
|
CO.consTable3 AdjPos Number Case CO.comma xs x ;
|
||||||
|
|
||||||
|
conjunctAdjPhrase : Conjunction -> ListAdjPhrase -> AdjPhrase = \c,xs ->
|
||||||
|
CO.conjunctTable3 AdjPos Number Case c xs ;
|
||||||
|
|
||||||
|
conjunctDistrAdjPhrase : ConjunctionDistr -> ListAdjPhrase -> AdjPhrase = \c,xs ->
|
||||||
|
CO.conjunctDistrTable3 AdjPos Number Case c xs ;
|
||||||
|
|
||||||
|
|
||||||
|
--3 Coordinating noun phrases
|
||||||
|
--
|
||||||
|
-- The structure is the same as for sentences. The result is either always plural
|
||||||
|
-- or plural if any of the components is, depending on the conjunction.
|
||||||
|
|
||||||
|
ListNounPhrase : Type = {s1,s2 : NPForm => Str ; n : Number ; p : NPPerson} ;
|
||||||
|
|
||||||
|
twoNounPhrase : (_,_ : NounPhrase) -> ListNounPhrase = \x,y ->
|
||||||
|
CO.twoTable NPForm x y ** {n = conjNumber x.n y.n ; p = conjPerson x.p y.p} ;
|
||||||
|
|
||||||
|
consNounPhrase : ListNounPhrase -> NounPhrase -> ListNounPhrase = \xs,x ->
|
||||||
|
CO.consTable NPForm CO.comma xs x **
|
||||||
|
{n = conjNumber xs.n x.n ; p = conjPerson xs.p x.p} ;
|
||||||
|
|
||||||
|
conjunctNounPhrase : Conjunction -> ListNounPhrase -> NounPhrase = \c,xs ->
|
||||||
|
CO.conjunctTable NPForm c xs ** {n = conjNumber c.n xs.n ; p = xs.p} ;
|
||||||
|
|
||||||
|
conjunctDistrNounPhrase : ConjunctionDistr -> ListNounPhrase -> NounPhrase =
|
||||||
|
\c,xs ->
|
||||||
|
CO.conjunctDistrTable NPForm c xs ** {n = conjNumber c.n xs.n ; p = xs.p} ;
|
||||||
|
|
||||||
|
-- We have to define a calculus of numbers of persons. For numbers,
|
||||||
|
-- it is like the conjunction with $Pl$ corresponding to $False$.
|
||||||
|
|
||||||
|
conjNumber : Number -> Number -> Number = \m,n -> case <m,n> of {
|
||||||
|
<Sg,Sg> => Sg ;
|
||||||
|
_ => Pl
|
||||||
|
} ;
|
||||||
|
|
||||||
|
-- For persons, we let the latter argument win ("either you or I am absent"
|
||||||
|
-- but "either I or you are absent"). This is not quite clear.
|
||||||
|
|
||||||
|
conjPerson : NPPerson -> NPPerson -> NPPerson = \_,p ->
|
||||||
|
p ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--2 Subjunction
|
||||||
|
--
|
||||||
|
-- Subjunctions ("kun", "jos", etc)
|
||||||
|
-- are a different way to combine sentences than conjunctions.
|
||||||
|
-- The main clause can be a sentences, an imperatives, or a question,
|
||||||
|
-- but the subjoined clause must be a sentence.
|
||||||
|
--
|
||||||
|
-- There are uniformly two variant word orders, e.g.
|
||||||
|
-- "jos poltat minä suutun"
|
||||||
|
-- and "minä suutun jos poltat".
|
||||||
|
|
||||||
|
Subjunction = SS ;
|
||||||
|
|
||||||
|
subjunctSentence : Subjunction -> Sentence -> Sentence -> Sentence =
|
||||||
|
\if, A, B ->
|
||||||
|
ss (subjunctVariants if A.s B.s) ;
|
||||||
|
|
||||||
|
subjunctImperative : Subjunction -> Sentence -> Imperative -> Imperative =
|
||||||
|
\if, A, B ->
|
||||||
|
{s = \\n => subjunctVariants if A.s (B.s ! n)} ;
|
||||||
|
|
||||||
|
subjunctQuestion : Subjunction -> Sentence -> Question -> Question =
|
||||||
|
\if, A, B ->
|
||||||
|
{s = subjunctVariants if A.s B.s} ;
|
||||||
|
|
||||||
|
subjunctVariants : Subjunction -> Str -> Str -> Str = \if,A,B ->
|
||||||
|
variants {if.s ++ A ++ commaPunct ++ B ; B ++ commaPunct ++ if.s ++ A} ;
|
||||||
|
|
||||||
|
--2 One-word utterances
|
||||||
|
--
|
||||||
|
-- An utterance can consist of one phrase of almost any category,
|
||||||
|
-- the limiting case being one-word utterances. These
|
||||||
|
-- utterances are often (but not always) in what can be called the
|
||||||
|
-- default form of a category, e.g. the nominative.
|
||||||
|
-- This list is far from exhaustive.
|
||||||
|
|
||||||
|
useNounPhrase : NounPhrase -> Utterance = \john ->
|
||||||
|
postfixSS stopPunct (defaultNounPhrase john) ;
|
||||||
|
|
||||||
|
useCommonNounPhrase : Number -> CommNounPhrase -> Utterance = \n,car ->
|
||||||
|
useNounPhrase (indefNounPhrase n car) ;
|
||||||
|
|
||||||
|
-- Here are some default forms.
|
||||||
|
|
||||||
|
defaultNounPhrase : NounPhrase -> SS = \john ->
|
||||||
|
ss (john.s ! NPCase Nom) ;
|
||||||
|
|
||||||
|
defaultQuestion : Question -> SS = \whoareyou ->
|
||||||
|
whoareyou ;
|
||||||
|
|
||||||
|
defaultSentence : Sentence -> Utterance = \x ->
|
||||||
|
x ;
|
||||||
|
} ;
|
||||||
40
grammars/resource/finnish/TestFin.gf
Normal file
40
grammars/resource/finnish/TestFin.gf
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
concrete TestFin of TestAbs = ResFin ** open Prelude, Syntax in {
|
||||||
|
|
||||||
|
flags startcat=Phr ; lexer=text ; parser=chart ; unlexer=text ;
|
||||||
|
|
||||||
|
-- a random sample from the lexicon
|
||||||
|
|
||||||
|
lin
|
||||||
|
Big = regAdjDegr (sTalo "iso") "isompaa" "isointa" ;
|
||||||
|
Small = regAdjDegr (sSusi "pieni" "pienen" "pienenä") "pienempää" "pienintä" ;
|
||||||
|
Old = regAdjDegr (sKukko "vanha" "vanhan" "vanhoja") "vanhempaa" "vanhinta" ;
|
||||||
|
Young = regAdjDegr (sSusi "nuori" "nuoren" "nuorena") "nuorempaa" "nuorinta" ;
|
||||||
|
|
||||||
|
Man = cnHum (mkNoun "mies" "miehen" "miehenä" "miestä" "mieheen" "miehinä"
|
||||||
|
"miehissä" "miesten" "miehiä" "miehiin") ;
|
||||||
|
Woman = cnHum (sNainen "naista") ;
|
||||||
|
Car = cnNoHum (sTalo "auto") ;
|
||||||
|
House = cnNoHum (sTalo "talo") ;
|
||||||
|
Light = cnNoHum (sTalo "valo") ;
|
||||||
|
|
||||||
|
Walk = vJuosta "kävellä" "kävelen" ;
|
||||||
|
Run = vJuosta "juosta" "juoksen" ;
|
||||||
|
Say = vSanoa "sanoa" ;
|
||||||
|
Prove = vPoistaa "todistaa" ;
|
||||||
|
Send = mkTransVerbDir (vOttaa "lähettää" "lähetän") ;
|
||||||
|
Love = mkTransVerbCase (vPoistaa "rakastaa") Part ;
|
||||||
|
Wait = mkTransVerbCase (vOttaa "odottaa" "odotan") Part ;
|
||||||
|
|
||||||
|
Mother = funGen (n2n (cnHum (sKukko "äiti" "äidin" "äitejä"))) ;
|
||||||
|
Uncle = funGen (n2n (cnHum (sKukko "setä" "sedän" "setiä"))) ; --- eno!
|
||||||
|
|
||||||
|
Always = ss "aina" ;
|
||||||
|
Well = ss "hyvin" ;
|
||||||
|
|
||||||
|
SwitchOn = mkTransVerbDir (vOttaa "sytyttää" "sytytän") ;
|
||||||
|
SwitchOff = mkTransVerbDir (vOttaa "sammuttaa" "sammutan") ;
|
||||||
|
|
||||||
|
John = mkProperName (sKukko "Jussi" "Jussin" "Jusseja") ;
|
||||||
|
Mary = mkProperName (sKukko "Mari" "Marin" "Mareja") ;
|
||||||
|
|
||||||
|
} ;
|
||||||
123
grammars/resource/finnish/Types.gf
Normal file
123
grammars/resource/finnish/Types.gf
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
--1 Finnish Word Classes and Morphological Parameters
|
||||||
|
--
|
||||||
|
-- This is a resource module for Finnish morphology, defining the
|
||||||
|
-- morphological parameters and word classes of Finnish. It is aimed
|
||||||
|
-- to be complete w.r.t. the description of word forms.
|
||||||
|
-- However, it only includes those parameters that are needed for
|
||||||
|
-- analysing individual words: such parameters are defined in syntax modules.
|
||||||
|
--
|
||||||
|
-- We use the language-independent prelude.
|
||||||
|
|
||||||
|
resource Types = open Prelude in {
|
||||||
|
|
||||||
|
--
|
||||||
|
--2 Enumerated parameter types
|
||||||
|
--
|
||||||
|
-- These types are the ones found in school grammars.
|
||||||
|
-- Their parameter values are atomic. We omit three of the cases, not
|
||||||
|
-- occurring in the resource syntax. The accusative cases are only
|
||||||
|
-- defined in syntax; in morphology, there is a special accusative for
|
||||||
|
-- pronouns.
|
||||||
|
|
||||||
|
param
|
||||||
|
Number = Sg | Pl ;
|
||||||
|
Case = Nom | Gen | Part | Transl | Ess
|
||||||
|
| Iness | Elat | Illat | Adess | Ablat | Allat ;
|
||||||
|
Person = P1 | P2 | P3 ;
|
||||||
|
Degree = Pos | Comp | Sup ;
|
||||||
|
Gender = NonHuman | Human ;
|
||||||
|
|
||||||
|
-- For data abstraction, we define
|
||||||
|
|
||||||
|
oper
|
||||||
|
singular = Sg ;
|
||||||
|
plural = Pl ;
|
||||||
|
|
||||||
|
--2 Word classes and hierarchical parameter types
|
||||||
|
--
|
||||||
|
-- Real parameter types (i.e. ones on which words and phrases depend)
|
||||||
|
-- are often hierarchical. The alternative would be cross-products of
|
||||||
|
-- simple parameters, but this would usually overgenerate.
|
||||||
|
--
|
||||||
|
|
||||||
|
--3 Common nouns
|
||||||
|
--
|
||||||
|
-- Common nouns are inflected in number and noun case. In noun case, we include
|
||||||
|
-- forms used in connection with possessive suffixes.
|
||||||
|
|
||||||
|
param
|
||||||
|
NForm = NCase Number Case
|
||||||
|
| NPossNom | NPossGenPl | NPossTransl Number | NPossIllat Number ;
|
||||||
|
|
||||||
|
oper
|
||||||
|
CommonNoun : Type = {s : NForm => Str} ;
|
||||||
|
|
||||||
|
useNForm : NForm -> (Number => Case => Str) -> Str = \nf,f -> case nf of {
|
||||||
|
NCase n c => f ! n ! c ;
|
||||||
|
NPossNom => f ! Sg ! Nom ; ---- "iso autoni"; also "isot autoni" etc
|
||||||
|
NPossGenPl => f ! Pl ! Gen ;
|
||||||
|
NPossTransl n => f ! n ! Transl ;
|
||||||
|
NPossIllat n => f ! n ! Illat
|
||||||
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
--3 Adjectives
|
||||||
|
--
|
||||||
|
-- The major division is between the comparison degrees, but it
|
||||||
|
-- is also good to leave room for adjectives that cannon be compared.
|
||||||
|
-- Such adjectives are like common nouns.
|
||||||
|
|
||||||
|
Adjective : Type = CommonNoun ;
|
||||||
|
AdjDegr : Type = {s : Degree => NForm => Str} ;
|
||||||
|
|
||||||
|
--3 Verbs
|
||||||
|
--
|
||||||
|
-- We limit the grammar so far to verbs in the infinitive, second-person
|
||||||
|
-- imperative, and present tense indicative. A special form is needed for
|
||||||
|
-- the negated plural imperative.
|
||||||
|
|
||||||
|
param
|
||||||
|
VForm =
|
||||||
|
Inf
|
||||||
|
| Ind Number Person
|
||||||
|
| Imper Number
|
||||||
|
| ImpNegPl ;
|
||||||
|
|
||||||
|
oper
|
||||||
|
Verb : Type = SS1 VForm ;
|
||||||
|
|
||||||
|
vFormNeg = Imper Sg ;
|
||||||
|
|
||||||
|
vform2number : VForm -> Number = \v -> case v of {
|
||||||
|
Inf => Sg ;
|
||||||
|
Ind n _ => n ;
|
||||||
|
Imper n => n ;
|
||||||
|
ImpNegPl => Pl
|
||||||
|
} ;
|
||||||
|
|
||||||
|
--
|
||||||
|
--3 Pronouns
|
||||||
|
--
|
||||||
|
-- For pronouns, we need the noun case forms, plus an accusative.
|
||||||
|
|
||||||
|
param
|
||||||
|
PForm = PCase Case | PAcc ;
|
||||||
|
|
||||||
|
oper
|
||||||
|
Pronoun : Type = {s : PForm => Str ; n : Number ; p : Person} ;
|
||||||
|
|
||||||
|
--3 Proper names
|
||||||
|
--
|
||||||
|
-- Proper names only need case forms.
|
||||||
|
|
||||||
|
ProperName : Type = SS1 Case ;
|
||||||
|
|
||||||
|
|
||||||
|
--3 Relative pronouns
|
||||||
|
--
|
||||||
|
-- Relative pronouns are inflected like nouns, except for possessive suffixes.
|
||||||
|
|
||||||
|
RelPron : Type = {s : Number => Case => Str} ;
|
||||||
|
|
||||||
|
} ;
|
||||||
@@ -112,6 +112,9 @@ ccompute cnc = comp []
|
|||||||
if noVar v'
|
if noVar v'
|
||||||
then matchPatt cs v' >>= compt
|
then matchPatt cs v' >>= compt
|
||||||
else return $ S u' v'
|
else return $ S u' v'
|
||||||
|
FV ccs -> do
|
||||||
|
v' <- compt v
|
||||||
|
mapM (\c -> compt (S c v')) ccs >>= return . FV
|
||||||
|
|
||||||
_ -> liftM (S u') $ compt v
|
_ -> liftM (S u') $ compt v
|
||||||
|
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ checkResInfo gr (c,info) = do
|
|||||||
ty' <- check ty typeType >>= comp . fst
|
ty' <- check ty typeType >>= comp . fst
|
||||||
(de',_) <- check de ty'
|
(de',_) <- check de ty'
|
||||||
return (Yes ty', Yes de')
|
return (Yes ty', Yes de')
|
||||||
(Nope, Yes de) -> do
|
(_, Yes de) -> do
|
||||||
(de',ty') <- infer de
|
(de',ty') <- infer de
|
||||||
return (Yes ty', Yes de')
|
return (Yes ty', Yes de')
|
||||||
_ -> return (pty, pde) --- other cases are uninteresting
|
_ -> return (pty, pde) --- other cases are uninteresting
|
||||||
@@ -611,6 +611,10 @@ checkEqLType env t u trm = do
|
|||||||
|| elem n (allExtends env m)
|
|| elem n (allExtends env m)
|
||||||
(QC m a, QC n b) | a == b -> elem m (allExtends env n)
|
(QC m a, QC n b) | a == b -> elem m (allExtends env n)
|
||||||
|| elem n (allExtends env m)
|
|| elem n (allExtends env m)
|
||||||
|
(QC m a, Q n b) | a == b -> elem m (allExtends env n)
|
||||||
|
|| elem n (allExtends env m)
|
||||||
|
(Q m a, QC n b) | a == b -> elem m (allExtends env n)
|
||||||
|
|| elem n (allExtends env m)
|
||||||
|
|
||||||
(RecType rs, RecType ts) -> and [alpha g a b && l == k --- too strong req
|
(RecType rs, RecType ts) -> and [alpha g a b && l == k --- too strong req
|
||||||
| ((l,a),(k,b)) <- zip rs ts]
|
| ((l,a),(k,b)) <- zip rs ts]
|
||||||
|
|||||||
@@ -27,8 +27,9 @@ extendModInfo name old new = case (old,new) of
|
|||||||
|
|
||||||
extendMod :: Ident -> BinTree (Ident,Info) -> BinTree (Ident,Info) ->
|
extendMod :: Ident -> BinTree (Ident,Info) -> BinTree (Ident,Info) ->
|
||||||
Err (BinTree (Ident,Info))
|
Err (BinTree (Ident,Info))
|
||||||
extendMod name old new =
|
extendMod name old new = foldM try new $ tree2list old where
|
||||||
foldM (tryInsert (extendAnyInfo name) (indirInfo name)) new $ tree2list old
|
try t i@(c,_) = errIn ("constant" +++ prt c) $
|
||||||
|
tryInsert (extendAnyInfo name) (indirInfo name) t i
|
||||||
|
|
||||||
indirInfo :: Ident -> Info -> Info
|
indirInfo :: Ident -> Info -> Info
|
||||||
indirInfo n info = AnyInd b n' where
|
indirInfo n info = AnyInd b n' where
|
||||||
@@ -58,7 +59,7 @@ perhIndir n p = case p of
|
|||||||
_ -> p
|
_ -> p
|
||||||
|
|
||||||
extendAnyInfo :: Ident -> Info -> Info -> Err Info
|
extendAnyInfo :: Ident -> Info -> Info -> Err Info
|
||||||
extendAnyInfo n i j = case (i,j) of
|
extendAnyInfo n i j = errIn ("building extension for" +++ prt n) $ case (i,j) of
|
||||||
(AbsCat mc1 mf1, AbsCat mc2 mf2) ->
|
(AbsCat mc1 mf1, AbsCat mc2 mf2) ->
|
||||||
liftM2 AbsCat (updatePerhaps n mc1 mc2) (updatePerhaps n mf1 mf2) --- add cstrs
|
liftM2 AbsCat (updatePerhaps n mc1 mc2) (updatePerhaps n mf1 mf2) --- add cstrs
|
||||||
(AbsFun mt1 md1, AbsFun mt2 md2) ->
|
(AbsFun mt1 md1, AbsFun mt2 md2) ->
|
||||||
@@ -66,8 +67,7 @@ extendAnyInfo n i j = case (i,j) of
|
|||||||
|
|
||||||
(ResParam mt1, ResParam mt2) -> liftM ResParam $ updatePerhaps n mt1 mt2
|
(ResParam mt1, ResParam mt2) -> liftM ResParam $ updatePerhaps n mt1 mt2
|
||||||
(ResValue mt1, ResValue mt2) -> liftM ResValue $ updatePerhaps n mt1 mt2
|
(ResValue mt1, ResValue mt2) -> liftM ResValue $ updatePerhaps n mt1 mt2
|
||||||
(ResOper mt1 m1, ResOper mt2 m2) ->
|
(ResOper mt1 m1, ResOper mt2 m2) -> extendResOper n mt1 m1 mt2 m2
|
||||||
liftM2 ResOper (updatePerhaps n mt1 mt2) (updatePerhaps n m1 m2)
|
|
||||||
|
|
||||||
(CncCat mc1 mf1 mp1, CncCat mc2 mf2 mp2) ->
|
(CncCat mc1 mf1 mp1, CncCat mc2 mf2 mp2) ->
|
||||||
liftM3 CncCat (updatePerhaps n mc1 mc2)
|
liftM3 CncCat (updatePerhaps n mc1 mc2)
|
||||||
@@ -75,4 +75,20 @@ extendAnyInfo n i j = case (i,j) of
|
|||||||
(CncFun m mt1 md1, CncFun _ mt2 md2) ->
|
(CncFun m mt1 md1, CncFun _ mt2 md2) ->
|
||||||
liftM2 (CncFun m) (updatePerhaps n mt1 mt2) (updatePerhaps n md1 md2)
|
liftM2 (CncFun m) (updatePerhaps n mt1 mt2) (updatePerhaps n md1 md2)
|
||||||
|
|
||||||
_ -> Bad $ "cannot unify information for" +++ show n
|
(AnyInd _ _, ResOper _ _) -> return j ----
|
||||||
|
|
||||||
|
_ -> Bad $ "cannot unify information in" ++++ show i ++++ "and" ++++ show j
|
||||||
|
|
||||||
|
|
||||||
|
-- opers declared in one module and defined in an extension are a special case
|
||||||
|
|
||||||
|
extendResOper n mt1 m1 mt2 m2 = case (m1,m2) of
|
||||||
|
(Nope,_) -> return $ ResOper (strip mt1) m2
|
||||||
|
_ -> liftM2 ResOper (updatePerhaps n mt1 mt2) (updatePerhaps n m1 m2)
|
||||||
|
where
|
||||||
|
strip (Yes t) = Yes $ strp t
|
||||||
|
strip m = m
|
||||||
|
strp t = case t of
|
||||||
|
Q _ c -> Vr c
|
||||||
|
QC _ c -> Vr c
|
||||||
|
_ -> composSafeOp strp t
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ extendModule ms (name,mod) = case mod of
|
|||||||
_ -> Bad $ "cannot find extended module" +++ prt n
|
_ -> Bad $ "cannot find extended module" +++ prt n
|
||||||
extendMod n (jments m0) js
|
extendMod n (jments m0) js
|
||||||
_ -> return js
|
_ -> return js
|
||||||
return $ (name,ModMod (Module mt fs Nothing ops js1))
|
return $ (name,ModMod (Module mt fs me ops js1))
|
||||||
|
|
||||||
|
|
||||||
type Status = (StatusTree, [(OpenSpec Ident, StatusTree)])
|
type Status = (StatusTree, [(OpenSpec Ident, StatusTree)])
|
||||||
@@ -72,7 +72,9 @@ type StatusTree = BinTree (Ident,StatusInfo)
|
|||||||
type StatusInfo = Ident -> Term
|
type StatusInfo = Ident -> Term
|
||||||
|
|
||||||
renameIdentTerm :: Status -> Term -> Err Term
|
renameIdentTerm :: Status -> Term -> Err Term
|
||||||
renameIdentTerm env@(act,imps) t = case t of
|
renameIdentTerm env@(act,imps) t =
|
||||||
|
errIn ("atomic term" +++ prt t +++ "given" +++ unwords (map (prt . fst) qualifs)) $
|
||||||
|
case t of
|
||||||
Vr c -> do
|
Vr c -> do
|
||||||
f <- lookupTreeMany prt opens c
|
f <- lookupTreeMany prt opens c
|
||||||
return $ f c
|
return $ f c
|
||||||
@@ -90,7 +92,8 @@ renameIdentTerm env@(act,imps) t = case t of
|
|||||||
_ -> return t
|
_ -> return t
|
||||||
where
|
where
|
||||||
opens = act : [st | (OSimple _,st) <- imps]
|
opens = act : [st | (OSimple _,st) <- imps]
|
||||||
qualifs = [ (m, st) | (OQualif m _, st) <- imps]
|
qualifs = [(m, st) | (OQualif m _, st) <- imps] ++
|
||||||
|
[(m, st) | (OSimple m, st) <- imps] -- qualifying is always possible
|
||||||
|
|
||||||
--- would it make sense to optimize this by inlining?
|
--- would it make sense to optimize this by inlining?
|
||||||
renameIdentPatt :: Status -> Patt -> Err Patt
|
renameIdentPatt :: Status -> Patt -> Err Patt
|
||||||
@@ -117,8 +120,9 @@ tree2status o = case o of
|
|||||||
buildStatus :: SourceGrammar -> Ident -> SourceModInfo -> Err Status
|
buildStatus :: SourceGrammar -> Ident -> SourceModInfo -> Err Status
|
||||||
buildStatus gr c mo = let mo' = self2status c mo in case mo of
|
buildStatus gr c mo = let mo' = self2status c mo in case mo of
|
||||||
ModMod m -> do
|
ModMod m -> do
|
||||||
let ops = allOpens m
|
let gr1 = MGrammar $ (c,mo) : modules gr
|
||||||
mods <- mapM (lookupModule gr . openedModule) ops
|
ops = [OSimple e | e <- allExtends gr1 c] ++ allOpens m
|
||||||
|
mods <- mapM (lookupModule gr1 . openedModule) ops
|
||||||
let sts = map modInfo2status $ zip ops mods
|
let sts = map modInfo2status $ zip ops mods
|
||||||
return $ if isModCnc m
|
return $ if isModCnc m
|
||||||
then (NT, sts) -- the module itself does not define any names
|
then (NT, sts) -- the module itself does not define any names
|
||||||
|
|||||||
@@ -168,6 +168,14 @@ updatePerhaps old p1 p2 = case (p1,p2) of
|
|||||||
(_, May a) -> Bad "strange indirection"
|
(_, May a) -> Bad "strange indirection"
|
||||||
_ -> unifPerhaps p1 p2
|
_ -> unifPerhaps p1 p2
|
||||||
|
|
||||||
|
-- here the value is copied instead of referred to; used for oper types
|
||||||
|
updatePerhapsHard :: b -> Perhaps a b -> Perhaps a b -> Err (Perhaps a b)
|
||||||
|
updatePerhapsHard old p1 p2 = case (p1,p2) of
|
||||||
|
(Yes a, Nope) -> return $ yes a
|
||||||
|
(May older,Nope) -> return $ may older
|
||||||
|
(_, May a) -> Bad "strange indirection"
|
||||||
|
_ -> unifPerhaps p1 p2
|
||||||
|
|
||||||
-- binary search trees
|
-- binary search trees
|
||||||
|
|
||||||
data BinTree a = NT | BT a (BinTree a) (BinTree a) deriving (Show,Read)
|
data BinTree a = NT | BT a (BinTree a) (BinTree a) deriving (Show,Read)
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ lookupResDef gr m c = do
|
|||||||
info <- lookupInfo mo c
|
info <- lookupInfo mo c
|
||||||
case info of
|
case info of
|
||||||
ResOper _ (Yes t) -> return $ qualifAnnot m t
|
ResOper _ (Yes t) -> return $ qualifAnnot m t
|
||||||
|
ResOper _ Nope -> return $ Q m c
|
||||||
AnyInd _ n -> lookupResDef gr n c
|
AnyInd _ n -> lookupResDef gr n c
|
||||||
ResParam _ -> return $ QC m c
|
ResParam _ -> return $ QC m c
|
||||||
ResValue _ -> return $ QC m c
|
ResValue _ -> return $ QC m c
|
||||||
@@ -31,6 +32,7 @@ lookupResType gr m c = do
|
|||||||
info <- lookupInfo mo c
|
info <- lookupInfo mo c
|
||||||
case info of
|
case info of
|
||||||
ResOper (Yes t) _ -> return $ qualifAnnot m t
|
ResOper (Yes t) _ -> return $ qualifAnnot m t
|
||||||
|
ResOper (May n) _ -> lookupResType gr n c
|
||||||
AnyInd _ n -> lookupResType gr n c
|
AnyInd _ n -> lookupResType gr n c
|
||||||
ResParam _ -> return $ typePType
|
ResParam _ -> return $ typePType
|
||||||
ResValue (Yes t) -> return $ qualifAnnotPar m t
|
ResValue (Yes t) -> return $ qualifAnnotPar m t
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
module Today where today = "Fri Oct 10 14:16:56 CEST 2003"
|
module Today where today = "Tue Oct 21 17:20:02 CEST 2003"
|
||||||
|
|||||||
Reference in New Issue
Block a user