main problems of Finnish solved

This commit is contained in:
aarne
2006-02-05 19:57:26 +00:00
parent d752c36d0f
commit fc945b485b
15 changed files with 520 additions and 493 deletions

View File

@@ -30,6 +30,8 @@ resource ResFin = ParamX ** open Prelude in {
oper
Agr = {n : Number ; p : Person} ;
NP = {s : NPForm => Str ; a : Agr ; isPron : Bool} ;
--
--2 Adjectives
--
@@ -50,8 +52,13 @@ oper
-- have a uniform, special accusative form ("minut", etc).
param
NPForm = NPCase Case | NPAccNom | NPAccGen ;
NPForm = NPCase Case | NPAcc ;
oper
npform2case : NPForm -> Case = \f -> case f of {
NPCase c => c ;
NPAcc => Gen -- appCompl does the job
} ;
--2 For $Verb$
@@ -59,7 +66,7 @@ param
param
VForm =
Inf
Inf InfForm
| Presn Number Person
| Impf Number Person
| Condit Number Person
@@ -70,6 +77,10 @@ param
| Pass Bool
| PastPartAct AForm
| PastPartPass AForm
;
InfForm =
Inf1
| Inf3Iness -- 5 forms acc. to Karlsson
| Inf3Elat
| Inf3Illat
@@ -103,60 +114,101 @@ param
Compl : Type = {s : Str ; c : NPForm ; isPre : Bool} ;
appCompl : Bool -> Polarity -> Compl -> NP -> Str = \isFin,b,co,np ->
let
c = case <isFin, b, co.c, np.isPron,np.a.n> of {
<_, Neg, NPAcc,_,_> => NPCase Part ; -- en näe taloa/sinua
<_, Pos, NPAcc,True,_> => NPAcc ; -- näen/täytyy sinut
<True, Pos, NPAcc,False,Sg> => NPCase Gen ; -- näen talon
<False,Pos, NPAcc,_,Pl> => NPCase Nom ; -- täytyy talo/sinut; näen talot
<_,_,coc,_,_> => coc
} ;
nps = np.s ! c
in
preOrPost co.isPre co.s nps ;
-- For $Verb$.
Verb : Type = {
s : VForm => Str
} ;
param
VIForm =
VIFin Tense
| VIInf InfForm
| VIImper
;
VP : Type = {
s : Tense => Anteriority => Polarity => Agr => {fin, inf : Str} ;
s2 : Agr => Str
oper
VP = {
s : VIForm => Anteriority => Polarity => Agr => {fin, inf : Str} ;
s2 : Polarity => Agr => Str ; -- itseni/itseäni
ext : Str ;
sc : NPForm
} ;
predV : Verb -> VP = \verb -> {
s = \\t,ant,b,agr => {fin = verb.s ! Presn agr.n agr.p ; inf = []} ;
s2 = \\_ => []
} ;
{-
predV : (Verb ** {sc : NPForm}) -> VP = \verb -> {
s = \\vi,ant,b,agr =>
let
inf = verb.s ! VInf ;
fin = presVerb verb agr ;
past = verb.s ! VPast ;
part = verb.s ! VPPart ;
verbs = verb.s ;
part : Str = verbs ! PastPartAct (AN (NCase agr.n Nom)) ;
eiv : Str = case agr of {
{n = Sg ; p = P1} => "en" ;
{n = Sg ; p = P2} => "et" ;
{n = Sg ; p = P3} => "ei" ;
{n = Pl ; p = P1} => "emme" ;
{n = Pl ; p = P2} => "ette" ;
{n = Pl ; p = P3} => "eivät"
} ;
einegole : Str * Str * Str = case <vi,agr.n> of {
<VIFin (Pres | Fut),_> => <eiv, verbs ! Imper Sg, "ole"> ;
<VIFin Cond, _> => <eiv, verbs ! Condit Sg P3, "olisi"> ;
<VIFin Past, Sg> => <eiv, part, "ollut"> ;
<VIFin Past, Pl> => <eiv, part, "olleet"> ;
<VIImper, Sg> => <"älä", verbs ! Imper Sg, "ole"> ;
<VIImper, Pl> => <"älkää", verbs ! ImpNegPl, "olko"> ;
<VIInf i, _> => <"ei", verbs ! Inf i, "olla"> ----
} ;
ei : Str = einegole.p1 ;
neg : Str = einegole.p2 ;
ole : Str = einegole.p3 ;
olla : VForm => Str = verbOlla.s ;
vf : Str -> Str -> {fin, inf : Str} = \x,y ->
{fin = x ; inf = y} ;
mkvf : VForm -> {fin, inf : Str} = \p -> case <ant,b> of {
<Simul,Pos> => vf (verbs ! p) [] ;
<Simul,Neg> => vf ei neg ;
<Anter,Pos> => vf (olla ! p) part ;
<Anter,Neg> => vf ei (ole ++ part)
}
in
case <t,ant,b,ord> of {
<Pres,Simul,Pos,ODir> => vf fin [] ;
<Pres,Simul,Pos,OQuest> => vf (does agr) inf ;
<Pres,Simul,Neg,_> => vf (doesnt agr) inf ;
<Pres,Anter,Pos,_> => vf (have agr) part ;
<Pres,Anter,Neg,_> => vf (havent agr) part ;
<Past,Simul,Pos,ODir> => vf past [] ;
<Past,Simul,Pos,OQuest> => vf "did" inf ;
<Past,Simul,Neg,_> => vf "didn't" inf ;
<Past,Anter,Pos,_> => vf "had" part ;
<Past,Anter,Neg,_> => vf "hadn't" part ;
<Fut, Simul,Pos,_> => vf "will" inf ;
<Fut, Simul,Neg,_> => vf "won't" inf ;
<Fut, Anter,Pos,_> => vf "will" ("have" ++ part) ;
<Fut, Anter,Neg,_> => vf "won't" ("have" ++ part) ;
<Cond,Simul,Pos,_> => vf "would" inf ;
<Cond,Simul,Neg,_> => vf "wouldn't" inf ;
<Cond,Anter,Pos,_> => vf "would" ("have" ++ part) ;
<Cond,Anter,Neg,_> => vf "wouldn't" ("have" ++ part)
case vi of {
VIFin Past => mkvf (Impf agr.n agr.p) ;
VIFin Cond => mkvf (Condit agr.n agr.p) ;
_ => mkvf (Presn agr.n agr.p)
} ;
s2 = \\a => if_then_Str verb.isRefl (reflPron ! a) []
s2 = \\_,_ => [] ;
ext = [] ;
sc = verb.sc
} ;
insertObj : (Agr => Str) -> VP -> VP = \obj,vp -> {
insertObj : (Polarity => Agr => Str) -> VP -> VP = \obj,vp -> {
s = vp.s ;
s2 = \\a => vp.s2 ! a ++ obj ! a
s2 = \\b,a => vp.s2 ! b ! a ++ obj ! b ! a ;
ext = vp.ext ;
sc = vp.sc
} ;
{-
--- This is not functional.
insertAdV : Str -> VP -> VP = \adv,vp -> {
@@ -219,21 +271,24 @@ param
s : Tense => Anteriority => Polarity => SType => Str
} ;
{-
mkClause : Str -> Agr -> VP -> Clause =
\subj,agr,vp -> {
s = \\t,a,b,o =>
let
verb = vp.s ! t ! a ! b ! o ! agr ;
compl = vp.s2 ! agr
verb = vp.s ! VIFin t ! a ! b ! agr ;
compl = vp.s2 ! b ! agr ++ vp.ext
in
case o of {
ODir => subj ++ verb.fin ++ verb.inf ++ compl ;
OQuest => verb.fin ++ subj ++ verb.inf ++ compl
SDecl => subj ++ verb.fin ++ verb.inf ++ compl ;
SQuest => questPart verb.fin ++ subj ++ verb.inf ++ compl
}
} ;
questPart : Str -> Str = \on -> on ++ BIND ++ "ko" ; ----
{-
-- For $Numeral$.
mkNum : Str -> Str -> Str -> Str -> {s : DForm => CardOrd => Str} =
@@ -260,4 +315,256 @@ param
_ => ten + "th"
} ;
-}
-- The definitions below were moved here from $MorphoFin$ so that we the
-- auxiliary of predication can be defined.
verbOlla : Verb =
mkVerb
"olla" "on" "olen" "ovat" "olkaa" "ollaan"
"oli" "olin" "olisi" "ollut" "oltu" "ollun" ;
--3 Verbs
--
-- The present, past, conditional. and infinitive stems, acc. to Koskenniemi.
-- Unfortunately not enough (without complicated processes).
-- We moreover give grade alternation forms as arguments, since it does not
-- happen automatically.
--- A problem remains with the verb "seistä", where the infinitive
--- stem has vowel harmony "ä" but the others "a", thus "seisoivat" but "seiskää".
mkVerb : (_,_,_,_,_,_,_,_,_,_,_,_ : Str) -> Verb =
\tulla,tulee,tulen,tulevat,tulkaa,tullaan,tuli,tulin,tulisi,tullut,tultu,tullun ->
v2v (mkVerbH
tulla tulee tulen tulevat tulkaa tullaan tuli tulin tulisi tullut tultu tullun
) ;
v2v : VerbH -> Verb = \vh ->
let
tulla = vh.tulla ;
tulee = vh.tulee ;
tulen = vh.tulen ;
tulevat = vh.tulevat ;
tulkaa = vh.tulkaa ;
tullaan = vh.tullaan ;
tuli = vh.tuli ;
tulin = vh.tulin ;
tulisi = vh.tulisi ;
tullut = vh.tullut ;
tultu = vh.tultu ;
tultu = vh.tultu ;
tullun = vh.tullun ;
tuje = init tulen ;
tuji = init tulin ;
a = Predef.dp 1 tulkaa ;
tulko = Predef.tk 2 tulkaa + (ifTok Str a "a" "o" "ö") ;
o = last tulko ;
tulleena = Predef.tk 2 tullut + ("een" + a) ;
tulleen = (noun2adj (nhn (sRae tullut tulleena))).s ;
tullun = (noun2adj (nhn (sKukko tultu tullun (tultu + ("j"+a))))).s ;
tulema = tuje + "m" + a ;
vat = "v" + a + "t"
in
{s = table {
Inf Inf1 => tulla ;
Presn Sg P1 => tuje + "n" ;
Presn Sg P2 => tuje + "t" ;
Presn Sg P3 => tulee ;
Presn Pl P1 => tuje + "mme" ;
Presn Pl P2 => tuje + "tte" ;
Presn Pl P3 => tulevat ;
Impf Sg P1 => tuji + "n" ;
Impf Sg P2 => tuji + "t" ;
Impf Sg P3 => tuli ;
Impf Pl P1 => tuji + "mme" ;
Impf Pl P2 => tuji + "tte" ;
Impf Pl P3 => tuli + vat ;
Condit Sg P1 => tulisi + "n" ;
Condit Sg P2 => tulisi + "t" ;
Condit Sg P3 => tulisi ;
Condit Pl P1 => tulisi + "mme" ;
Condit Pl P2 => tulisi + "tte" ;
Condit Pl P3 => tulisi + vat ;
Imper Sg => tuje ;
Imper Pl => tulkaa ;
ImperP3 Sg => tulko + o + "n" ;
ImperP3 Pl => tulko + o + "t" ;
ImperP1Pl => tulkaa + "mme" ;
ImpNegPl => tulko ;
Pass True => tullaan ;
Pass False => Predef.tk 2 tullaan ;
PastPartAct n => tulleen ! n ;
PastPartPass n => tullun ! n ;
Inf Inf3Iness => tulema + "ss" + a ;
Inf Inf3Elat => tulema + "st" + a ;
Inf Inf3Illat => tulema + a + "n" ;
Inf Inf3Adess => tulema + "ll" + a ;
Inf Inf3Abess => tulema + "tt" + a
}
} ;
VerbH : Type = {
tulla,tulee,tulen,tulevat,tulkaa,tullaan,tuli,tulin,tulisi,tullut,tultu,tullun
: Str
} ;
mkVerbH : (_,_,_,_,_,_,_,_,_,_,_,_ : Str) -> VerbH =
\tulla,tulee,tulen,tulevat,tulkaa,tullaan,tuli,tulin,tulisi,tullut,tultu,tullun ->
{tulla = tulla ;
tulee = tulee ;
tulen = tulen ;
tulevat = tulevat ;
tulkaa = tulkaa ;
tullaan = tullaan ;
tuli = tuli ;
tulin = tulin ;
tulisi = tulisi ;
tullut = tullut ;
tultu = tultu ;
tullun = tullun
} ;
noun2adj : CommonNoun -> Adj = noun2adjComp True ;
noun2adjComp : Bool -> CommonNoun -> Adj = \isPos,tuore ->
let
tuoreesti = Predef.tk 1 (tuore.s ! NCase Sg Gen) + "sti" ;
tuoreemmin = Predef.tk 2 (tuore.s ! NCase Sg Gen) + "in"
in {s = table {
AN f => tuore.s ! f ;
AAdv => if_then_Str isPos tuoreesti tuoreemmin
}
} ;
CommonNoun = {s : NForm => Str} ;
-- To form an adjective, it is usually enough to give a noun declension: the
-- adverbial form is regular.
Adj : Type = {s : AForm => Str} ;
NounH : Type = {
a,vesi,vede,vete,vetta,veteen,vetii,vesii,vesien,vesia,vesiin : Str
} ;
-- worst-case macro
mkSubst : Str -> (_,_,_,_,_,_,_,_,_,_ : Str) -> NounH =
\a,vesi,vede,vete,vetta,veteen,vetii,vesii,vesien,vesia,vesiin ->
{a = a ;
vesi = vesi ;
vede = vede ;
vete = vete ;
vetta = vetta ;
veteen = veteen ;
vetii = vetii ;
vesii = vesii ;
vesien = vesien ;
vesia = vesia ;
vesiin = vesiin
} ;
nhn : NounH -> CommonNoun = \nh ->
let
a = nh.a ;
vesi = nh.vesi ;
vede = nh.vede ;
vete = nh.vete ;
vetta = nh.vetta ;
veteen = nh.veteen ;
vetii = nh.vetii ;
vesii = nh.vesii ;
vesien = nh.vesien ;
vesia = nh.vesia ;
vesiin = nh.vesiin
in
{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 Sg Abess => vede + ("tt" + a) ;
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" ;
NCase Pl Abess => vesii + ("tt" + a) ;
NComit => vetii + "ne" ;
NInstruct => vesii + "n" ;
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
}
} ;
-- Surpraisingly, making the test for the partitive, this not only covers
-- "rae", "perhe", "savuke", but also "rengas", "lyhyt" (except $Sg Illat$), etc.
sRae : (_,_ : Str) -> NounH = \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") ;
-- 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) -> NounH = \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") ;
}