tuning resource API

This commit is contained in:
aarne
2005-02-06 09:52:19 +00:00
parent bd432cf147
commit c30eebbba6
35 changed files with 2065 additions and 1432 deletions

View File

@@ -1,8 +1,9 @@
--# -path=.:../scandinavian:../abstract:../../prelude
concrete BasicSwe of Basic = CategoriesSwe ** open NewParadigmsSwe in {
concrete BasicSwe of Basic = CategoriesSwe ** open ParadigmsSwe in {
flags startcat=Phr ; lexer=textlit ; parser=chart ; unlexer=text ;
optimize=values ;
lin
airplane_N = regN "flygplan" neutrum ;
@@ -218,5 +219,11 @@ lin
put_V2 = mkV2 (irregV "sätta" "satte" "satt") [] ;
stop_V = regV "stanna" ;
jump_V = regV "hoppa" ;
here_Adv = mkAdv "här" ;
here7to_Adv = mkAdv "hit" ;
here7from_Adv = mkAdv ["härifrån"] ;
there_Adv = mkAdv "där" ;
there7to_Adv = mkAdv "dit" ;
there7from_Adv = mkAdv ["därifrån"] ;
} ;

View File

@@ -0,0 +1,27 @@
concrete CountrySwe of Country = open ResourceSwe, ParadigmsSwe in {
lincat
Country = PN ;
Nationality = A ;
Language = N ;
lin
Denmark = regPN "Danmark" neutrum ;
England = regPN "England" neutrum ;
Finland = regPN "Finland" neutrum ;
France = regPN "Frankrike" neutrum ;
Germany = regPN "Tyskland" neutrum ;
Italy = regPN "Italien" neutrum ;
Norway = regPN "Norge" neutrum ;
Russia = regPN "Ryssland" neutrum ;
Spain = regPN "Spanien" neutrum ;
Sweden = regPN "Sverige" neutrum ;
Danish = regA "Dansk" ;
English = regA "Engelsk" ;
DanishLang = regN "Danska" utrum ;
EnglishLang = regN "Engelska" utrum ;
} ;

View File

@@ -0,0 +1,22 @@
--# -path=.:../scandinavian:../abstract:../../prelude
concrete LangSwe of Lang =
RulesSwe,
ClauseSwe,
StructuralSwe,
BasicSwe,
TimeSwe,
CountrySwe
** open Prelude, ResourceSwe, ParadigmsSwe in {
lin
AdvDate d = prefixSS "på" d ;
AdvTime t = prefixSS "klockan" t ;
NWeekday w = w ;
PNWeekday w = nounPN w ;
PNCountry x = x ;
ANationality x = x ;
NLanguage x = x ;
}

View File

@@ -1,348 +0,0 @@
--# -path=.:../scandinavian:../abstract:../../prelude
--1 Swedish Lexical Paradigms UNDER RECONSTRUCTION!
--
-- Aarne Ranta 2003
--
-- This is an API to the user of the resource grammar
-- for adding lexical items. It gives functions for forming
-- expressions of open categories: nouns, adjectives, verbs.
--
-- Closed categories (determiners, pronouns, conjunctions) are
-- accessed through the resource syntax API, $Structural.gf$.
--
-- The main difference with $MorphoEng.gf$ is that the types
-- referred to are compiled resource grammar types. We have moreover
-- had the design principle of always having existing forms, rather
-- than stems, as string arguments of the paradigms.
--
-- The structure of functions for each word class $C$ is the following:
-- first we give a handful of patterns that aim to cover all
-- regular cases. Then we give a worst-case function $mkC$, which serves as an
-- escape to construct the most irregular words of type $C$.
-- However, this function should only seldom be needed: we have a
-- separate module $IrregularEng$, which covers all irregularly inflected
-- words.
--
-- The following modules are presupposed:
resource NewParadigmsSwe =
open (Predef=Predef), Prelude, TypesSwe, MorphoSwe, SyntaxSwe, ResourceSwe in {
--2 Parameters
--
-- To abstract over gender names, we define the following identifiers.
oper
Gender : Type ;
utrum : Gender ;
neutrum : Gender ;
-- To abstract over number names, we define the following.
Number : Type ;
singular : Number ;
plural : Number ;
-- To abstract over case names, we define the following.
Case : Type ;
nominative : Case ;
genitive : Case ;
-- Prepositions used in many-argument functions are just strings.
Preposition : Type = Str ;
--2 Nouns
-- Worst case: give all four forms. The gender is computed from the
-- last letter of the second form (if "n", then $utrum$, otherwise $neutrum$).
mkN : (apa,apan,apor,aporna : Str) -> N ;
-- The regular function takes the singular indefinite form and the gender,
-- and computes the other forms by a heuristic.
-- If in doubt, use the $cc$ command to test!
regN : Str -> Gender -> N ;
-- In practice the worst case is often just: give singular and plural indefinite.
mk2N : (nyckel,nycklar : Str) -> N ;
-- All nouns created by the previous functions are marked as
-- $nonmasculine$. If you want a $masculine$ noun, wrap it with the following
-- function:
mascN : N -> N ;
--3 Compound nouns
--
-- All the functions above work quite as well to form compound nouns,
-- such as "fotboll".
--3 Relational nouns
--
-- Relational nouns ("daughter of x") need a preposition.
mkN2 : N -> Preposition -> N2 ;
-- The most common preposition is "av", and the following is a
-- shortcut for regular, $nonhuman$ relational nouns with "av".
regN2 : Str -> Gender -> N2 ;
-- Use the function $mkPreposition$ or see the section on prepositions below to
-- form other prepositions.
--
-- Three-place relational nouns ("the connection from x to y") need two prepositions.
mkN3 : N -> Preposition -> Preposition -> N3 ;
--3 Relational common noun phrases
--
-- In some cases, you may want to make a complex $CN$ into a
-- relational noun (e.g. "the old town hall of").
cnN2 : CN -> Preposition -> N2 ;
cnN3 : CN -> Preposition -> Preposition -> N3 ;
--
--3 Proper names and noun phrases
--
-- Proper names, with a regular genitive, are formed as follows
regPN : Str -> Gender -> PN ; -- John, John's
-- To form a noun phrase that can also be plural and have an irregular
-- genitive, you can use the worst-case function.
mkNP : Str -> Str -> Number -> Gender -> NP ;
--2 Adjectives
-- Non-comparison one-place adjectives need for forms:
mkA : (galen,galet,galna : Str) -> A ;
-- For regular adjectives, the other forms are derived.
regA : Str -> A ;
-- In practice, two forms are enough.
mk2A : (bred,brett : Str) -> A ;
--3 Two-place adjectives
--
-- Two-place adjectives need a preposition for their second argument.
mkA2 : A -> Preposition -> A2 ;
-- Comparison adjectives may need as many as seven forms.
mkADeg : (liten, litet, lilla, sma, mindre, minst, minsta : Str) -> ADeg ;
-- The regular pattern works for many adjectives, e.g. those ending
-- with "ig".
regADeg : Str -> ADeg ;
-- Just the comparison forms can be irregular.
irregADeg : (tung,tyngre,tyngst : Str) -> ADeg ;
-- Sometimes just the positive forms are irregular.
mk3ADeg : (galen,galet,galna : Str) -> ADeg ;
mk2ADeg : (bred,brett : Str) -> ADeg ;
-- If comparison is formed by "more, "most", as in general for
-- long adjective, the following pattern is used:
compoundADeg : A -> ADeg ; -- -/more/most ridiculous
-- From a given $ADeg$, it is possible to get back to $A$.
adegA : ADeg -> A ;
--2 Adverbs
-- Adverbs are not inflected. Most lexical ones have position
-- after the verb. Some can be preverbal (e.g. "always").
mkAdv : Str -> Adv ;
mkAdV : Str -> AdV ;
-- Adverbs modifying adjectives and sentences can also be formed.
mkAdA : Str -> AdA ;
--2 Prepositions
--
-- A preposition is just a string.
mkPreposition : Str -> Preposition ;
--2 Verbs
--
-- The worst case needs five forms.
mkV : (supa,super,sup,söp,supit,supen : Str) -> V ;
-- The 'regular verb' function is the first conjugation.
regV : (tala : Str) -> V ;
-- The almost regular verb function needs the infinitive and the present.
mk2V : (leka,leker : Str) -> V ;
-- There is an extensive list of irregular verbs in the module $IrregularSwe$.
-- In practice, it is enough to give three forms, as in school books.
irregV : (dricka, drack, druckit : Str) -> V ;
--3 Verbs with a particle.
--
-- The particle, such as in "switch on", is given as a string.
partV : V -> Str -> V ;
--3 Deponent verbs.
--
-- Some words are used in passive forms only, e.g. "hoppas".
depV : V -> V ;
--3 Two-place verbs
--
-- Two-place verbs need a preposition, except the special case with direct object.
-- (transitive verbs). Notice that a particle comes from the $V$.
mkV2 : V -> Preposition -> V2 ;
dirV2 : V -> V2 ;
--3 Three-place verbs
--
-- Three-place (ditransitive) verbs need two prepositions, of which
-- the first one or both can be absent.
mkV3 : V -> Str -> Str -> V3 ; -- speak, with, about
dirV3 : V -> Str -> V3 ; -- give,_,to
dirdirV3 : V -> V3 ; -- give,_,_
--3 Other complement patterns
--
-- Verbs and adjectives can take complements such as sentences,
-- questions, verb phrases, and adjectives.
mkV0 : V -> V0 ;
mkVS : V -> VS ;
mkV2S : V -> Str -> V2S ;
mkVV : V -> VV ;
mkV2V : V -> Str -> Str -> V2V ;
mkVA : V -> VA ;
mkV2A : V -> Str -> V2A ;
mkVQ : V -> VQ ;
mkV2Q : V -> Str -> V2Q ;
mkAS : A -> AS ;
mkA2S : A -> Str -> A2S ;
mkAV : A -> AV ;
mkA2V : A -> Str -> A2V ;
--2 Definitions of the paradigms
--
-- The definitions should not bother the user of the API. So they are
-- hidden from the document.
--.
Gender = SyntaxSwe.NounGender ;
Number = TypesSwe.Number ;
Case = TypesSwe.Case ;
utrum = NUtr NoMasc ;
neutrum = NNeutr ;
singular = Sg ;
plural = Pl ;
nominative = Nom ;
genitive = Gen ;
mkN x y z u = extCommNoun (mkNoun x y z u) ** {lock_N = <>} ;
regN x g = extCommNoun (regNoun x (genNoun g)) ** {lock_N = <>} ;
mk2N x g = extCommNoun (reg2Noun x g) ** {lock_N = <>} ;
mascN n = {s = n.s ; g = NUtr Masc ; lock_N = <>} ;
mkN2 = \n,p -> UseN n ** {lock_N2 = <> ; s2 = p} ;
regN2 n g = mkN2 (regN n g) (mkPreposition "av") ;
mkN3 = \n,p,q -> UseN n ** {lock_N3 = <> ; s2 = p ; s3 = q} ;
cnN2 = \n,p -> n ** {lock_N2 = <> ; s2 = p} ;
cnN3 = \n,p,q -> n ** {lock_N3 = <> ; s2 = p ; s3 = q} ;
regPN n g = {s = \\c => mkCase c n ; g = g} ** {lock_PN = <>} ;
mkNP x y n g =
{s = table {PGen _ => x ; _ => y} ; g = genNoun g ; n = n ; p = P3 ;
lock_NP = <>} ;
mkA a b c = extractPositive (adjAlmostReg a b c) ** {lock_A = <>} ;
mk2A a b = extractPositive (adj2Reg a b) ** {lock_A = <>} ;
regA a = extractPositive (adjReg a) ** {lock_A = <>} ;
mkA2 a p = a ** {s2 = p ; lock_A2 = <>} ;
mkADeg a b c d e f g = mkAdjective a b c d e f g ** {lock_ADeg = <>} ;
regADeg a = adjReg a ** {lock_ADeg = <>} ;
irregADeg a b c = adjIrreg3 a b c ** {lock_ADeg = <>} ;
mk3ADeg a b c = adjAlmostReg a b c ** {lock_ADeg = <>} ;
mk2ADeg a b = adj2Reg a b ** {lock_ADeg = <>} ;
mkAdv x = ss x ** {lock_Adv = <>} ;
mkAdV x = ss x ** {lock_AdV = <>} ;
mkAdA x = ss x ** {lock_AdA = <>} ;
mkPreposition p = p ;
mkV a b c d e f = mkVerb a b c d e f ** {s1 = [] ; lock_V = <>} ;
regV a = mk2V a (a + "r") ;
mk2V a b = regVerb a b ** {s1 = [] ; lock_V = <>} ;
irregV x y z = vSälja x y z
** {s1 = [] ; lock_V = <>} ;
partV v p = {s = v.s ; s1 = p ; lock_V = <>} ;
depV v = deponentVerb v ** {lock_V = <>} ;
mkV2 v p = v ** {s = v.s ; s1 = v.s1 ; s2 = p ; lock_V2 = <>} ;
dirV2 v = mkV2 v [] ;
mkV3 v p q = v ** {s = v.s ; s1 = v.s1 ; s2 = p ; s3 = q ; lock_V3 = <>} ;
dirV3 v p = mkV3 v [] p ;
dirdirV3 v = dirV3 v [] ;
mkV0 v = v ** {lock_V0 = <>} ;
mkVS v = v ** {lock_VS = <>} ;
mkV2S v p = mkV2 v p ** {lock_V2S = <>} ;
mkVV v = v ** {s3 = "att" ; lock_VV = <>} ;
mkV2V v p t = mkV2 v p ** {s3 = t ; lock_V2V = <>} ;
mkVA v = v ** {lock_VA = <>} ;
mkV2A v p = mkV2 v p ** {lock_V2A = <>} ;
mkVQ v = v ** {lock_VQ = <>} ;
mkV2Q v p = mkV2 v p ** {lock_V2Q = <>} ;
mkAS v = v ** {lock_AS = <>} ;
mkA2S v p = mkA2 v p ** {lock_A2S = <>} ;
mkAV v = v ** {lock_AV = <>} ;
mkA2V v p = mkA2 v p ** {lock_A2V = <>} ;
} ;

View File

@@ -0,0 +1,370 @@
--# -path=.:../scandinavian:../abstract:../../prelude
--1 Swedish Lexical Paradigms
--
-- Aarne Ranta 2003
--
-- This is an API to the user of the resource grammar
-- for adding lexical items. It give shortcuts for forming
-- expressions of basic categories: nouns, adjectives, verbs.
--
-- Closed categories (determiners, pronouns, conjunctions) are
-- accessed through the resource syntax API, $Structural.gf$.
--
-- The main difference with $MorphoSwe.gf$ is that the types
-- referred to are compiled resource grammar types. We have moreover
-- had the design principle of always having existing forms, not stems, as string
-- arguments of the paradigms.
--
-- The following modules are presupposed:
resource ParadigmsSwe = open (Predef=Predef), Prelude, MorphoSwe, SyntaxSwe, ResourceSwe in {
--2 Parameters
--
-- To abstract over gender names, we define the following identifiers.
oper
Gender : Type ;
utrum : Gender ;
neutrum : Gender ;
Sex : Type ;
masculine : Sex ;
nonmasculine : Sex ;
-- To abstract over case names, we define the following.
Case : Type ;
nominative : Case ;
genitive : Case ;
-- To abstract over number names, we define the following.
Number : Type ;
singular : Number ;
plural : Number ;
--2 Nouns
-- Worst case: give all nominative forms and the gender.
-- The genitive is formed automatically, even when the nominative
-- ends with an "s".
mkN : (_,_,_,_ : Str) -> Gender -> Sex -> N ;
-- man, mannen, män, männen
-- Here are some common patterns, corresponding to school-gramamr declensions.
-- Except $nPojke$, $nKarl$, and $nMurare$,
-- they are defined to be $nonmasculine$, which means that they don't create
-- the definite adjective form with "e" but with "a".
nApa : Str -> N ; -- apa (apan, apor, aporna) ; utrum
nBil : Str -> N ; -- bil (bilen, bilar, bilarna) ; utrum
nKarl : Str -> N ; -- karl (karlen, karlar, karlarna) ; utrum ; masculine
nPojke : Str -> N ; -- pojke (pojken, pojkar, pojkarna) ; utrum ; masculine
nNyckel : Str -> N ; -- nyckel (nyckeln, nycklar, nycklarna) ; utrum
nRisk : Str -> N ; -- risk (risken, risker, riskerna) ; utrum
nDike : Str -> N ; -- dike (diket, diken, dikena) ; neutrum
nRep : Str -> N ; -- rep (repet, rep, repen) ; neutrum
nPapper : Str -> N ; -- papper (pappret, papper, pappren) ; neutrum
nMurare : Str -> N ; -- murare (muraren, murare, murarna) ; utrum ; masculine
nKikare : Str -> N ; -- kikare (kikaren, kikare, kikarna) ; utrum
-- Nouns used as functions need a preposition. The most common ones are "av",
-- "på", and "till". A preposition is a string.
mkN2 : N -> Str -> N2 ;
funAv : N -> N2 ;
funPaa : N -> N2 ;
funTill : N -> N2 ;
-- Proper names, with their possibly
-- irregular genitive. The regular genitive is "s", omitted after "s".
mkPN : (_,_ : Str) -> Gender -> Sex -> PN ; -- Karolus, Karoli
pnReg : Str -> Gender -> Sex -> PN ; -- Johan,Johans ; Johannes, Johannes
pnS : Str -> Gender -> Sex -> PN ; -- "Burger King(s)"
-- On the top level, it is maybe $CN$ that is used rather than $N$, and
-- $NP$ rather than $PN$.
mkCN : N -> CN ;
mkNP : (Karolus, Karoli : Str) -> Gender -> NP ;
npReg : Str -> Gender -> NP ; -- Johann, Johanns
--2 Adjectives
-- Non-comparison one-place adjectives need four forms in the worst case:
-- strong singular, weak singular, plural.
mkA : (_,_,_,_ : Str) -> A ; -- liten, litet, lilla, små
-- Special cases needing one form each are: regular adjectives,
-- adjectives with unstressed "e" in the last syllable, those
-- ending with "n" as a further special case, and invariable
-- adjectives.
adjReg : Str -> A ; -- billig (billigt, billiga, billiga)
adjNykter : Str -> A ; -- nykter (nyktert, nyktra, nyktra)
adjGalen : Str -> A ; -- galen (galet, galna, galna)
adjInvar : Str -> A ; -- bra
-- Two-place adjectives need a preposition and a case as extra arguments.
mkA2 : A -> Str -> A2 ; -- delbar, med
mkA2Reg : Str -> Str -> A2 ; --
-- Comparison adjectives may need the three four forms for the positive case, plus
-- three more forms for the comparison cases.
mkADeg : (liten, litet, lilla, sma, mindre, minst, minsta : Str) -> ADeg ;
-- Some comparison adjectives are completely regular.
aReg : Str -> ADeg ;
-- On top level, there are adjectival phrases. The most common case is
-- just to use a one-place adjective. The variation in $adjGen$ is taken
-- into account.
apReg : Str -> AP ;
--2 Adverbs
-- Adverbs are not inflected. Most lexical ones have position not
-- before the verb. Some can be preverbal (e.g. "alltid").
mkAdv : Str -> Adv ;
mkAdvPre : Str -> Adv ;
-- Adverbs modifying adjectives and sentences can also be formed.
mkAdA : Str -> AdA ;
mkAdS : Str -> AdS ;
-- Prepositional phrases are another productive form of adverbials.
mkPP : Str -> NP -> Adv ;
--2 Verbs
--
-- The fragment only has present tense so far.
-- The worst case needs three forms: the infinitive, the indicative, and the
-- imperative.
Voice: Type;
passive : Voice;
active: Voice;
mkV : (_,_,_,_,_,_ : Str) -> V ; -- vara, är, var; trivas, trivs, trivs
-- The main conjugations need one string each.
vKoka : Str -> V ; -- tala (talar, tala)
vSteka : Str -> V ; -- leka (leker, lek)
---- vBo : Str -> V ; -- bo (bor, bo)
---- vAndas : Str -> V ; -- andas [all forms the same: also "slåss"]
---- vTrivas : Str -> V ; -- trivas (trivs, trivs)
-- The verbs 'be' and 'have' are special.
vVara : V ;
vHa : V ;
-- Particle verbs are formed by putting together a verb and a particle.
-- If the verb already has a particle, it is replaced by the new one.
mkPartV : V -> Str -> V ; -- stänga av ;
-- Two-place verbs, and the special case with direct object.
mkV2 : V -> Str -> V2 ; -- tycka, om
tvDir : V -> V2 ; -- gilla
-- Ditransitive verbs.
mkV3 : V -> Str -> Str -> V3 ; -- prata, med, om
v3Dir : V -> Str -> V3 ; -- ge,_,till
v3DirDir : V -> V3 ; -- ge,_,_
-- Sentence complement verbs.
mkVS : V -> VS ; -- säga (att ...)
-- Verb phrase complement verbs.
vvInf : V -> VV ; -- orka (spela)
vvAtt : V -> VV ; -- gilla (att spela)
vvBoth : V -> VV ; -- försöka (spela | att spela)
-- The definitions should not bother the user of the API. So they are
-- hidden from the document.
--.
Gender = SyntaxSwe.Gender ;
Sex = SyntaxSwe.Sex ;
Case = SyntaxSwe.Case ;
Number = SyntaxSwe.Number ;
Voice = SyntaxSwe.Voice ;
utrum = Utr ;
neutrum = Neutr ;
masculine = Masc ;
nonmasculine = NoMasc ;
nominative = Nom ;
genitive = Gen ;
singular = Sg ;
plural = Pl ;
active = Act;
passive = Pass;
mkN = \apa, apan, apor, aporna, g, x -> let
{nom = table {
SF Sg Indef _ => apa ;
SF Sg Def _ => apan ;
SF Pl Indef _ => apor ;
SF Pl Def _ => aporna
}
} in
{s = \\n,d,c => mkCase c (nom ! SF n d Nom) ;
g = gensex g x ; lock_N = <>
} ;
-- auxiliaries
mkGenit : Tok -> Tok = \s -> ifTok Tok (Predef.dp 1 s) "s" s (s + "s") ;
mkCase : Case -> Tok -> Tok = \c,t -> case c of {
Nom => t ;
Gen => mkGenit t
} ;
nApa = \apa ->
let {apor = Predef.tk 1 apa + "or"} in
mkN apa (apa + "n") apor (apor + "na") utrum nonmasculine ;
nBil = \bil ->
mkN bil (bil + "en") (bil + "ar") (bil + "arna") utrum nonmasculine ;
nKarl = \bil ->
mkN bil (bil + "en") (bil + "ar") (bil + "arna") utrum masculine ;
nPojke = \pojke ->
let {bil = Predef.tk 1 pojke} in
mkN pojke (bil + "en") (bil + "ar") (bil + "arna") utrum masculine ;
nNyckel = \cykel ->
let {cykl = Predef.tk 2 cykel + Predef.dp 1 cykel} in
mkN cykel (cykel + "n") (cykl + "ar") (cykl + "arna") utrum nonmasculine ;
nRisk = \bil ->
mkN bil (bil + "en") (bil + "er") (bil + "erna") utrum nonmasculine ;
nDike = \dike ->
mkN dike (dike + "t") (dike + "n") (dike + "na") neutrum nonmasculine ;
nRep = \rep ->
mkN rep (rep + "et") rep (rep + "en") neutrum nonmasculine ;
nPapper = \cykel ->
let {cykl = Predef.tk 2 cykel + Predef.dp 1 cykel} in
mkN cykel (cykl + "et") cykel (cykl + "en") neutrum nonmasculine ;
nMurare = \murare ->
let {murar = Predef.tk 1 murare} in
mkN murare (murar + "en") murare (murar + "na") utrum masculine ;
nKikare = \murare ->
let {murar = Predef.tk 1 murare} in
mkN murare (murar + "en") murare (murar + "na") utrum nonmasculine ;
mkN2 x y = mkFun x y ** {lock_N2 = <>} ;
funAv = \f -> mkN2 f "av" ;
funPaa = \f -> mkN2 f "på" ;
funTill = \f -> mkN2 f "till" ;
mkPN = \karolus, karoli, g, x ->
{s = table {Gen => karoli ; _ => karolus} ; g = gensex g x ; lock_PN = <>} ;
pnReg = \horst ->
mkPN horst (ifTok Tok (Predef.dp 1 horst) "s" horst (horst + "s")) ;
pnS = \bk ->
mkPN bk (bk + "s") ;
mkCN = UseN ;
mkNP = \a,b,g -> UsePN (mkPN a b g nonmasculine) ; -- gender irrelevant in NP
npReg = \s,g -> UsePN (pnReg s g nonmasculine) ;
mkA = \liten, litet, lilla, små ->
{s = table {
Strong (ASg Utr) => \\c => mkCase c liten ;
Strong (ASg Neutr) => \\c => mkCase c litet ;
Strong APl => \\c => mkCase c små ;
Weak (AxSg Masc) => \\c => mkCase c (Predef.tk 1 lilla + "e") ;
Weak _ => \\c => mkCase c lilla
} ;
lock_A = <>
} ;
adjReg = \billig -> mkA billig (billig + "t") (billig + "a") (billig + "a") ;
adjNykter = \nykter ->
let {nyktr = Predef.tk 2 nykter + Predef.dp 1 nykter} in
mkA nykter (nykter + "t") (nyktr + "a") (nyktr + "a") ;
adjGalen = \galen ->
let {gal = Predef.tk 2 galen} in
mkA galen (gal + "et") (gal + "na") (gal + "na") ;
adjInvar = \bra -> {s = \\_,_ => bra ; lock_A = <>} ;
mkA2 = \a,p -> a ** {s2 = p ; lock_A2 = <>} ;
mkA2Reg = \a -> mkA2 (adjReg a) ;
mkADeg = \liten, litet, lilla, sma, mindre, minst, minsta ->
let {lit = (mkA liten litet lilla sma).s} in
{s = table {
AF (Posit f) c => lit ! f ! c ;
AF Compar c => mkCase c mindre ;
AF (Super SupStrong) c => mkCase c minst ;
AF (Super SupWeak) c => mkCase c minsta --- masculine!
} ;
lock_ADeg = <>
} ;
aReg = \fin -> mkADeg fin
(fin + "t") (fin + "a") (fin + "a") (fin + "are") (fin + "ast") (fin + "aste") ;
apReg = \s -> UseA (adjReg s) ;
mkAdv a = advPost a ** {lock_Adv = <>} ;
mkAdvPre a = advPre a ** {lock_Adv = <>} ;
mkPP x y = prepPhrase x y ** {lock_Adv = <>} ;
mkAdA a = ss a ** {lock_AdA = <>} ;
mkAdS a = ss a ** {lock_AdS = <>} ;
mkV x y z a b c = mkVerb x y z a b c ** {lock_V = <>} ;
vKoka = \tala -> vTala (Predef.tk 1 tala) ** {s1 = [] ; lock_V = <>} ;
vSteka = \leka -> vLeka (Predef.tk 1 leka) ** {s1 = [] ; lock_V = <>} ;
---- vBo = \bo -> mkV bo (bo+"r") bo ;
---- vAndas = \andas -> mkV andas andas andas ;
---- vTrivas = \trivas ->
---- let {trivs = Predef.tk 1 trivas + "s"} in mkV trivas trivs trivs ;
vVara = verbVara ** {s1 = [] ; lock_V = <>} ;
vHa = verbHava ** {s1 = [] ; lock_V = <>} ;
mkPartV v p = {s = v.s ; s1 = p ; lock_V = <>} ;
mkV2 x y = mkTransVerb x y ** {lock_V2 = <>} ;
tvDir = \v -> mkV2 v [] ;
mkV3 x y z = mkDitransVerb x y z ** {lock_V3 = <>} ;
v3Dir x y = mkV3 x [] y ;
v3DirDir x = v3Dir x [] ;
mkVS v = v ** {lock_VS = <>} ;
vvInf v = v ** {isAux = True ; lock_VV = <>} ;
vvAtt v = v ** {isAux = False ; lock_VV = <>} ;
vvBoth v = v ** {isAux = variants {False ; True} ; lock_VV = <>} ;
gensex : Gender -> Sex -> NounGender = \g,x -> case g of {
Utr => NUtr x ;
_ => NNeutr
} ;
} ;

View File

@@ -1,370 +1,350 @@
--# -path=.:../scandinavian:../abstract:../../prelude
--1 Swedish Lexical Paradigms
--1 Swedish Lexical Paradigms UNDER RECONSTRUCTION!
--
-- Aarne Ranta 2003
--
-- This is an API to the user of the resource grammar
-- for adding lexical items. It give shortcuts for forming
-- expressions of basic categories: nouns, adjectives, verbs.
-- for adding lexical items. It gives functions for forming
-- expressions of open categories: nouns, adjectives, verbs.
--
-- Closed categories (determiners, pronouns, conjunctions) are
-- accessed through the resource syntax API, $Structural.gf$.
--
-- The main difference with $MorphoSwe.gf$ is that the types
-- The main difference with $MorphoEng.gf$ is that the types
-- referred to are compiled resource grammar types. We have moreover
-- had the design principle of always having existing forms, not stems, as string
-- arguments of the paradigms.
-- had the design principle of always having existing forms, rather
-- than stems, as string arguments of the paradigms.
--
-- The structure of functions for each word class $C$ is the following:
-- first we give a handful of patterns that aim to cover all
-- regular cases. Then we give a worst-case function $mkC$, which serves as an
-- escape to construct the most irregular words of type $C$.
-- However, this function should only seldom be needed: we have a
-- separate module $IrregularEng$, which covers all irregularly inflected
-- words.
--
-- The following modules are presupposed:
resource ParadigmsSwe = open (Predef=Predef), Prelude, MorphoSwe, SyntaxSwe, ResourceSwe in {
resource ParadigmsSwe =
open (Predef=Predef), Prelude, TypesSwe, MorphoSwe, SyntaxSwe, ResourceSwe in {
--2 Parameters
--
-- To abstract over gender names, we define the following identifiers.
oper
Gender : Type ;
utrum : Gender ;
neutrum : Gender ;
Gender : Type ;
Sex : Type ;
masculine : Sex ;
nonmasculine : Sex ;
-- To abstract over case names, we define the following.
Case : Type ;
nominative : Case ;
genitive : Case ;
utrum : Gender ;
neutrum : Gender ;
-- To abstract over number names, we define the following.
Number : Type ;
Number : Type ;
singular : Number ;
plural : Number ;
-- To abstract over case names, we define the following.
Case : Type ;
nominative : Case ;
genitive : Case ;
-- Prepositions used in many-argument functions are just strings.
Preposition : Type = Str ;
--2 Nouns
-- Worst case: give all nominative forms and the gender.
-- The genitive is formed automatically, even when the nominative
-- ends with an "s".
-- Worst case: give all four forms. The gender is computed from the
-- last letter of the second form (if "n", then $utrum$, otherwise $neutrum$).
mkN : (_,_,_,_ : Str) -> Gender -> Sex -> N ;
-- man, mannen, män, männen
mkN : (apa,apan,apor,aporna : Str) -> N ;
-- Here are some common patterns, corresponding to school-gramamr declensions.
-- Except $nPojke$, $nKarl$, and $nMurare$,
-- they are defined to be $nonmasculine$, which means that they don't create
-- the definite adjective form with "e" but with "a".
-- The regular function takes the singular indefinite form and the gender,
-- and computes the other forms by a heuristic.
-- If in doubt, use the $cc$ command to test!
nApa : Str -> N ; -- apa (apan, apor, aporna) ; utrum
nBil : Str -> N ; -- bil (bilen, bilar, bilarna) ; utrum
nKarl : Str -> N ; -- karl (karlen, karlar, karlarna) ; utrum ; masculine
nPojke : Str -> N ; -- pojke (pojken, pojkar, pojkarna) ; utrum ; masculine
nNyckel : Str -> N ; -- nyckel (nyckeln, nycklar, nycklarna) ; utrum
nRisk : Str -> N ; -- risk (risken, risker, riskerna) ; utrum
nDike : Str -> N ; -- dike (diket, diken, dikena) ; neutrum
nRep : Str -> N ; -- rep (repet, rep, repen) ; neutrum
nPapper : Str -> N ; -- papper (pappret, papper, pappren) ; neutrum
nMurare : Str -> N ; -- murare (muraren, murare, murarna) ; utrum ; masculine
nKikare : Str -> N ; -- kikare (kikaren, kikare, kikarna) ; utrum
regN : Str -> Gender -> N ;
-- Nouns used as functions need a preposition. The most common ones are "av",
-- "på", and "till". A preposition is a string.
-- In practice the worst case is often just: give singular and plural indefinite.
mkN2 : N -> Str -> N2 ;
funAv : N -> N2 ;
funPaa : N -> N2 ;
funTill : N -> N2 ;
mk2N : (nyckel,nycklar : Str) -> N ;
-- Proper names, with their possibly
-- irregular genitive. The regular genitive is "s", omitted after "s".
-- All nouns created by the previous functions are marked as
-- $nonmasculine$. If you want a $masculine$ noun, wrap it with the following
-- function:
mkPN : (_,_ : Str) -> Gender -> Sex -> PN ; -- Karolus, Karoli
pnReg : Str -> Gender -> Sex -> PN ; -- Johan,Johans ; Johannes, Johannes
pnS : Str -> Gender -> Sex -> PN ; -- "Burger King(s)"
mascN : N -> N ;
-- On the top level, it is maybe $CN$ that is used rather than $N$, and
-- $NP$ rather than $PN$.
--3 Compound nouns
--
-- All the functions above work quite as well to form compound nouns,
-- such as "fotboll".
mkCN : N -> CN ;
mkNP : (Karolus, Karoli : Str) -> Gender -> NP ;
npReg : Str -> Gender -> NP ; -- Johann, Johanns
--3 Relational nouns
--
-- Relational nouns ("daughter of x") need a preposition.
mkN2 : N -> Preposition -> N2 ;
-- The most common preposition is "av", and the following is a
-- shortcut for regular, $nonhuman$ relational nouns with "av".
regN2 : Str -> Gender -> N2 ;
-- Use the function $mkPreposition$ or see the section on prepositions below to
-- form other prepositions.
--
-- Three-place relational nouns ("the connection from x to y") need two prepositions.
mkN3 : N -> Preposition -> Preposition -> N3 ;
--3 Relational common noun phrases
--
-- In some cases, you may want to make a complex $CN$ into a
-- relational noun (e.g. "the old town hall of"). However, $N2$ and
-- $N3$ are purely lexical categories. But you can use the $AdvCN$
-- and $PrepNP$ constructions to build phrases like this.
--
--3 Proper names and noun phrases
--
-- Proper names, with a regular genitive, are formed as follows
regPN : Str -> Gender -> PN ; -- John, John's
-- Sometimes you can reuse a common noun as a proper name, e.g. "Bank".
nounPN : N -> PN ;
-- To form a noun phrase that can also be plural and have an irregular
-- genitive, you can use the worst-case function.
mkNP : Str -> Str -> Number -> Gender -> NP ;
--2 Adjectives
-- Non-comparison one-place adjectives need four forms in the worst case:
-- strong singular, weak singular, plural.
-- Non-comparison one-place adjectives need for forms:
mkA : (_,_,_,_ : Str) -> A ; -- liten, litet, lilla, små
mkA : (galen,galet,galna : Str) -> A ;
-- Special cases needing one form each are: regular adjectives,
-- adjectives with unstressed "e" in the last syllable, those
-- ending with "n" as a further special case, and invariable
-- adjectives.
-- For regular adjectives, the other forms are derived.
adjReg : Str -> A ; -- billig (billigt, billiga, billiga)
adjNykter : Str -> A ; -- nykter (nyktert, nyktra, nyktra)
adjGalen : Str -> A ; -- galen (galet, galna, galna)
adjInvar : Str -> A ; -- bra
regA : Str -> A ;
-- Two-place adjectives need a preposition and a case as extra arguments.
-- In practice, two forms are enough.
mkA2 : A -> Str -> A2 ; -- delbar, med
mkA2Reg : Str -> Str -> A2 ; --
mk2A : (bred,brett : Str) -> A ;
--3 Two-place adjectives
--
-- Two-place adjectives need a preposition for their second argument.
-- Comparison adjectives may need the three four forms for the positive case, plus
-- three more forms for the comparison cases.
mkA2 : A -> Preposition -> A2 ;
-- Comparison adjectives may need as many as seven forms.
mkADeg : (liten, litet, lilla, sma, mindre, minst, minsta : Str) -> ADeg ;
-- Some comparison adjectives are completely regular.
-- The regular pattern works for many adjectives, e.g. those ending
-- with "ig".
aReg : Str -> ADeg ;
regADeg : Str -> ADeg ;
-- On top level, there are adjectival phrases. The most common case is
-- just to use a one-place adjective. The variation in $adjGen$ is taken
-- into account.
-- Just the comparison forms can be irregular.
irregADeg : (tung,tyngre,tyngst : Str) -> ADeg ;
-- Sometimes just the positive forms are irregular.
mk3ADeg : (galen,galet,galna : Str) -> ADeg ;
mk2ADeg : (bred,brett : Str) -> ADeg ;
-- If comparison is formed by "more, "most", as in general for
-- long adjective, the following pattern is used:
compoundADeg : A -> ADeg ; -- -/more/most ridiculous
-- From a given $ADeg$, it is possible to get back to $A$.
adegA : ADeg -> A ;
apReg : Str -> AP ;
--2 Adverbs
-- Adverbs are not inflected. Most lexical ones have position not
-- before the verb. Some can be preverbal (e.g. "alltid").
-- Adverbs are not inflected. Most lexical ones have position
-- after the verb. Some can be preverbal (e.g. "always").
mkAdv : Str -> Adv ;
mkAdvPre : Str -> Adv ;
mkAdV : Str -> AdV ;
-- Adverbs modifying adjectives and sentences can also be formed.
mkAdA : Str -> AdA ;
mkAdS : Str -> AdS ;
-- Prepositional phrases are another productive form of adverbials.
mkPP : Str -> NP -> Adv ;
--2 Prepositions
--
-- A preposition is just a string.
mkPreposition : Str -> Preposition ;
--2 Verbs
--
-- The fragment only has present tense so far.
-- The worst case needs three forms: the infinitive, the indicative, and the
-- imperative.
-- The worst case needs five forms.
Voice: Type;
mkV : (supa,super,sup,söp,supit,supen : Str) -> V ;
passive : Voice;
active: Voice;
-- The 'regular verb' function is the first conjugation.
mkV : (_,_,_,_,_,_ : Str) -> V ; -- vara, är, var; trivas, trivs, trivs
regV : (tala : Str) -> V ;
-- The main conjugations need one string each.
-- The almost regular verb function needs the infinitive and the present.
vKoka : Str -> V ; -- tala (talar, tala)
vSteka : Str -> V ; -- leka (leker, lek)
---- vBo : Str -> V ; -- bo (bor, bo)
mk2V : (leka,leker : Str) -> V ;
---- vAndas : Str -> V ; -- andas [all forms the same: also "slåss"]
---- vTrivas : Str -> V ; -- trivas (trivs, trivs)
-- There is an extensive list of irregular verbs in the module $IrregularSwe$.
-- In practice, it is enough to give three forms, as in school books.
-- The verbs 'be' and 'have' are special.
irregV : (dricka, drack, druckit : Str) -> V ;
vVara : V ;
vHa : V ;
-- Particle verbs are formed by putting together a verb and a particle.
-- If the verb already has a particle, it is replaced by the new one.
--3 Verbs with a particle.
--
-- The particle, such as in "switch on", is given as a string.
mkPartV : V -> Str -> V ; -- stänga av ;
partV : V -> Str -> V ;
-- Two-place verbs, and the special case with direct object.
--3 Deponent verbs.
--
-- Some words are used in passive forms only, e.g. "hoppas".
mkV2 : V -> Str -> V2 ; -- tycka, om
tvDir : V -> V2 ; -- gilla
depV : V -> V ;
-- Ditransitive verbs.
--3 Two-place verbs
--
-- Two-place verbs need a preposition, except the special case with direct object.
-- (transitive verbs). Notice that a particle comes from the $V$.
mkV3 : V -> Str -> Str -> V3 ; -- prata, med, om
v3Dir : V -> Str -> V3 ; -- ge,_,till
v3DirDir : V -> V3 ; -- ge,_,_
mkV2 : V -> Preposition -> V2 ;
-- Sentence complement verbs.
dirV2 : V -> V2 ;
mkVS : V -> VS ; -- säga (att ...)
--3 Three-place verbs
--
-- Three-place (ditransitive) verbs need two prepositions, of which
-- the first one or both can be absent.
-- Verb phrase complement verbs.
mkV3 : V -> Str -> Str -> V3 ; -- speak, with, about
dirV3 : V -> Str -> V3 ; -- give,_,to
dirdirV3 : V -> V3 ; -- give,_,_
vvInf : V -> VV ; -- orka (spela)
vvAtt : V -> VV ; -- gilla (att spela)
vvBoth : V -> VV ; -- försöka (spela | att spela)
--3 Other complement patterns
--
-- Verbs and adjectives can take complements such as sentences,
-- questions, verb phrases, and adjectives.
mkV0 : V -> V0 ;
mkVS : V -> VS ;
mkV2S : V -> Str -> V2S ;
mkVV : V -> VV ;
mkV2V : V -> Str -> Str -> V2V ;
mkVA : V -> VA ;
mkV2A : V -> Str -> V2A ;
mkVQ : V -> VQ ;
mkV2Q : V -> Str -> V2Q ;
mkAS : A -> AS ;
mkA2S : A -> Str -> A2S ;
mkAV : A -> AV ;
mkA2V : A -> Str -> A2V ;
--2 Definitions of the paradigms
--
-- The definitions should not bother the user of the API. So they are
-- hidden from the document.
--.
Gender = SyntaxSwe.Gender ;
Sex = SyntaxSwe.Sex ;
Case = SyntaxSwe.Case ;
Number = SyntaxSwe.Number ;
Voice = SyntaxSwe.Voice ;
utrum = Utr ;
neutrum = Neutr ;
masculine = Masc ;
nonmasculine = NoMasc ;
nominative = Nom ;
genitive = Gen ;
Gender = SyntaxSwe.NounGender ;
Number = TypesSwe.Number ;
Case = TypesSwe.Case ;
utrum = NUtr NoMasc ;
neutrum = NNeutr ;
singular = Sg ;
plural = Pl ;
nominative = Nom ;
genitive = Gen ;
active = Act;
passive = Pass;
mkN x y z u = extCommNoun (mkNoun x y z u) ** {lock_N = <>} ;
regN x g = extCommNoun (regNoun x (genNoun g)) ** {lock_N = <>} ;
mk2N x g = extCommNoun (reg2Noun x g) ** {lock_N = <>} ;
mascN n = {s = n.s ; g = NUtr Masc ; lock_N = <>} ;
mkN = \apa, apan, apor, aporna, g, x -> let
{nom = table {
SF Sg Indef _ => apa ;
SF Sg Def _ => apan ;
SF Pl Indef _ => apor ;
SF Pl Def _ => aporna
}
} in
{s = \\n,d,c => mkCase c (nom ! SF n d Nom) ;
g = gensex g x ; lock_N = <>
} ;
mkN2 = \n,p -> n ** {lock_N2 = <> ; s2 = p} ;
regN2 n g = mkN2 (regN n g) (mkPreposition "av") ;
mkN3 = \n,p,q -> n ** {lock_N3 = <> ; s2 = p ; s3 = q} ;
-- auxiliaries
mkGenit : Tok -> Tok = \s -> ifTok Tok (Predef.dp 1 s) "s" s (s + "s") ;
mkCase : Case -> Tok -> Tok = \c,t -> case c of {
Nom => t ;
Gen => mkGenit t
} ;
regPN n g = {s = \\c => mkCase c n ; g = g} ** {lock_PN = <>} ;
nounPN n = {s = n.s ! singular ! Indef ; g = n.g ; lock_PN = <>} ;
mkNP x y n g =
{s = table {PGen _ => x ; _ => y} ; g = genNoun g ; n = n ; p = P3 ;
lock_NP = <>} ;
nApa = \apa ->
let {apor = Predef.tk 1 apa + "or"} in
mkN apa (apa + "n") apor (apor + "na") utrum nonmasculine ;
mkA a b c = extractPositive (adjAlmostReg a b c) ** {lock_A = <>} ;
mk2A a b = extractPositive (adj2Reg a b) ** {lock_A = <>} ;
regA a = extractPositive (adjReg a) ** {lock_A = <>} ;
nBil = \bil ->
mkN bil (bil + "en") (bil + "ar") (bil + "arna") utrum nonmasculine ;
nKarl = \bil ->
mkN bil (bil + "en") (bil + "ar") (bil + "arna") utrum masculine ;
nPojke = \pojke ->
let {bil = Predef.tk 1 pojke} in
mkN pojke (bil + "en") (bil + "ar") (bil + "arna") utrum masculine ;
nNyckel = \cykel ->
let {cykl = Predef.tk 2 cykel + Predef.dp 1 cykel} in
mkN cykel (cykel + "n") (cykl + "ar") (cykl + "arna") utrum nonmasculine ;
nRisk = \bil ->
mkN bil (bil + "en") (bil + "er") (bil + "erna") utrum nonmasculine ;
nDike = \dike ->
mkN dike (dike + "t") (dike + "n") (dike + "na") neutrum nonmasculine ;
nRep = \rep ->
mkN rep (rep + "et") rep (rep + "en") neutrum nonmasculine ;
nPapper = \cykel ->
let {cykl = Predef.tk 2 cykel + Predef.dp 1 cykel} in
mkN cykel (cykl + "et") cykel (cykl + "en") neutrum nonmasculine ;
nMurare = \murare ->
let {murar = Predef.tk 1 murare} in
mkN murare (murar + "en") murare (murar + "na") utrum masculine ;
nKikare = \murare ->
let {murar = Predef.tk 1 murare} in
mkN murare (murar + "en") murare (murar + "na") utrum nonmasculine ;
mkA2 a p = a ** {s2 = p ; lock_A2 = <>} ;
mkADeg a b c d e f g = mkAdjective a b c d e f g ** {lock_ADeg = <>} ;
regADeg a = adjReg a ** {lock_ADeg = <>} ;
irregADeg a b c = adjIrreg3 a b c ** {lock_ADeg = <>} ;
mk3ADeg a b c = adjAlmostReg a b c ** {lock_ADeg = <>} ;
mk2ADeg a b = adj2Reg a b ** {lock_ADeg = <>} ;
mkN2 x y = mkFun x y ** {lock_N2 = <>} ;
funAv = \f -> mkN2 f "av" ;
funPaa = \f -> mkN2 f "på" ;
funTill = \f -> mkN2 f "till" ;
mkAdv x = ss x ** {lock_Adv = <>} ;
mkAdV x = ss x ** {lock_AdV = <>} ;
mkAdA x = ss x ** {lock_AdA = <>} ;
mkPN = \karolus, karoli, g, x ->
{s = table {Gen => karoli ; _ => karolus} ; g = gensex g x ; lock_PN = <>} ;
pnReg = \horst ->
mkPN horst (ifTok Tok (Predef.dp 1 horst) "s" horst (horst + "s")) ;
pnS = \bk ->
mkPN bk (bk + "s") ;
mkPreposition p = p ;
mkCN = UseN ;
mkNP = \a,b,g -> UsePN (mkPN a b g nonmasculine) ; -- gender irrelevant in NP
npReg = \s,g -> UsePN (pnReg s g nonmasculine) ;
mkV a b c d e f = mkVerb a b c d e f ** {s1 = [] ; lock_V = <>} ;
mkA = \liten, litet, lilla, små ->
{s = table {
Strong (ASg Utr) => \\c => mkCase c liten ;
Strong (ASg Neutr) => \\c => mkCase c litet ;
Strong APl => \\c => mkCase c små ;
Weak (AxSg Masc) => \\c => mkCase c (Predef.tk 1 lilla + "e") ;
Weak _ => \\c => mkCase c lilla
} ;
lock_A = <>
} ;
regV a = mk2V a (a + "r") ;
mk2V a b = regVerb a b ** {s1 = [] ; lock_V = <>} ;
adjReg = \billig -> mkA billig (billig + "t") (billig + "a") (billig + "a") ;
adjNykter = \nykter ->
let {nyktr = Predef.tk 2 nykter + Predef.dp 1 nykter} in
mkA nykter (nykter + "t") (nyktr + "a") (nyktr + "a") ;
adjGalen = \galen ->
let {gal = Predef.tk 2 galen} in
mkA galen (gal + "et") (gal + "na") (gal + "na") ;
adjInvar = \bra -> {s = \\_,_ => bra ; lock_A = <>} ;
irregV x y z = vSälja x y z
** {s1 = [] ; lock_V = <>} ;
mkA2 = \a,p -> a ** {s2 = p ; lock_A2 = <>} ;
mkA2Reg = \a -> mkA2 (adjReg a) ;
partV v p = {s = v.s ; s1 = p ; lock_V = <>} ;
depV v = deponentVerb v ** {lock_V = <>} ;
mkADeg = \liten, litet, lilla, sma, mindre, minst, minsta ->
let {lit = (mkA liten litet lilla sma).s} in
{s = table {
AF (Posit f) c => lit ! f ! c ;
AF Compar c => mkCase c mindre ;
AF (Super SupStrong) c => mkCase c minst ;
AF (Super SupWeak) c => mkCase c minsta --- masculine!
} ;
lock_ADeg = <>
} ;
mkV2 v p = v ** {s = v.s ; s1 = v.s1 ; s2 = p ; lock_V2 = <>} ;
dirV2 v = mkV2 v [] ;
aReg = \fin -> mkADeg fin
(fin + "t") (fin + "a") (fin + "a") (fin + "are") (fin + "ast") (fin + "aste") ;
mkV3 v p q = v ** {s = v.s ; s1 = v.s1 ; s2 = p ; s3 = q ; lock_V3 = <>} ;
dirV3 v p = mkV3 v [] p ;
dirdirV3 v = dirV3 v [] ;
apReg = \s -> UseA (adjReg s) ;
mkV0 v = v ** {lock_V0 = <>} ;
mkVS v = v ** {lock_VS = <>} ;
mkV2S v p = mkV2 v p ** {lock_V2S = <>} ;
mkVV v = v ** {s3 = "att" ; lock_VV = <>} ;
mkV2V v p t = mkV2 v p ** {s3 = t ; lock_V2V = <>} ;
mkVA v = v ** {lock_VA = <>} ;
mkV2A v p = mkV2 v p ** {lock_V2A = <>} ;
mkVQ v = v ** {lock_VQ = <>} ;
mkV2Q v p = mkV2 v p ** {lock_V2Q = <>} ;
mkAdv a = advPost a ** {lock_Adv = <>} ;
mkAdvPre a = advPre a ** {lock_Adv = <>} ;
mkPP x y = prepPhrase x y ** {lock_Adv = <>} ;
mkAdA a = ss a ** {lock_AdA = <>} ;
mkAdS a = ss a ** {lock_AdS = <>} ;
mkV x y z a b c = mkVerb x y z a b c ** {lock_V = <>} ;
vKoka = \tala -> vTala (Predef.tk 1 tala) ** {s1 = [] ; lock_V = <>} ;
vSteka = \leka -> vLeka (Predef.tk 1 leka) ** {s1 = [] ; lock_V = <>} ;
---- vBo = \bo -> mkV bo (bo+"r") bo ;
---- vAndas = \andas -> mkV andas andas andas ;
---- vTrivas = \trivas ->
---- let {trivs = Predef.tk 1 trivas + "s"} in mkV trivas trivs trivs ;
vVara = verbVara ** {s1 = [] ; lock_V = <>} ;
vHa = verbHava ** {s1 = [] ; lock_V = <>} ;
mkPartV v p = {s = v.s ; s1 = p ; lock_V = <>} ;
mkV2 x y = mkTransVerb x y ** {lock_V2 = <>} ;
tvDir = \v -> mkV2 v [] ;
mkV3 x y z = mkDitransVerb x y z ** {lock_V3 = <>} ;
v3Dir x y = mkV3 x [] y ;
v3DirDir x = v3Dir x [] ;
mkVS v = v ** {lock_VS = <>} ;
vvInf v = v ** {isAux = True ; lock_VV = <>} ;
vvAtt v = v ** {isAux = False ; lock_VV = <>} ;
vvBoth v = v ** {isAux = variants {False ; True} ; lock_VV = <>} ;
gensex : Gender -> Sex -> NounGender = \g,x -> case g of {
Utr => NUtr x ;
_ => NNeutr
} ;
mkAS v = v ** {lock_AS = <>} ;
mkA2S v p = mkA2 v p ** {lock_A2S = <>} ;
mkAV v = v ** {lock_AV = <>} ;
mkA2V v p = mkA2 v p ** {lock_A2V = <>} ;
} ;

View File

@@ -6,14 +6,108 @@
--
concrete StructuralSwe of Structural =
CategoriesSwe, NumeralsSwe ** open Prelude, MorphoSwe, SyntaxSwe in {
flags optimize=values ;
lin
UseNumeral i = {s = table {Nom => i.s ; Gen => i.s ++ "s"}} ; ---
above_Prep = ss "ovanför" ;
after_Prep = ss "efter" ;
by8agent_Prep = ss "av" ;
all8mass_Det = mkDeterminerSgGender2 "all" "allt" IndefP ;
all_NDet = mkDeterminerPlNum "alla" IndefP ;
almost_Adv = ss "nästan" ;
although_Subj = ss "fast" ;
and_Conj = ss "och" ** {n = Pl} ;
because_Subj = ss "eftersom" ;
before_Prep = ss "före" ;
behind_Prep = ss "bakom" ;
between_Prep = ss "mellan" ;
both_AndConjD = sd2 "både" "och" ** {n = Pl} ;
by8means_Prep = ss "med" ;
can8know_VV = mkVerb "kunna" "kan" "kunn" "kunde" "kunnat" "kunnen" ** {s3 = []} ;
can_VV = mkVerb "kunna" "kan" "kunn" "kunde" "kunnat" "kunnen" ** {s3 = []} ;
during_Prep = ss "under" ;
either8or_ConjD = sd2 "antingen" "eller" ** {n = Sg} ;
everybody_NP = let alla = table {Nom => "alla" ; Gen => "allas"} in
{s = \\c => alla ! npCase c ; g = Utr ; n = Pl ; p = P3} ;
every_Det = varjeDet ;
everything_NP = nameNounPhrase (mkProperName "allting" NNeutr) ;
everywhere_Adv = advPost "varstans" ;
from_Prep = ss "från" ;
he_NP = pronNounPhrase han_34 ;
how_IAdv = ss "hur" ;
how8many_IDet = mkDeterminerPl ["hur många"] IndefP ;
if_Subj = ss "om" ;
in8front_Prep = ss "framför" ;
i_NP = pronNounPhrase jag_32 ;
in_Prep = ss "i" ;
it_NP = pronNounPhrase det_40 ; ----
many_Det = mkDeterminerPl "många" IndefP ;
most_Det = mkDeterminerSgGender2 ["den mesta"] ["det mesta"] (DefP Def) ;
most8many_Det = flestaDet ;
much_Det = mkDeterminerSg (detSgInvar "mycket") IndefP ;
must_VV = mkVerb "få" "måste" "få" "fick" "måst" "måst" ** {s3 = []} ;
no_Phr = ss ["Nej ."] ;
on_Prep = ss "på" ;
or_Conj = ss "eller" ** {n = Sg} ;
otherwise_Adv = ss "annars" ;
part_Prep = ss "av" ;
possess_Prep = ss "av" ;
quite_Adv = ss "ganska" ;
she_NP = pronNounPhrase hon_35 ;
so_Adv = ss "så" ;
somebody_NP = nameNounPhrase (mkProperName "någon" (NUtr Masc)) ;
some_Det = mkDeterminerSgGender2 "någon" "något" IndefP ;
some_NDet = mkDeterminerPlNum "några" IndefP ;
something_NP = nameNounPhrase (mkProperName "någonting" NNeutr) ;
somewhere_Adv = advPost "någonstans" ;
that_Det = mkDeterminerSgGender2 ["den där"] ["det där"] (DefP Def) ;
that_NP = regNameNounPhrase ["det där"] NNeutr ;
therefore_Adv = ss "därför" ;
these_NDet = mkDeterminerPlNum ["de här"] (DefP Def) ;
they8fem_NP = pronNounPhrase de_38 ;
they_NP = pronNounPhrase de_38 ;
this_Det = mkDeterminerSgGender2 ["den här"] ["det här"] (DefP Def) ;
this_NP = regNameNounPhrase ["det här"] NNeutr ;
those_NDet = mkDeterminerPlNum ["de där"] (DefP Def) ;
thou_NP = pronNounPhrase du_33 ;
through_Prep = ss "genom" ;
too_Adv = ss "för" ;
to_Prep = ss "till" ;
under_Prep = ss "under" ;
very_Adv = ss "mycket" ;
want_VV = mkVerb "vilja" "vill" "vilj" "ville" "velat" "velad" ** {s3 = []} ;
we_NP = pronNounPhrase (vi_36) ;
what8many_IP = intPronWhat plural ;
what8one_IP = intPronWhat singular ;
when_IAdv = ss "när" ;
when_Subj = ss "när" ;
where_IAdv = ss "var" ;
which8one_IDet = vilkenDet ;
which8many_IDet = mkDeterminerPl "vilka" IndefP ;
who8many_IP = intPronWho plural ;
who8one_IP = intPronWho singular ;
why_IAdv = ss "varför" ;
without_Prep = ss "utan" ;
with_Prep = ss "med" ;
ye_NP = pronNounPhrase (ni_37) ;
yes_Phr = ss ["Ja ."] ;
you_NP = let {ni = pronNounPhrase ni_37 } in {
s = ni.s ; g = ni.g ; n = Sg ; p = P2} ; ---- gives wrong refl
{-
INP = pronNounPhrase jag_32 ;
ThouNP = pronNounPhrase du_33 ;
HeNP = pronNounPhrase han_34 ;
SheNP = pronNounPhrase hon_35 ;
WeNumNP n = pronNounPhrase (pronWithNum vi_36 n) ;
YeNumNP n = pronNounPhrase (pronWithNum ni_37 n) ;
WeNP n = pronNounPhrase (vi_36 n) ;
YeNP n = pronNounPhrase (ni_37 n) ;
TheyNP = pronNounPhrase de_38 ;
TheyFemNP = pronNounPhrase de_38 ;
@@ -23,10 +117,6 @@ concrete StructuralSwe of Structural =
ItNP = pronNounPhrase det_40 ; ----
ThisNP = regNameNounPhrase ["det här"] NNeutr ;
ThatNP = regNameNounPhrase ["det där"] NNeutr ;
TheseNumNP n =
{s = \\c => ["de här"] ++ n.s ! npCase c ; g = Neutr ; n = Pl ; p = P3} ;
ThoseNumNP n =
{s = \\c => ["de där"] ++ n.s ! npCase c ; g = Neutr ; n = Pl ; p = P3} ;
EveryDet = varjeDet ;
AllMassDet = mkDeterminerSgGender2 "all" "allt" IndefP ;
@@ -66,16 +156,16 @@ concrete StructuralSwe of Structural =
IfSubj = ss "om" ;
WhenSubj = ss "när" ;
PhrYes = ss ["Ja ."] ;
PhrNo = ss ["Nej ."] ;
YesPhr = ss ["Ja ."] ;
NoPhr = ss ["Nej ."] ;
VeryAdv = ss "mycket" ;
TooAdv = ss "för" ;
SoAdv = ss "så" ;
OtherwiseAdv = ss "annars" ;
ThereforeAdv = ss "därför" ;
EverybodyNP = let alla = table {Nom => "alla" ; Gen => "allas"} in
{s = \\c => alla ! npCase c ; g = Utr ; n = Pl ; p = P3} ;
EverybodyNP = let alla = table {Nom => "alla" ; Gen => "allas"} in {s = \\c => alla ! npCase c ; g = Utr ; n = Pl ; p = P3} ;
SomebodyNP = nameNounPhrase (mkProperName "någon" (NUtr Masc)) ;
NobodyNP = nameNounPhrase (mkProperName "ingen" (NUtr Masc)) ;
EverythingNP = nameNounPhrase (mkProperName "allting" NNeutr) ;
@@ -115,5 +205,7 @@ concrete StructuralSwe of Structural =
PossessPrep = ss "av" ;
PartPrep = ss "av" ;
AgentPrep = ss "av" ;
-}
}

View File

@@ -0,0 +1,34 @@
concrete TimeSwe of Time = NumeralsSwe **
open Prelude, MorphoSwe, ResourceSwe, ParadigmsSwe in {
lincat
Date = SS ;
Weekday = N ;
Hour = SS ;
Minute = SS ;
Time = SS ;
lin
DayDate day = ss (day.s ! singular ! Indef ! nominative) ;
DayTimeDate day time = ss (day.s ! singular ! Indef ! nominative ++ "klockan" ++ time.s) ;
FormalTime = infixSS "och" ;
PastTime h m = ss (m.s ++ "över" ++ h.s) ;
ToTime h m = ss (m.s ++ "i" ++ h.s) ;
ExactTime h = ss (h.s ++ "prick") ;
NumHour n = n ;
NumMinute n = n ;
monday = regN "måndag" utrum ;
tuesday = regN "tisdag" utrum ;
wednesday = regN "onsdag" utrum ;
thursday = regN "torsdag" utrum ;
friday = regN "fredag" utrum ;
saturday = regN "lördag" utrum ;
sunday = regN "söndag" utrum ;
} ;