forked from GitHub/gf-core
resource = resource-1.0
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
--# -path=.:../scandinavian:../abstract:../../prelude
|
||||
--# -path=.:../scandinavian:../common:../abstract:../../prelude
|
||||
|
||||
--1 Norwegian Lexical Paradigms
|
||||
--
|
||||
-- Aarne Ranta 2003
|
||||
--
|
||||
-- This is an API to the user of the resource grammar
|
||||
-- This is an API for the user of the resource grammar
|
||||
-- for adding lexical items. It gives functions for forming
|
||||
-- expressions of open categories: nouns, adjectives, verbs.
|
||||
--
|
||||
-- It covers the "bokmål" variant of Norwegian.
|
||||
--
|
||||
-- Closed categories (determiners, pronouns, conjunctions) are
|
||||
-- accessed through the resource syntax API, $Structural.gf$.
|
||||
-- accessed through the resource syntax API, $Structural$.
|
||||
--
|
||||
-- The main difference with $MorphoNor.gf$ is that the types
|
||||
-- referred to are compiled resource grammar types. We have moreover
|
||||
@@ -21,13 +22,17 @@
|
||||
-- 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:
|
||||
-- separate module [``IrregNor`` ../../norwegian/IrregNor],
|
||||
-- which covers irregularly inflected verbs.
|
||||
|
||||
resource ParadigmsNor =
|
||||
open (Predef=Predef), Prelude, TypesNor, MorphoNor, SyntaxNor, CategoriesNor in {
|
||||
open
|
||||
(Predef=Predef),
|
||||
Prelude,
|
||||
CommonScand,
|
||||
ResNor,
|
||||
MorphoNor,
|
||||
CatNor in {
|
||||
|
||||
--2 Parameters
|
||||
--
|
||||
@@ -56,7 +61,8 @@ oper
|
||||
|
||||
-- Prepositions used in many-argument functions are just strings.
|
||||
|
||||
Preposition : Type = Str ;
|
||||
mkPrep : Str -> Prep ;
|
||||
noPrep : Prep ; -- empty string
|
||||
|
||||
--2 Nouns
|
||||
|
||||
@@ -65,11 +71,17 @@ oper
|
||||
|
||||
mkN : (dreng,drengen,drenger,drengene : Str) -> N ;
|
||||
|
||||
-- The regular function takes the singular indefinite form and the gender,
|
||||
-- and computes the other forms by a heuristic.
|
||||
-- The regular function takes the singular indefinite form
|
||||
-- and computes the other forms and the gender by a heuristic.
|
||||
-- The heuristic is that nouns ending "e" are feminine like "kvinne",
|
||||
-- all others are masculine like "bil".
|
||||
-- If in doubt, use the $cc$ command to test!
|
||||
|
||||
regN : Str -> Gender -> N ;
|
||||
regN : Str -> N ;
|
||||
|
||||
-- Giving gender manually makes the heuristic more reliable.
|
||||
|
||||
regGenN : Str -> Gender -> N ;
|
||||
|
||||
-- This function takes the singular indefinite and definite forms; the
|
||||
-- gender is computed from the definite form.
|
||||
@@ -85,27 +97,28 @@ oper
|
||||
|
||||
--3 Relational nouns
|
||||
--
|
||||
-- Relational nouns ("daughter of x") need a preposition.
|
||||
-- Relational nouns ("datter til x") need a preposition.
|
||||
|
||||
mkN2 : N -> Preposition -> N2 ;
|
||||
mkN2 : N -> Prep -> 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
|
||||
-- Use the function $mkPrep$ or see the section on prepositions below to
|
||||
-- form other prepositions.
|
||||
--
|
||||
-- Three-place relational nouns ("the connection from x to y") need two prepositions.
|
||||
-- Three-place relational nouns ("forbindelse fra x til y")
|
||||
-- need two prepositions.
|
||||
|
||||
mkN3 : N -> Preposition -> Preposition -> N3 ;
|
||||
mkN3 : N -> Prep -> Prep -> 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
|
||||
-- relational noun (e.g. "den gamle kongen av"). However, $N2$ and
|
||||
-- $N3$ are purely lexical categories. But you can use the $AdvCN$
|
||||
-- and $PrepNP$ constructions to build phrases like this.
|
||||
|
||||
@@ -114,7 +127,8 @@ oper
|
||||
--
|
||||
-- Proper names, with a regular genitive, are formed as follows
|
||||
|
||||
regPN : Str -> Gender -> PN ; -- John, John's
|
||||
regPN : Str -> PN ; -- utrum
|
||||
regGenPN : Str -> Gender -> PN ;
|
||||
|
||||
-- Sometimes you can reuse a common noun as a proper name, e.g. "Bank".
|
||||
|
||||
@@ -143,53 +157,44 @@ oper
|
||||
--
|
||||
-- Two-place adjectives need a preposition for their second argument.
|
||||
|
||||
mkA2 : A -> Preposition -> A2 ;
|
||||
mkA2 : A -> Prep -> A2 ;
|
||||
|
||||
-- Comparison adjectives may need as many as five forms.
|
||||
|
||||
mkADeg : (stor,stort,store,storre,storst : Str) -> ADeg ;
|
||||
mkADeg : (stor,stort,store,storre,storst : Str) -> A ;
|
||||
|
||||
-- The regular pattern works for many adjectives, e.g. those ending
|
||||
-- with "ig".
|
||||
|
||||
regADeg : Str -> ADeg ;
|
||||
regADeg : Str -> A ;
|
||||
|
||||
-- Just the comparison forms can be irregular.
|
||||
|
||||
irregADeg : (tung,tyngre,tyngst : Str) -> ADeg ;
|
||||
irregADeg : (tung,tyngre,tyngst : Str) -> A ;
|
||||
|
||||
-- Sometimes just the positive forms are irregular.
|
||||
|
||||
mk3ADeg : (galen,galet,galna : Str) -> ADeg ;
|
||||
mk2ADeg : (bred,bredt : Str) -> ADeg ;
|
||||
mk3ADeg : (galen,galet,galne : Str) -> A ;
|
||||
mk2ADeg : (bred,bredt : Str) -> A ;
|
||||
|
||||
-- If comparison is formed by "mer, "mest", as in general for
|
||||
-- If comparison is formed by "mer", "mest", as in general for
|
||||
-- long adjective, the following pattern is used:
|
||||
|
||||
compoundADeg : A -> ADeg ; -- -/mer/mest norsk
|
||||
|
||||
-- From a given $ADeg$, it is possible to get back to $A$.
|
||||
|
||||
adegA : ADeg -> A ;
|
||||
compoundA : A -> A ; -- -/mer/mest norsk
|
||||
|
||||
|
||||
--2 Adverbs
|
||||
|
||||
-- Adverbs are not inflected. Most lexical ones have position
|
||||
-- after the verb. Some can be preverbal (e.g. "always").
|
||||
-- after the verb. Some follow the verb (e.g. "altid").
|
||||
|
||||
mkAdv : Str -> Adv ;
|
||||
mkAdV : Str -> AdV ;
|
||||
mkAdv : Str -> Adv ; -- e.g. her
|
||||
mkAdV : Str -> AdV ; -- e.g. altid
|
||||
|
||||
-- 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
|
||||
--
|
||||
@@ -205,30 +210,39 @@ oper
|
||||
|
||||
mk2V : (leve,levde : Str) -> V ;
|
||||
|
||||
-- There is an extensive list of irregular verbs in the module $IrregularSwe$.
|
||||
-- There is an extensive list of irregular verbs in the module $IrregNor$.
|
||||
-- In practice, it is enough to give three forms, as in school books.
|
||||
|
||||
irregV : (drikke, drakk, drukket : Str) -> V ;
|
||||
|
||||
|
||||
--3 Verbs with 'være' as auxiliary
|
||||
--
|
||||
-- By default, the auxiliary is "have". This function changes it to "være".
|
||||
|
||||
vaereV : V -> V ;
|
||||
|
||||
|
||||
--3 Verbs with a particle.
|
||||
--
|
||||
-- The particle, such as in "switch on", is given as a string.
|
||||
-- The particle, such as in "lukke opp", is given as a string.
|
||||
|
||||
partV : V -> Str -> V ;
|
||||
|
||||
--3 Deponent verbs.
|
||||
--
|
||||
-- Some words are used in passive forms only, e.g. "hoppas".
|
||||
-- Some words are used in passive forms only, e.g. "trives", some as
|
||||
-- reflexive e.g. "forestille seg".
|
||||
|
||||
depV : V -> V ;
|
||||
reflV : 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 ;
|
||||
mkV2 : V -> Prep -> V2 ;
|
||||
|
||||
dirV2 : V -> V2 ;
|
||||
|
||||
@@ -237,9 +251,9 @@ oper
|
||||
-- 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,_,_
|
||||
mkV3 : V -> Prep -> Prep -> V3 ; -- snakke, med, om
|
||||
dirV3 : V -> Prep -> V3 ; -- gi,_,til
|
||||
dirdirV3 : V -> V3 ; -- gi,_,_
|
||||
|
||||
--3 Other complement patterns
|
||||
--
|
||||
@@ -248,126 +262,175 @@ oper
|
||||
|
||||
mkV0 : V -> V0 ;
|
||||
mkVS : V -> VS ;
|
||||
mkV2S : V -> Str -> V2S ;
|
||||
mkV2S : V -> Prep -> V2S ;
|
||||
mkVV : V -> VV ;
|
||||
mkV2V : V -> Str -> Str -> V2V ;
|
||||
mkV2V : V -> Prep -> Prep -> V2V ;
|
||||
mkVA : V -> VA ;
|
||||
mkV2A : V -> Str -> V2A ;
|
||||
mkV2A : V -> Prep -> V2A ;
|
||||
mkVQ : V -> VQ ;
|
||||
mkV2Q : V -> Str -> V2Q ;
|
||||
mkV2Q : V -> Prep -> V2Q ;
|
||||
|
||||
mkAS : A -> AS ;
|
||||
mkA2S : A -> Str -> A2S ;
|
||||
mkA2S : A -> Prep -> A2S ;
|
||||
mkAV : A -> AV ;
|
||||
mkA2V : A -> Str -> A2V ;
|
||||
mkA2V : A -> Prep -> A2V ;
|
||||
|
||||
-- Notice: categories $V2S, V2V, V2A, V2Q$ are in v 1.0 treated
|
||||
-- just as synonyms of $V2$, and the second argument is given
|
||||
-- as an adverb. Likewise $AS, A2S, AV, A2V$ are just $A$.
|
||||
-- $V0$ is just $V$.
|
||||
|
||||
V0, V2S, V2V, V2A, V2Q : Type ;
|
||||
AS, A2S, AV, A2V : Type ;
|
||||
|
||||
|
||||
--.
|
||||
--2 Definitions of the paradigms
|
||||
--
|
||||
-- The definitions should not bother the user of the API. So they are
|
||||
-- hidden from the document.
|
||||
--.
|
||||
|
||||
Gender = SyntaxNor.NounGender ;
|
||||
Number = TypesNor.Number ;
|
||||
Case = TypesNor.Case ;
|
||||
masculine = NUtr Masc ;
|
||||
feminine = NUtr NoMasc ;
|
||||
neutrum = NNeutr ;
|
||||
Gender = MorphoNor.Gender ;
|
||||
Number = MorphoNor.Number ;
|
||||
Case = MorphoNor.Case ;
|
||||
masculine = Utr Masc ;
|
||||
feminine = Utr Fem ;
|
||||
neutrum = Neutr ;
|
||||
singular = Sg ;
|
||||
plural = Pl ;
|
||||
nominative = Nom ;
|
||||
genitive = Gen ;
|
||||
|
||||
mkN x y z u = let sb = mkSubstantive x y z u
|
||||
in {s = \\n,b,c => sb.s ! SF n b c ; g = extNGen y ; lock_N = <>} ;
|
||||
regN x g = case last x of {
|
||||
mkN x y z u = mkSubstantive x y z u ** {g = extNGen y ; lock_N = <>} ;
|
||||
|
||||
regN x = regGenN x g where {
|
||||
g = case <x : Str> of {
|
||||
_ + "e" => Utr Fem ;
|
||||
_ => Utr Masc
|
||||
}
|
||||
} ;
|
||||
|
||||
regGenN x g = case last x of {
|
||||
"e" => case g of {
|
||||
NUtr Masc => mkN x (x + "n") (x + "r") (x + "ne") ;
|
||||
NUtr NoMasc => mkN x (init x + "a") (x + "r") (x + "ne") ;
|
||||
NNeutr => mkN x (x + "t") (x + "r") (init x + "a")
|
||||
Utr Masc => mkN x (x + "n") (x + "r") (x + "ne") ;
|
||||
Utr Fem => mkN x (init x + "a") (x + "r") (x + "ne") ;
|
||||
Neutr => mkN x (x + "t") (x + "r") (init x + "a")
|
||||
} ;
|
||||
_ => case g of {
|
||||
NUtr Masc => mkN x (x + "en") (x + "er") (x + "ene") ;
|
||||
NUtr NoMasc => mkN x (x + "a") (x + "er") (x + "ene") ;
|
||||
NNeutr => mkN x (x + "et") (x + "") (x + "a")
|
||||
Utr Masc => mkN x (x + "en") (x + "er") (x + "ene") ;
|
||||
Utr Fem => mkN x (x + "a") (x + "er") (x + "ene") ;
|
||||
Neutr => mkN x (x + "et") (x + "") (x + "a")
|
||||
}
|
||||
} ;
|
||||
|
||||
mk2N x y = case last y of {
|
||||
"n" => regN x masculine ;
|
||||
"a" => regN x feminine ;
|
||||
_ => regN x neutrum
|
||||
"n" => regGenN x masculine ;
|
||||
"a" => regGenN x feminine ;
|
||||
_ => regGenN x neutrum
|
||||
} ;
|
||||
|
||||
|
||||
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} ;
|
||||
mkN2 = \n,p -> n ** {lock_N2 = <> ; c2 = p.s} ;
|
||||
regN2 n g = mkN2 (regGenN n g) (mkPrep "av") ;
|
||||
mkN3 = \n,p,q -> n ** {lock_N3 = <> ; c2 = p.s ; c3 = q.s} ;
|
||||
|
||||
regPN n g = {s = \\c => mkCase n ! c ; g = g} ** {lock_PN = <>} ;
|
||||
regGenPN n g = {s = \\c => mkCase c n ; g = g} ** {lock_PN = <>} ;
|
||||
regPN n = regGenPN n utrum ;
|
||||
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 ;
|
||||
{s = table {NPPoss _ => x ; _ => y} ; a = agrP3 g n ;
|
||||
lock_NP = <>} ;
|
||||
|
||||
mkA a b c = extractPositive (mkAdjective a b c [] []) ** {lock_A = <>} ;
|
||||
mkA a b c = (mkAdject a b c [] []) ** {isComp = False ; lock_A = <>} ;
|
||||
mk2A a b = mkA a b (a + "e") ;
|
||||
regA a = extractPositive (regADeg a) ** {lock_A = <>} ;
|
||||
regA a = (regADeg a) ** {isComp = False ; lock_A = <>} ;
|
||||
|
||||
mkA2 a p = a ** {s2 = p ; lock_A2 = <>} ;
|
||||
mkA2 a p = a ** {c2 = p.s ; lock_A2 = <>} ;
|
||||
|
||||
mkADeg a b c d e = mkAdjective a b c d e ** {lock_ADeg = <>} ;
|
||||
mkADeg a b c d e = mkAdject a b c d e ** {isComp = False ; lock_A = <>} ;
|
||||
regADeg a = case Predef.dp 2 a of {
|
||||
"ig" => aBillig a ;
|
||||
"sk" => aRask a ;
|
||||
_ => aRod a
|
||||
} ** {lock_ADeg = <>} ;
|
||||
irregADeg a b c = mkAdjective a (a + "t") (a + "e") b c ** {lock_ADeg = <>} ;
|
||||
mk3ADeg a b c = mkAdjective a b c (a + "ere") (a + "est") ** {lock_ADeg = <>} ;
|
||||
mk2ADeg a b = mkAdjective a b (a + "e") (a + "ere") (a + "est") ** {lock_ADeg = <>} ;
|
||||
} ** {isComp = False ; lock_A = <>} ;
|
||||
irregADeg a b c = mkAdject a (a + "t") (a + "e") b c **
|
||||
{isComp = False ; lock_A = <>} ;
|
||||
mk3ADeg a b c = mkAdject a b c (a + "ere") (a + "est") **
|
||||
{isComp = False ; lock_A = <>} ;
|
||||
mk2ADeg a b = mkAdject a b (a + "e") (a + "ere") (a + "est") **
|
||||
{isComp = False ; lock_A = <>} ;
|
||||
|
||||
compoundA adj = {s = adj.s ; isComp = True ; lock_A = <>} ;
|
||||
|
||||
mkAdv x = ss x ** {lock_Adv = <>} ;
|
||||
mkAdV x = ss x ** {lock_AdV = <>} ;
|
||||
mkAdA x = ss x ** {lock_AdA = <>} ;
|
||||
|
||||
mkPreposition p = p ;
|
||||
mkPrep p = {s = p ; lock_Prep = <>} ;
|
||||
noPrep = mkPrep [] ;
|
||||
|
||||
mkV a b c d e f = mkVerb a b c d e f ** {s1 = [] ; lock_V = <>} ;
|
||||
mkV a b c d e f = mkVerb6 a b c d e f **
|
||||
{part = [] ; vtype = VAct ; isVaere = False ; lock_V = <>} ;
|
||||
|
||||
regV a = case last a of {
|
||||
"e" => vHusk (init a) ;
|
||||
_ => vBo a
|
||||
} ** {s1 = [] ; lock_V = <>} ;
|
||||
} ** {part = [] ; vtype = VAct ; isVaere = False ; lock_V = <>} ;
|
||||
|
||||
mk2V a b = regVerb a b ** {s1 = [] ; lock_V = <>} ;
|
||||
mk2V a b = regVerb a b ** {part = [] ; vtype = VAct ; isVaere = False ; lock_V = <>} ;
|
||||
|
||||
irregV x y z = irregVerb x y z
|
||||
** {s1 = [] ; lock_V = <>} ;
|
||||
irregV =
|
||||
\drikke,drakk,drukket ->
|
||||
let
|
||||
drikk = case last drikke of {
|
||||
"e" => init drikke ;
|
||||
_ => drikke
|
||||
} ;
|
||||
drikker = case last (init drikke) of {
|
||||
"r" => init drikke ;
|
||||
_ => drikke + "r"
|
||||
}
|
||||
in
|
||||
mkV drikke drikker (drikke + "s") drakk drukket drikk ;
|
||||
|
||||
partV v p = {s = v.s ; s1 = p ; lock_V = <>} ;
|
||||
depV v = deponentVerb v ** {lock_V = <>} ;
|
||||
vaereV v = {
|
||||
s = v.s ;
|
||||
part = [] ;
|
||||
vtype = v.vtype ;
|
||||
isVaere = True ;
|
||||
lock_V = <>
|
||||
} ;
|
||||
|
||||
mkV2 v p = v ** {s = v.s ; s1 = v.s1 ; s2 = p ; lock_V2 = <>} ;
|
||||
dirV2 v = mkV2 v [] ;
|
||||
partV v p = {s = v.s ; part = p ; vtype = v.vtype ; isVaere = v.isVaere ; lock_V = <>} ;
|
||||
depV v = {s = v.s ; part = v.part ; vtype = VPass ; isVaere = False ; lock_V = <>} ;
|
||||
reflV v = {s = v.s ; part = v.part ; vtype = VRefl ; isVaere = False ; lock_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 [] ;
|
||||
mkV2 v p = v ** {c2 = p.s ; lock_V2 = <>} ;
|
||||
dirV2 v = mkV2 v noPrep ;
|
||||
|
||||
mkV3 v p q = v ** {c2 = p.s ; c3 = q.s ; lock_V3 = <>} ;
|
||||
dirV3 v p = mkV3 v noPrep p ;
|
||||
dirdirV3 v = dirV3 v noPrep ;
|
||||
|
||||
mkV0 v = v ** {lock_V0 = <>} ;
|
||||
mkVS v = v ** {lock_VS = <>} ;
|
||||
mkV2S v p = mkV2 v p ** {lock_V2S = <>} ;
|
||||
mkVV v = v ** {isAux = False ; lock_VV = <>} ;
|
||||
mkVV v = v ** {c2 = "å" ; 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 = <>} ;
|
||||
mkAS v = v ** {lock_A = <>} ;
|
||||
mkA2S v p = mkA2 v p ** {lock_A = <>} ;
|
||||
mkAV v = v ** {lock_A = <>} ;
|
||||
mkA2V v p = mkA2 v p ** {lock_A = <>} ;
|
||||
|
||||
V0 : Type = V ;
|
||||
V2S, V2V, V2Q, V2A : Type = V2 ;
|
||||
AS, A2S, AV : Type = A ;
|
||||
A2V : Type = A2 ;
|
||||
|
||||
|
||||
} ;
|
||||
|
||||
Reference in New Issue
Block a user