diff --git a/lib/prelude/Coordination.gf b/lib/prelude/Coordination.gf new file mode 100644 index 000000000..6ed4af791 --- /dev/null +++ b/lib/prelude/Coordination.gf @@ -0,0 +1,105 @@ +resource Coordination = { + +param + ListSize = TwoElem | ManyElem ; + +oper + SS = {s : Str} ; ---- + + ListX = {s1,s2 : Str} ; + + twoStr : (x,y : Str) -> ListX = \x,y -> + {s1 = x ; s2 = y} ; + consStr : Str -> ListX -> Str -> ListX = \comma,xs,x -> + {s1 = xs.s1 ++ comma ++ xs.s2 ; s2 = x } ; + + twoSS : (_,_ : SS) -> ListX = \x,y -> + twoStr x.s y.s ; + consSS : Str -> ListX -> SS -> ListX = \comma,xs,x -> + consStr comma xs x.s ; + + Conjunction : Type = SS ; + ConjunctionDistr : Type = {s1 : Str ; s2 : Str} ; + + conjunctX : Conjunction -> ListX -> Str = \or,xs -> + xs.s1 ++ or.s ++ xs.s2 ; + + conjunctDistrX : ConjunctionDistr -> ListX -> Str = \or,xs -> + or.s1 ++ xs.s1 ++ or.s2 ++ xs.s2 ; + + -- all this lifted to tables + + ListTable : Type -> Type = \P -> {s1,s2 : P => Str} ; + + twoTable : (P : Type) -> (_,_ : {s : P => Str}) -> ListTable P = \_,x,y -> + {s1 = x.s ; s2 = y.s} ; + + consTable : (P : Type) -> Str -> ListTable P -> {s : P => Str} -> ListTable P = + \P,c,xs,x -> + {s1 = table P {o => xs.s1 ! o ++ c ++ xs.s2 ! o} ; s2 = x.s} ; + + conjunctTable : (P : Type) -> Conjunction -> ListTable P -> {s : P => Str} = + \P,or,xs -> + {s = table P {p => xs.s1 ! p ++ or.s ++ xs.s2 ! p}} ; + + conjunctDistrTable : + (P : Type) -> ConjunctionDistr -> ListTable P -> {s : P => Str} = \P,or,xs -> + {s = table P {p => or.s1++ xs.s1 ! p ++ or.s2 ++ xs.s2 ! p}} ; + + -- ... and to two- and three-argument tables: how clumsy! --- + + ListTable2 : Type -> Type -> Type = \P,Q -> + {s1,s2 : P => Q => Str} ; + + twoTable2 : (P,Q : Type) -> (_,_ : {s : P => Q => Str}) -> ListTable2 P Q = + \_,_,x,y -> + {s1 = x.s ; s2 = y.s} ; + + consTable2 : + (P,Q : Type) -> Str -> ListTable2 P Q -> {s : P => Q => Str} -> ListTable2 P Q = + \P,Q,c,xs,x -> + {s1 = table P {p => table Q {q => xs.s1 ! p ! q ++ c ++ xs.s2 ! p! q}} ; + s2 = x.s + } ; + + conjunctTable2 : + (P,Q : Type) -> Conjunction -> ListTable2 P Q -> {s : P => Q => Str} = + \P,Q,or,xs -> + {s = table P {p => table Q {q => xs.s1 ! p ! q ++ or.s ++ xs.s2 ! p ! q}}} ; + + conjunctDistrTable2 : + (P,Q : Type) -> ConjunctionDistr -> ListTable2 P Q -> {s : P => Q => Str} = + \P,Q,or,xs -> + {s = + table P {p => table Q {q => or.s1++ xs.s1 ! p ! q ++ or.s2 ++ xs.s2 ! p ! q}}} ; + + ListTable3 : Type -> Type -> Type -> Type = \P,Q,R -> + {s1,s2 : P => Q => R => Str} ; + + twoTable3 : (P,Q,R : Type) -> (_,_ : {s : P => Q => R => Str}) -> + ListTable3 P Q R = + \_,_,_,x,y -> + {s1 = x.s ; s2 = y.s} ; + + consTable3 : + (P,Q,R : Type) -> Str -> ListTable3 P Q R -> {s : P => Q => R => Str} -> + ListTable3 P Q R = + \P,Q,R,c,xs,x -> + {s1 = \\p,q,r => xs.s1 ! p ! q ! r ++ c ++ xs.s2 ! p ! q ! r ; + s2 = x.s + } ; + + conjunctTable3 : + (P,Q,R : Type) -> Conjunction -> ListTable3 P Q R -> {s : P => Q => R => Str} = + \P,Q,R,or,xs -> + {s = \\p,q,r => xs.s1 ! p ! q ! r ++ or.s ++ xs.s2 ! p ! q ! r} ; + + conjunctDistrTable3 : + (P,Q,R : Type) -> ConjunctionDistr -> ListTable3 P Q R -> + {s : P => Q => R => Str} = + \P,Q,R,or,xs -> + {s = \\p,q,r => or.s1++ xs.s1 ! p ! q ! r ++ or.s2 ++ xs.s2 ! p ! q ! r} ; + + comma = "," ; + +} ; diff --git a/lib/prelude/HTML.gf b/lib/prelude/HTML.gf new file mode 100644 index 000000000..b469b582c --- /dev/null +++ b/lib/prelude/HTML.gf @@ -0,0 +1,8 @@ +resource HTML = open Prelude in { + oper + tag : Str -> Str = \t -> "<" + t + ">" ; + endtag : Str -> Str = \t -> tag ("/" + t) ; + intag : Str -> Str -> Str = \t,s -> tag t ++ s ++ endtag t ; + intagAttr : Str -> Str -> Str -> Str = + \t,a,s -> ("<" + t) ++ (a + ">") ++ s ++ endtag t ; +} diff --git a/lib/prelude/Latex.gf b/lib/prelude/Latex.gf new file mode 100644 index 000000000..2fd2f9ec8 --- /dev/null +++ b/lib/prelude/Latex.gf @@ -0,0 +1,12 @@ +resource Latex = open Prelude in { + oper + command : Str -> Str = \c -> "\\" + c ; + fun1 : Str -> Str -> Str = \f,x -> "\\" + f + "{" ++ x ++ "}" ; + fun2 : Str -> Str -> Str -> Str = + \f,x,y -> "\\" + f + "{" ++ x ++ "}{" ++ y ++ "}" ; + begin : Str -> Str = \e -> "\\begin{" + e + "}" ; + end : Str -> Str = \e -> "\\end{" + e + "}" ; + inEnv : Str -> Str -> Str = \e,s -> begin e ++ s ++ end e ; +} + + diff --git a/lib/prelude/Precedence.gf b/lib/prelude/Precedence.gf new file mode 100644 index 000000000..1e0b1a77c --- /dev/null +++ b/lib/prelude/Precedence.gf @@ -0,0 +1,117 @@ +-- operations for precedence-dependent strings. +-- five levels: +-- p4 (constants), p3 (applications), p2 (products), p1 (sums), p0 (arrows) + +resource Precedence = open Prelude in { + +param +Prec = p4 | p3 | p2 | p1 | p0 ; + +lintype +PrecTerm = Prec => Str ; + +oper +pss : PrecTerm -> {s : PrecTerm} = \s -> {s = s} ; + + +-- change this if you want some other type of parentheses +mkParenth : Str -> Str = \str -> "(" ++ str ++ ")" ; + +-- define ordering of precedences +nextPrec : Prec => Prec = + table {p0 => p1 ; p1 => p2 ; p2 => p3 ; _ => p4} ; +prevPrec : Prec => Prec = + table {p4 => p3 ; p3 => p2 ; p2 => p1 ; _ => p0} ; + +mkPrec : Str -> Prec => Prec => Str = \str -> + table { + p4 => table { -- use the term of precedence p4... + _ => str} ; -- ...always without parentheses + p3 => table { -- use the term of precedence p3... + p4 => mkParenth str ; -- ...in parentheses if p4 is required... + _ => str} ; -- ...otherwise without parentheses + p2 => table { + p4 => mkParenth str ; + p3 => mkParenth str ; + _ => str} ; + p1 => table { + p1 => str ; + p0 => str ; + _ => mkParenth str} ; + p0 => table { + p0 => str ; + _ => mkParenth str} + } ; + +-- make a string into a constant, of precedence p4 +mkConst : Str -> PrecTerm = + \f -> + mkPrec f ! p4 ; + +-- make a string into a 1/2/3 -place prefix operator, of precedence p3 +mkFun1 : Str -> PrecTerm -> PrecTerm = + \f -> \x -> + table {k => mkPrec (f ++ x ! p4) ! p3 ! k} ; +mkFun2 : Str -> PrecTerm -> PrecTerm -> PrecTerm = + \f -> \x -> \y -> + table {k => mkPrec (f ++ x ! p4 ++ y ! p4) ! p3 ! k} ; +mkFun3 : Str -> PrecTerm -> PrecTerm -> PrecTerm -> PrecTerm = + \f -> \x -> \y -> \z -> + table {k => mkPrec (f ++ x ! p4 ++ y ! p4 ++ z ! p4) ! p3 ! k} ; + +-- make a string into a non/left/right -associative infix operator, of precedence p +mkInfix : Str -> Prec -> PrecTerm -> PrecTerm -> PrecTerm = + \f -> \p -> \x -> \y -> + table {k => mkPrec (x ! (nextPrec ! p) ++ f ++ y ! (nextPrec ! p)) ! p ! k} ; +mkInfixL : Str -> Prec -> PrecTerm -> PrecTerm -> PrecTerm = + \f -> \p -> \x -> \y -> + table {k => mkPrec (x ! p ++ f ++ y ! (nextPrec ! p)) ! p ! k} ; +mkInfixR : Str -> Prec -> PrecTerm -> PrecTerm -> PrecTerm = + \f -> \p -> \x -> \y -> + table {k => mkPrec (x ! (nextPrec ! p) ++ f ++ y ! p) ! p ! k} ; + +----------------------------------------------------------- + +-- alternative: +-- precedence as inherent feature + +lintype TermWithPrec = {s : Str ; p : Prec} ; + +oper +mkpPrec : Str -> Prec -> TermWithPrec = + \f -> \p -> + {s = f ; p = p} ; + +usePrec : TermWithPrec -> Prec -> Str = + \x -> \p -> + mkPrec x.s ! x.p ! p ; + +-- make a string into a constant, of precedence p4 +mkpConst : Str -> TermWithPrec = + \f -> + mkpPrec f p4 ; + +-- make a string into a 1/2/3 -place prefix operator, of precedence p3 +mkpFun1 : Str -> TermWithPrec -> TermWithPrec = + \f -> \x -> + mkpPrec (f ++ usePrec x p4) p3 ; + +mkpFun2 : Str -> TermWithPrec -> TermWithPrec -> TermWithPrec = + \f -> \x -> \y -> + mkpPrec (f ++ usePrec x p4 ++ usePrec y p4) p3 ; + +mkpFun3 : Str -> TermWithPrec -> TermWithPrec -> TermWithPrec -> TermWithPrec = + \f -> \x -> \y -> \z -> + mkpPrec (f ++ usePrec x p4 ++ usePrec y p4 ++ usePrec z p4) p3 ; + +-- make a string a into non/left/right -associative infix operator, of precedence p +mkpInfix : Str -> Prec -> TermWithPrec -> TermWithPrec -> TermWithPrec = + \f -> \p -> \x -> \y -> + mkpPrec (usePrec x (nextPrec ! p) ++ f ++ usePrec y (nextPrec ! p)) p ; +mkpInfixL : Str -> Prec -> TermWithPrec -> TermWithPrec -> TermWithPrec = + \f -> \p -> \x -> \y -> + mkpPrec (usePrec x p ++ f ++ usePrec y (nextPrec ! p)) p ; +mkpInfixR : Str -> Prec -> TermWithPrec -> TermWithPrec -> TermWithPrec = + \f -> \p -> \x -> \y -> + mkpPrec (usePrec x (nextPrec ! p) ++ f ++ usePrec y p) p ; +} ; \ No newline at end of file diff --git a/lib/prelude/Predef.gf b/lib/prelude/Predef.gf new file mode 100644 index 000000000..866ce5b6a --- /dev/null +++ b/lib/prelude/Predef.gf @@ -0,0 +1,27 @@ +-- predefined functions for concrete syntax, defined in AppPredefined.hs + +resource Predef = { + + -- this type is for internal use only + param PBool = PTrue | PFalse ; + + -- these operations have their proper definitions in AppPredefined.hs + + oper Int : Type = variants {} ; -- the type of integers + oper Ints : Int -> Type = variants {} ; -- the type of integers from 0 to n + + oper length : Tok -> Int = variants {} ; -- length of string + oper drop : Int -> Tok -> Tok = variants {} ; -- drop prefix of length + oper take : Int -> Tok -> Tok = variants {} ; -- take prefix of length + oper tk : Int -> Tok -> Tok = variants {} ; -- drop suffix of length + oper dp : Int -> Tok -> Tok = variants {} ; -- take suffix of length + oper eqInt : Int -> Int -> PBool = variants {} ; -- test if equal integers + oper lessInt: Int -> Int -> PBool = variants {} ; -- test order of integers + oper plus : Int -> Int -> Int = variants {} ; -- add integers + oper eqStr : Tok -> Tok -> PBool = variants {} ; -- test if equal strings + oper occur : Tok -> Tok -> PBool = variants {} ; -- test if occurs as substring + oper show : (P : Type) -> P -> Tok = variants {} ; -- convert param to string + oper read : (P : Type) -> Tok -> P = variants {} ; -- convert string to param + + } ; + diff --git a/lib/prelude/PredefAbs.gf b/lib/prelude/PredefAbs.gf new file mode 100644 index 000000000..2779bcd58 --- /dev/null +++ b/lib/prelude/PredefAbs.gf @@ -0,0 +1,4 @@ +abstract PredefAbs = { + cat Int ; String ; +} ; + diff --git a/lib/prelude/Prelude.gf b/lib/prelude/Prelude.gf new file mode 100644 index 000000000..c84fa6188 --- /dev/null +++ b/lib/prelude/Prelude.gf @@ -0,0 +1,100 @@ +-- language-independent prelude facilities + +resource Prelude = open (Predef=Predef) in { + +oper +-- to construct records and tables + SS : Type = {s : Str} ; + ss : Str -> SS = \s -> {s = s} ; + ss2 : (_,_ : Str) -> SS = \x,y -> ss (x ++ y) ; + ss3 : (_,_ ,_: Str) -> SS = \x,y,z -> ss (x ++ y ++ z) ; + + cc2 : (_,_ : SS) -> SS = \x,y -> ss (x.s ++ y.s) ; + + SS1 : Type -> Type = \P -> {s : P => Str} ; + ss1 : (A : Type) -> Str -> SS1 A = \A,s -> {s = table {_ => s}} ; + + SP1 : Type -> Type = \P -> {s : Str ; p : P} ; + sp1 : (A : Type) -> Str -> A -> SP1 A = \_,s,a -> {s = s ; p = a} ; + + nonExist : Str = variants {} ; + + optStr : Str -> Str = \s -> variants {s ; []} ; + + constTable : (A,B : Type) -> B -> A => B = \_,_,b -> \\_ => b ; + constStr : (A : Type) -> Str -> A => Str = \A -> constTable A Str ; + + infixSS : Str -> SS -> SS -> SS = \f,x,y -> ss (x.s ++ f ++ y.s) ; + prefixSS : Str -> SS -> SS = \f,x -> ss (f ++ x.s) ; + postfixSS : Str -> SS -> SS = \f,x -> ss (x.s ++ f) ; + embedSS : Str -> Str -> SS -> SS = \f,g,x -> ss (f ++ x.s ++ g) ; + + id : (A : Type) -> A -> A ; + +-- discontinuous + SD2 = {s1,s2 : Str} ; + sd2 : (_,_ : Str) -> SD2 = \x,y -> {s1 = x ; s2 = y} ; + +-- parentheses + paren : Str -> Str = \s -> "(" ++ s ++ ")" ; + parenss : SS -> SS = \s -> ss (paren s.s) ; + +-- free order between two strings + bothWays : Str -> Str -> Str = \x,y -> variants {x ++ y ; y ++ x} ; + +-- parametric order between two strings + preOrPost : Bool -> Str -> Str -> Str = \pr,x,y -> + if_then_Str pr (x ++ y) (y ++ x) ; + +-- Booleans + + param Bool = True | False ; + +oper + if_then_else : (A : Type) -> Bool -> A -> A -> A = \_,c,d,e -> + case c of { + True => d ; ---- should not need to qualify + False => e + } ; + + andB : (_,_ : Bool) -> Bool = \a,b -> if_then_else Bool a b False ; + orB : (_,_ : Bool) -> Bool = \a,b -> if_then_else Bool a True b ; + notB : Bool -> Bool = \a -> if_then_else Bool a False True ; + + if_then_Str : Bool -> Str -> Str -> Str = if_then_else Str ; + +-- zero, one, two, or more (elements in a list etc) + +param + ENumber = E0 | E1 | E2 | Emore ; + +oper + eNext : ENumber -> ENumber = \e -> case e of { + E0 => E1 ; E1 => E2 ; _ => Emore} ; + + -- these were defined in Predef before + isNil : Tok -> Bool = \b -> pbool2bool (Predef.eqStr [] b) ; + + ifTok : (A : Type) -> Tok -> Tok -> A -> A -> A = \A,t,u,a,b -> + case Predef.eqStr t u of {Predef.PTrue => a ; Predef.PFalse => b} ; + + -- so we need an interface + pbool2bool : Predef.PBool -> Bool = \b -> case b of { + Predef.PFalse => False ; Predef.PTrue => True + } ; + + init : Tok -> Tok = Predef.tk 1 ; + last : Tok -> Tok = Predef.dp 1 ; + + +-- bind together two tokens in the lexer, either obligatorily or optionally + + oper + glue : Str -> Str -> Str = \x,y -> x ++ BIND ++ y ; + glueOpt : Str -> Str -> Str = \x,y -> variants {glue x y ; x ++ y} ; + noglueOpt : Str -> Str -> Str = \x,y -> variants {x ++ y ; glue x y} ; + +-- these should be hidden, and never changed since it's hardcoded in (un)lexers + BIND : Str = "&+" ; + PARA : Str = "&-" ; +} ; diff --git a/lib/resource-0.6/english/SyntaxEng.gf b/lib/resource-0.6/english/SyntaxEng.gf index 408acd3cd..2c67bf265 100644 --- a/lib/resource-0.6/english/SyntaxEng.gf +++ b/lib/resource-0.6/english/SyntaxEng.gf @@ -291,6 +291,70 @@ oper -- --3 Verb phrases -- +-- The syntactic verb phrase form type, which includes compound tenses, +-- is defined as follows. + + param + + Anteriority = Simul | Anter ; + + Tense = Pres | Pas | Fut ; + + VerbForm = + VInd Tense Anteriority Number Person + | VCond Anteriority + | VInf Anteriority + | VImp ; + +-- This is how the syntactic verb phrase forms are realized as +-- inflectional forms of verbs. + + oper + +{- + VGrp : Type = {s,s2 : Str ; isAux : Bool} + + inflVerb : + VerbP3 -> Bool -> VerbForm -> VGrp = + \verb,b,v -> let + simple : Bool -> Str -> VGrp = \s -> {s = s ; s2 = [] ; isAux = False} ; + s = if_then_Str b + (walk.s ! v ++ walk.s1) + (contractNot (verbP3Do.s ! v)) ; + +s ; s2 = [] ; isAux = False} ; + + in case v of { + VInd Pres Simul n p => simple b (indicVerb verb p n) ; + VInd Pas Simul n p => simple b (verb.s ! Past n) ; + VInd Fut Simul n p => compos (will b) infin ; + VInd t Anter n p => compos (have b t) pastp ; + VCond a => compos (would b) infin ; + + + + indicVerb : VerbP3 -> Person -> Number -> Str = \v,p,n -> case n of { + Sg => v.s ! Indic p ; + Pl => v.s ! Indic P2 + } ; + predVerb : Verb -> VerbGroup = \walk -> + {s = \\b,v => if_then_Str b + (walk.s ! v ++ walk.s1) + (contractNot (verbP3Do.s ! v)) ; + s2 = \\b,_ => if_then_Str b + [] + (walk.s ! InfImp ++ walk.s1) ; + isAuxT = False ; + isAuxF = True + } ; + VerbGrp = { + s : Bool => VerbForm => Str ; + s2 : Bool => Number => Str ; + isAuxT : Bool ; + isAuxF : Bool + } ; +-} + -- Verb phrases are discontinuous: the two parts of a verb phrase are -- (s) an inflected verb, (s2) infinitive and complement. -- For instance: "doesn't" - "walk" ; "isn't" - "old" ; "is" - "a man" diff --git a/lib/resource/abstract/Categories.gf b/lib/resource/abstract/Categories.gf new file mode 100644 index 000000000..7c1771aa3 --- /dev/null +++ b/lib/resource/abstract/Categories.gf @@ -0,0 +1,154 @@ +--1 Abstract Syntax Categories for Multilingual Resource Grammar +-- +-- Aarne Ranta 2002 -- 2004 +-- +-- Although concrete syntax differs a lot between different languages, +-- many structures can be treated as common, on the level +-- of abstraction that GF provides. +-- What we will present in the following is a linguistically oriented abstract +-- syntax that has been successfully defined for the following languages: +-- +--* $Eng$lish +--* $Fin$nish +--* $Fre$nch +--* $Ger$man +--* $Ita$lian +--* $Rus$sian +--* $Swe$dish +-- +-- The three-letter prefixes are used in file names all over the resource +-- grammar library; we refer to them commonly as $X$ below. +--! +-- The grammar has been applied to define language +-- fragments on technical or near-to-technical domains: database queries, +-- video recorder dialogue systems, software specifications, and a +-- health-related phrase book. Each new application helped to identify some +-- missing structures in the resource and suggested some additions, but the +-- number of required additions was usually small. +-- +-- To use the resource in applications, you need the following +-- $cat$ and $fun$ rules in $oper$ form, completed by taking the +-- $lincat$ and $lin$ judgements of a particular language. This is done +-- by using, instead of this module, the $reuse$ module which has the name +-- $ResourceX$. It is located in the subdirectory +-- $lib/resource/lang$ where $lang$ is the full name of the language. + + +abstract Categories = PredefAbs ** { +--! +--2 Categories +-- +-- The categories of this resource grammar are mostly 'standard' categories +-- of linguistics. Their is no claim that they correspond to semantic categories +-- definable in type theory: to define such correspondences is the business +-- of applications grammars. In general, the correspondence between linguistic +-- and semantic categories is many-to-many. +-- +-- Categories that may look special are $A2$, $N2$, and $V2$. They are all +-- instances of endowing another category with a complement, which can be either +-- a direct object (whose case may vary) or a prepositional phrase. Prepositional +-- phrases that are not complements belong to the category +-- $Adv$ of adverbs. +-- +-- In each group below, some categories are *lexical* in the sense of only +-- containing atomic elements. These elements are not necessarily expressed by +-- one word in all languages; the essential thing is that they have no +-- constituents. Thus they have no productions in this part of the +-- resource grammar. The $ParadigmsX$ grammars provide ways of defining +-- lexical elements. +-- +-- Lexical categories are listed before other categories +-- in each group and divided by an empty line. + +--! +--3 Nouns and noun phrases +-- + +cat + N ; -- simple common noun, e.g. "car" + CN ; -- common noun phrase, e.g. "red car", "car that John owns" + N2 ; -- function word, e.g. "mother (of)" + N3 ; -- two-place function, e.g. "flight (from) (to)" + + PN ; -- proper name, e.g. "John", "New York" + NP ; -- noun phrase, e.g. "John", "all cars", "you" + Det ; -- determiner, e.g. "every", "all" + Num ; -- numeral, e.g. "three", "879" + +--! +--3 Adjectives and adjectival phrases +-- + + A1 ; -- one-place adjective, e.g. "even" + A2 ; -- two-place adjective, e.g. "divisible (by)" + ADeg ; -- degree adjective, e.g. "big/bigger/biggest" + + AP ; -- adjective phrase, e.g. "divisible by two", "bigger than John" + +-- The difference between $A1$ and $ADeg$ is that the former has no +-- comparison forms. + +--! +--3 Verbs and verb phrases +-- + + V ; -- one-place verb, e.g. "walk" + V2 ; -- two-place verb, e.g. "love", "wait (for)", "switch on" + V3 ; -- three-place verb, e.g. "give", "prefer (stg) (to stg)" + VS ; -- sentence-compl. verb, e.g. "say", "prove" + VV ; -- verb-compl. verb, e.g. "can", "want" + + VG ; -- verbal group, e.g. "switch the light on" + VP ; -- verb phrase, e.g. "switch the light on", "don't run" + +--! +--3 Adverbs and prepositions/cases +-- + + Adv ; -- adverbial e.g. "now", "in the house" + AdA ; -- ad-adjective e.g. "very" + AdS ; -- sentence adverbial e.g. "therefore", "otherwise" + PP ; -- prepositional phrase e.g. "in London" + Prep ; -- pre/postposition, case e.g. "after", Adessive + +--! +--3 Sentences and relative clauses +-- +-- This group has no lexical categories. + + S ; -- sentence (fixed tense) e.g. "John walks", "John walked" + Cl ; -- clause (variable tense) e.g. "John walks"/"John walked" + Slash ; -- sentence without NP, e.g. "John waits for (...)" + RP ; -- relative pronoun, e.g. "which", "the mother of whom" + RC ; -- relative clause, e.g. "who walks", "that I wait for" + +--! +--3 Questions and imperatives +-- +-- This group has no lexical categories. + + IP ; -- interrogative pronoun, e.g. "who", "whose mother", "which yellow car" + IAdv ; -- interrogative adverb., e.g. "when", "why" + Qu ; -- question, e.g. "who walks" + Imp ; -- imperative, e.g. "walk!" + +--! +--3 Coordination and subordination +-- + + Conj ; -- conjunction, e.g. "and" + ConjD ; -- distributed conj. e.g. "both - and" + Subj ; -- subjunction, e.g. "if", "when" + + ListS ; -- list of sentences + ListAP ; -- list of adjectival phrases + ListNP ; -- list of noun phrases + +--! +--3 Complete utterances +-- +-- This group has no lexical categories. + + Phr ; -- full phrase, e.g. "John walks.","Who walks?", "Wait for me!" + Text ; -- sequence of phrases e.g. "One is odd. Therefore, two is even." +} diff --git a/lib/resource/abstract/Numerals.gf b/lib/resource/abstract/Numerals.gf new file mode 100644 index 000000000..b725070dc --- /dev/null +++ b/lib/resource/abstract/Numerals.gf @@ -0,0 +1,34 @@ +-- numerals from 1 to 999999 in decimal notation + +abstract Numerals = { + +flags startcat=Numeral ; + +cat + Numeral ; -- 0.. + Digit ; -- 2..9 + Sub10 ; -- 1..9 + Sub100 ; -- 1..99 + Sub1000 ; -- 1..999 + Sub1000000 ; -- 1..999999 + +fun + num : Sub1000000 -> Numeral ; + + n2, n3, n4, n5, n6, n7, n8, n9 : Digit ; + + pot01 : Sub10 ; -- 1 + pot0 : Digit -> Sub10 ; -- d * 1 + pot110 : Sub100 ; -- 10 + pot111 : Sub100 ; -- 11 + pot1to19 : Digit -> Sub100 ; -- 10 + d + pot0as1 : Sub10 -> Sub100 ; -- coercion of 1..9 + pot1 : Digit -> Sub100 ; -- d * 10 + pot1plus : Digit -> Sub10 -> Sub100 ; -- d * 10 + n + pot1as2 : Sub100 -> Sub1000 ; -- coercion of 1..99 + pot2 : Sub10 -> Sub1000 ; -- m * 100 + pot2plus : Sub10 -> Sub100 -> Sub1000 ; -- m * 100 + n + pot2as3 : Sub1000 -> Sub1000000 ; -- coercion of 1..999 + pot3 : Sub1000 -> Sub1000000 ; -- m * 1000 + pot3plus : Sub1000 -> Sub1000 -> Sub1000000 ; -- m * 1000 + n +} diff --git a/lib/resource/abstract/Rules.gf b/lib/resource/abstract/Rules.gf new file mode 100644 index 000000000..f32e9d08a --- /dev/null +++ b/lib/resource/abstract/Rules.gf @@ -0,0 +1,195 @@ +--! +--2 Rules +-- +-- This set of rules is minimal, in the sense of defining the simplest combinations +-- of categories and not having redundant rules. +-- When the resource grammar is used as a library, it will often be useful to +-- access it through an intermediate library that defines more rules as +-- 'macros' for combinations of the ones below. + +abstract Rules = Categories, Numerals ** { + +--! +--3 Nouns and noun phrases +-- + +fun + UseN : N -> CN ; -- "car" + UsePN : PN -> NP ; -- "John" + + SymbPN : String -> PN ; -- "x" + SymbCN : CN -> String -> CN ; -- "number x" + + IndefOneNP : CN -> NP ; -- "a car", "cars" + IndefNumNP : Num -> CN -> NP ; -- "houses", "86 houses" + DefOneNP : CN -> NP ; -- "the car" + DefNumNP : Num -> CN -> NP ; -- "the cars", "the 86 cars" + + DetNP : Det -> CN -> NP ; -- "every car" + MassNP : CN -> NP ; -- "wine" + + AppN2 : N2 -> NP -> CN ; -- "successor of zero" + AppN3 : N3 -> NP -> N2 ; -- "flight from Paris" + UseN2 : N2 -> CN ; -- "successor" + + ModAdj : AP -> CN -> CN ; -- "red car" + CNthatS : CN -> S -> CN ; -- "idea that the Earth is flat" + + ModGenOne : NP -> CN -> NP ; -- "John's car" + ModGenNum : Num -> NP -> CN -> NP ; -- "John's cars", "John's 86 cars" + + UseInt : Int -> Num ; -- "32" --- assumes i > 1 + UseNumeral : Numeral -> Num ; -- "thirty-two" --- assumes i > 1 + NoNum : Num ; -- no numeral modifier + +--! +--3 Adjectives and adjectival phrases +-- + + UseA1 : A1 -> AP ; -- "red" + ComplA2 : A2 -> NP -> AP ; -- "divisible by two" + + PositADeg : ADeg -> AP ; -- "old" + ComparADeg : ADeg -> NP -> AP ; -- "older than John" + SuperlADeg : ADeg -> AP ; -- "the oldest" + +--! +--3 Verbs and verb phrases +-- +-- The principal way of forming sentences ($S$) is by combining a noun phrase +-- with a verb phrase (the $PredVP$ rule below). In addition to this, verb +-- phrases have uses in relative clauses and questions. Verb phrases already +-- have (or have not) a negation, but they are formed from verbal groups +-- ($VG$), which have both positive and negative forms. + + PredV : V -> VG ; -- "walk", "doesn't walk" + PredPassV : V -> VG ; -- "is seen", "is not seen" + PredV2 : V2 -> NP -> VG ; -- "sees John", "doesn't see John" + PredV3 : V3 -> NP -> NP -> VG ; -- "prefers wine to beer" + PredVS : VS -> S -> VG ; -- "says that I run", "doesn't say..." + PredVV : VV -> VG -> VG ; -- "can run", "can't run", "tries to run" + + PredNP : NP -> VG ; -- "is John", "is not John" + PredAdv : Adv -> VG ; -- "is everywhere", "is not in France" + PredAP : AP -> VG ; -- "is old", "isn't old" + PredCN : CN -> VG ; -- "is a man", "isn't a man" + VTrans : V2 -> V ; -- "loves" + + PosVG,NegVG : VG -> VP ; -- + + PredVG : NP -> VG -> Cl ; -- preserves all pol/tense variation + +--! +--3 Adverbs +-- +-- Here is how complex adverbs can be formed and used. + + AdjAdv : AP -> Adv ; -- "freely", "more consciously than you" + AdvPP : PP -> Adv ; -- "in London", "after the war" + PrepNP : Prep -> NP -> PP ; -- "in London", "after the war" + + AdvVP : VP -> Adv -> VP ; -- "always walks", "walks in the park" + AdvCN : CN -> PP -> CN ; -- "house in London" + AdvAP : AdA -> AP -> AP ; -- "very good" + +--! +--3 Sentences and relative clauses +-- + + PredVP : NP -> VP -> S ; -- "John walks" + PosSlashV2,NegSlashV2 : NP -> V2 -> Slash ; -- "John sees", "John doesn't see" + OneVP : VP -> S ; -- "one walks" + ThereNP : NP -> S ; -- "there is a bar","there are 86 bars" + + IdRP : RP ; -- "which" + FunRP : N2 -> RP -> RP ; -- "the successor of which" + RelVP : RP -> VP -> RC ; -- "who walks", "who doesn't walk" + RelSlash : RP -> Slash -> RC ; -- "that I wait for"/"for which I wait" + ModRC : CN -> RC -> CN ; -- "man who walks" + RelSuch : S -> RC ; -- "such that it is even" + +--! +--3 Questions and imperatives +-- + + WhoOne, WhoMany : IP ; -- "who (is)", "who (are)" + WhatOne, WhatMany : IP ; -- "what (is)", "what (are)" + FunIP : N2 -> IP -> IP ; -- "the mother of whom" + NounIPOne, NounIPMany : CN -> IP ; -- "which car", "which cars" + + QuestVP : NP -> VP -> Qu ; -- "does John walk"; "doesn't John walk" + IntVP : IP -> VP -> Qu ; -- "who walks" + IntSlash : IP -> Slash -> Qu ; -- "whom does John see" + QuestAdv : IAdv -> NP -> VP -> Qu ; -- "why do you walk" + IsThereNP : NP -> Qu ; -- "is there a bar", "are there (86) bars" + + ImperVP : VP -> Imp ; -- "be a man" + + IndicPhrase : S -> Phr ; -- "I walk." + QuestPhrase : Qu -> Phr ; -- "Do I walk?" + ImperOne, ImperMany : Imp -> Phr ; -- "Be a man!", "Be men!" + + PrepS : PP -> AdS ; -- "in Sweden, (there are bears)" + AdvS : AdS -> S -> Phr ; -- "Therefore, 2 is prime." + +--! +--3 Coordination +-- +-- We consider "n"-ary coordination, with "n" > 1. To this end, we have introduced +-- a *list category* $ListX$ for each category $X$ whose expressions we want to +-- conjoin. Each list category has two constructors, the base case being $TwoX$. + +-- We have not defined coordination of all possible categories here, +-- since it can be tricky in many languages. For instance, $VP$ coordination +-- is linguistically problematic in German because $VP$ is a discontinuous +-- category. + + ConjS : Conj -> ListS -> S ; -- "John walks and Mary runs" + ConjAP : Conj -> ListAP -> AP ; -- "even and prime" + ConjNP : Conj -> ListNP -> NP ; -- "John or Mary" + + ConjDS : ConjD -> ListS -> S ; -- "either John walks or Mary runs" + ConjDAP : ConjD -> ListAP -> AP ; -- "both even and prime" + ConjDNP : ConjD -> ListNP -> NP ; -- "either John or Mary" + + TwoS : S -> S -> ListS ; + ConsS : ListS -> S -> ListS ; + + TwoAP : AP -> AP -> ListAP ; + ConsAP : ListAP -> AP -> ListAP ; + + TwoNP : NP -> NP -> ListNP ; + ConsNP : ListNP -> NP -> ListNP ; + +--! +--3 Subordination +-- +-- Subjunctions are different from conjunctions, but form +-- a uniform category among themselves. + + SubjS : Subj -> S -> S -> S ; -- "if 2 is odd, 3 is even" + SubjImper : Subj -> S -> Imp -> Imp ; -- "if it is hot, use a glove!" + SubjQu : Subj -> S -> Qu -> Qu ; -- "if you are new, who are you?" + SubjVP : VP -> Subj -> S -> VP ; -- "(a man who) sings when he runs" + +--! +--2 One-word utterances +-- +-- These are, more generally, *one-phrase utterances*. The list below +-- is very incomplete. + + PhrNP : NP -> Phr ; -- "Some man.", "John." + PhrOneCN, PhrManyCN : CN -> Phr ; -- "A car.", "Cars." + PhrIP : IAdv -> Phr ; -- "Who?" + PhrIAdv : IAdv -> Phr ; -- "Why?" + +--! +--2 Text formation +-- +-- A text is a sequence of phrases. It is defined like a non-empty list. + + OnePhr : Phr -> Text ; + ConsPhr : Phr -> Text -> Text ; + +} ; + diff --git a/lib/resource/abstract/Structural.gf b/lib/resource/abstract/Structural.gf new file mode 100644 index 000000000..a07634bde --- /dev/null +++ b/lib/resource/abstract/Structural.gf @@ -0,0 +1,91 @@ +--1 GF Resource Grammar API for Structural Words +-- +-- AR 21/11/2003 +-- +-- Here we have some words belonging to closed classes and appearing +-- in all languages we have considered. +-- Sometimes they are not really meaningful, e.g. $TheyNP$ in French +-- should really be replaced by masculine and feminine variants. + +abstract Structural = Categories ** { + +fun + +--! +--2 Determiners and noun phrases +-- +-- Many plural determiners can take a numeral modifier. So can the plural +-- pronouns "we" and "you". + + EveryDet, WhichDet, AllMassDet, -- every, sg which, sg all + SomeDet, AnyDet, NoDet, -- sg some, any, no + MostDet, MostsDet, ManyDet, MuchDet : Det ; -- sg most, pl most, many, much + ThisDet, ThatDet : Det ; -- this, that + + AllNumDet, WhichNumDet, -- pl all, which (86) + SomeNumDet, AnyNumDet, NoNumDet, -- pl some, any, no + TheseNumDet, ThoseNumDet : Num -> Det ; -- these, those (86) + + ThisNP, ThatNP : NP ; -- this, that + TheseNumNP, ThoseNumNP : Num -> NP ; -- these, those (86) + INP, ThouNP, HeNP, SheNP, ItNP : NP ; -- personal pronouns in singular + WeNumNP, YeNumNP : Num -> NP ; -- these pronouns can take numeral + TheyNP : NP ; YouNP : NP ; -- they, the polite you + + EverybodyNP, SomebodyNP, NobodyNP, -- everybody, somebody, nobody + EverythingNP, SomethingNP, NothingNP : NP ; -- everything, something, nothing + +--! +--2 Auxiliary verbs +-- +-- Depending on language, all, some, or none of there verbs belong to +-- a separate class of *auxiliary* verbs. The list is incomplete. + + CanVV, CanKnowVV, MustVV : VV ; -- can (pouvoir,savoir), must + WantVV : VV ; -- want (to do) + +--! +--2 Adverbials +-- + + WhenIAdv,WhereIAdv,WhyIAdv,HowIAdv : IAdv ; -- when, where, why, how + EverywhereNP, SomewhereNP,NowhereNP : Adv ; -- everywhere, somewhere, nowhere + VeryAdv, TooAdv : AdA ; -- very, too + AlmostAdv, QuiteAdv : AdA ; -- almost, quite + OtherwiseAdv, ThereforeAdv : AdS ; -- therefore, otherwise + +--! +--2 Conjunctions and subjunctions +-- + + AndConj, OrConj : Conj ; -- and, or + BothAnd, EitherOr, NeitherNor : ConjD ; -- both-and, either-or, neither-nor + IfSubj, WhenSubj, AlthoughSubj : Subj ; -- if, when, although + +--! +--2 Prepositions +-- +-- We have chosen a set of semantic relations expressible +-- by prepositions in some languages, by cases or postpositions in +-- others. Complement uses of prepositions are not included, and +-- should be treated by the use of many-place verbs, adjectives, and +-- functions. + + InPrep, OnPrep, ToPrep, FromPrep, -- spatial relations + ThroughPrep, AbovePrep, UnderPrep, + InFrontPrep, BehindPrep, BetweenPrep : Prep ; + BeforePrep, DuringPrep, AfterPrep : Prep ; -- temporal relations + WithPrep, WithoutPrep, ByMeansPrep : Prep ; -- some other relations + PossessPrep : Prep ; -- possessive/genitive + PartPrep : Prep ; -- partitive "of" ("bottle of wine") + AgentPrep : Prep ; -- agent "by" in passive constructions + + +--! +--2 Affirmation and negation +-- +-- The negative-positive (French "si", German "doch") is missing. + + PhrYes, PhrNo : Phr ; -- yes, no + +} diff --git a/lib/resource/abstract/TestResource.gf b/lib/resource/abstract/TestResource.gf new file mode 100644 index 000000000..55dda45e0 --- /dev/null +++ b/lib/resource/abstract/TestResource.gf @@ -0,0 +1,18 @@ +abstract TestResource = Rules, Structural ** { + +-- a random sample of lexicon to test resource grammar with + +fun + Big, Happy, Small, Old, Young : ADeg ; + American, Finnish : A1 ; + Married : A2 ; + Man, Woman, Car, House, Light, Bar, Bottle, Wine : N ; + Walk, Run : V ; + Send, Wait, Love, Drink, SwitchOn, SwitchOff : V2 ; + Give, Prefer : V3 ; + Say, Prove : VS ; + Mother, Uncle : N2 ; + Connection : N3 ; + Well, Always : Adv ; + John, Mary : PN ; +} ; diff --git a/lib/resource/swedish/CategoriesSwe.gf b/lib/resource/swedish/CategoriesSwe.gf new file mode 100644 index 000000000..862832c32 --- /dev/null +++ b/lib/resource/swedish/CategoriesSwe.gf @@ -0,0 +1,83 @@ +--# -path=.:../abstract:../../prelude + +--1 The Top-Level Swedish Resource Grammar: Combination Rules +-- +-- Aarne Ranta 2002 -- 2003 +-- +-- This is the Swedish concrete syntax of the multilingual resource +-- grammar. Most of the work is done in the file $SyntaxSwe.gf$. +-- However, for the purpose of documentation, we make here explicit the +-- linearization types of each category, so that their structures and +-- dependencies can be seen. +-- Another substantial part are the linearization rules of some +-- structural words. +-- +-- The users of the resource grammar should not look at this file for the +-- linearization rules, which are in fact hidden in the document version. +-- They should use $resource.Abs.gf$ to access the syntactic rules. +-- This file can be consulted in those, hopefully rare, occasions in which +-- one has to know how the syntactic categories are +-- implemented. The parameter types are defined in $TypesSwe.gf$. + +concrete CategoriesSwe of Categories = open Prelude, SyntaxSwe in { + +flags + startcat=Phr ; + lexer=text ; + unlexer=text ; + +lincat + CN = {s : Number => SpeciesP => Case => Str ; g : Gender ; x : Sex ; + p : IsComplexCN} ; + N = CommNoun ; + -- = {s : Number => Species => Case => Str ; g : Gender ; x : Sex} ; + NP = NounPhrase ; + -- = {s : NPForm => Str ; g : Gender ; n : Number} ; + PN = {s : Case => Str ; g : Gender ; x : Sex} ; + Det = {s : Gender => Sex => Str ; n : Number ; b : SpeciesP} ; + N2 = Function ; + -- = CommNoun ** {s2 : Preposition} ; + N3 = Function ** {s3 : Preposition} ; + Num = {s : Case => Str} ; + Prep = {s : Str} ; + + A1 = Adjective ; + -- = {s : AdjFormPos => Case => Str} ; + A2 = Adjective ** {s2 : Preposition} ; + ADeg = {s : AdjForm => Str} ; + AP = Adjective ** {p : IsPostfixAdj} ; + + V = Verb ; + -- = {s : VerbForm => Str ; s1 : Str} ; + VG = {s : SForm => Str ; s2 : Bool => Str ; s3 : SForm => Gender => Number => Str} ; + VP = {s : SForm => Str ; s2 : Str ; s3 : SForm => Gender => Number => Str} ; + V2 = TransVerb ; + -- = Verb ** {s2 : Preposition} ; + V3 = TransVerb ** {s3 : Preposition} ; + VS = Verb ; + VV = Verb ** {isAux : Bool} ; + + Adv = Adverb ; + -- = {s : Str ; isPost : Bool} ; + PP = Adverb ; + + S = Sentence ; + -- = {s : Order => Str} ; + Cl = Clause ; + -- = {s : Bool => SForm => Order => Str} ; + Slash = Sentence ** {s2 : Preposition} ; + RP = {s : RelCase => GenNum => Str ; g : RelGender} ; + RC = {s : GenNum => Str} ; + IP = NounPhrase ; + Qu = {s : QuestForm => Str} ; + Imp = {s : Number => Str} ; + + Phr = {s : Str} ; + + Conj = {s : Str ; n : Number} ; + ConjD = {s1 : Str ; s2 : Str ; n : Number} ; + + ListS = {s1,s2 : Order => Str} ; + ListAP = {s1,s2 : AdjFormPos => Case => Str ; p : Bool} ; + ListNP = {s1,s2 : NPForm => Str ; g : Gender ; n : Number} ; +} diff --git a/lib/resource/swedish/MorphoSwe.gf b/lib/resource/swedish/MorphoSwe.gf new file mode 100644 index 000000000..b949e72fa --- /dev/null +++ b/lib/resource/swedish/MorphoSwe.gf @@ -0,0 +1,1202 @@ +--1 A Simple Swedish Resource Morphology +-- +-- Aarne Ranta 2002 +-- +-- This resource morphology contains definitions needed in the resource +-- syntax. It moreover contains copies of the most usual inflectional patterns +-- as defined in functional morphology (in the Haskell file $RulesSw.hs$). +-- +-- We use the parameter types and word classes defined for morphology. + +resource MorphoSwe = TypesSwe ** open Prelude in { + +-- The indefinite and definite article +oper + artIndef = table {Utr => "en" ; Neutr => "ett"} ; + + artDef : Bool => GenNum => Str = table { + True => table { + ASg Utr => "den" ; + ASg Neutr => "det" ; -- det gamla huset + APl => variants {"de" ; "dom"} + } ; + False => table {_ => []} -- huset + } ; + +-- A simplified verb category: present tense only (no more!). + +oper + verbVara = vara_1200 ; + verbHava = hava_1198 ; + + verbFinnas : Verb = vFinna "finn" "fann" "funn" ** {s1 = []} ; + + deponentVerb : Verb -> Verb = \finna -> { + s = table { + VF (Pres m _) => finna.s ! VF (Pres m Pass) ; + VF (Pret m _) => finna.s ! VF (Pret m Pass) ; + VI (Inf _) => finna.s ! VI (Inf Pass) ; + VI (Supin _) => finna.s ! VI (Supin Pass) ; + v => finna.s ! v --- Imper ! + } ; + s1 = finna.s1 + } ; + +{- deprecated + + verbFinnas = mkVerb "finnas" "finns" "finns" ; + +-- A simplified conjugation takes three forms in the worst case, plus a particle. + + mkVerbPart : (supa,super,sup,upp : Str) -> Verb = \supa,super,sup,upp -> + {s = table { + VPres Infinit Act => supa ; + VPres Infinit Pass => supa + "s" ; + VPres Indicat Act => super ; + VPres Indicat Pass => sup + "s" ; + VPres Imperat Act => sup ; + VPres Imparat Pass => sup + "s" + } ; + s1 = upp + } ; + +-- The most common is a verb without a particle. + + mkVerb : (supa,super,sup : Str) -> Verb = \supa,super,sup -> + mkVerbPart supa super sup [] ; +-} + +-- Prepositions are just strings. + Preposition = Str ; + +-- Relative pronouns have a special case system. $RPrep$ is the form used +-- after a preposition (e.g. "det hus i vilket jag bor"). +param + RelCase = RNom | RAcc | RGen | RPrep ; + +oper + relPronForms : RelCase => GenNum => Str = table { + RNom => \\_ => "som" ; + RAcc => \\_ => variants {"som" ; []} ; + RGen => \\_ => "vars" ; + RPrep => pronVilken + } ; + + pronVilken = table { + ASg Utr => "vilken" ; + ASg Neutr => "vilket" ; + APl => "vilka" + } ; + + pronSådan = table { + ASg Utr => "sådan" ; + ASg Neutr => "sådant" ; + APl => "sådana" + } ; + +-- What follows are machine-generated inflection paradigms from functional +-- morphology. Hence they are low-level paradigms, without any +-- abstractions or generalizations: the Haskell code is better in these respects. +-- +-- The variable names are selected in such a way that the paradigms can be read +-- as inflection tables of certain words. + +oper sApa : Str -> Subst = \ap -> + {s = table { + SF Sg Indef Nom => ap + "a" ; + SF Sg Indef Gen => ap + "as" ; + SF Sg Def Nom => ap + "an" ; + SF Sg Def Gen => ap + "ans" ; + SF Pl Indef Nom => ap + "or" ; + SF Pl Indef Gen => ap + "ors" ; + SF Pl Def Nom => ap + "orna" ; + SF Pl Def Gen => ap + "ornas" + } ; + h1 = Utr + } ; + +oper sBil : Str -> Subst = \bil -> + {s = table { + SF Sg Indef Nom => bil ; + SF Sg Indef Gen => bil + "s" ; + SF Sg Def Nom => bil + "en" ; + SF Sg Def Gen => bil + "ens" ; + SF Pl Indef Nom => bil + "ar" ; + SF Pl Indef Gen => bil + "ars" ; + SF Pl Def Nom => bil + "arna" ; + SF Pl Def Gen => bil + "arnas" + } ; + h1 = Utr + } ; + +oper sPojke : Str -> Subst = \pojk -> + {s = table { + SF Sg Indef Nom => pojk + "e" ; + SF Sg Indef Gen => pojk + "es" ; + SF Sg Def Nom => pojk + "en" ; + SF Sg Def Gen => pojk + "ens" ; + SF Pl Indef Nom => pojk + "ar" ; + SF Pl Indef Gen => pojk + "ars" ; + SF Pl Def Nom => pojk + "arna" ; + SF Pl Def Gen => pojk + "arnas" + } ; + h1 = Utr + } ; + +oper sNyckel : Str -> Subst = \nyck -> + {s = table { + SF Sg Indef Nom => nyck + "el" ; + SF Sg Indef Gen => nyck + "els" ; + SF Sg Def Nom => nyck + "eln" ; + SF Sg Def Gen => nyck + "elns" ; + SF Pl Indef Nom => nyck + "lar" ; + SF Pl Indef Gen => nyck + "lars" ; + SF Pl Def Nom => nyck + "larna" ; + SF Pl Def Gen => nyck + "larnas" + } ; + h1 = Utr + } ; + +oper sKam : Str -> Subst = \kam -> + {s = table { + SF Sg Indef Nom => kam ; + SF Sg Indef Gen => kam + "s" ; + SF Sg Def Nom => kam + "men" ; + SF Sg Def Gen => kam + "mens" ; + SF Pl Indef Nom => kam + "mar" ; + SF Pl Indef Gen => kam + "mars" ; + SF Pl Def Nom => kam + "marna" ; + SF Pl Def Gen => kam + "marnas" + } ; + h1 = Utr + } ; + +oper sSak : Str -> Subst = \sak -> + {s = table { + SF Sg Indef Nom => sak ; + SF Sg Indef Gen => sak + "s" ; + SF Sg Def Nom => sak + "en" ; + SF Sg Def Gen => sak + "ens" ; + SF Pl Indef Nom => sak + "er" ; + SF Pl Indef Gen => sak + "ers" ; + SF Pl Def Nom => sak + "erna" ; + SF Pl Def Gen => sak + "ernas" + } ; + h1 = Utr + } ; + +oper sVarelse : Str -> Subst = \varelse -> + {s = table { + SF Sg Indef Nom => varelse ; + SF Sg Indef Gen => varelse + "s" ; + SF Sg Def Nom => varelse + "n" ; + SF Sg Def Gen => varelse + "ns" ; + SF Pl Indef Nom => varelse + "r" ; + SF Pl Indef Gen => varelse + "rs" ; + SF Pl Def Nom => varelse + "rna" ; + SF Pl Def Gen => varelse + "rnas" + } ; + h1 = Utr + } ; + +oper sNivå : Str -> Subst = \nivå -> + {s = table { + SF Sg Indef Nom => nivå ; + SF Sg Indef Gen => nivå + "s" ; + SF Sg Def Nom => nivå + "n" ; + SF Sg Def Gen => nivå + "ns" ; + SF Pl Indef Nom => nivå + "er" ; + SF Pl Indef Gen => nivå + "ers" ; + SF Pl Def Nom => nivå + "erna" ; + SF Pl Def Gen => nivå + "ernas" + } ; + h1 = Utr + } ; + +oper sParti : Str -> Subst = \parti -> + {s = table { + SF Sg Indef Nom => parti ; + SF Sg Indef Gen => parti + "s" ; + SF Sg Def Nom => parti + "et" ; + SF Sg Def Gen => parti + "ets" ; + SF Pl Indef Nom => parti + "er" ; + SF Pl Indef Gen => parti + "ers" ; + SF Pl Def Nom => parti + "erna" ; + SF Pl Def Gen => parti + "ernas" + } ; + h1 = Neutr + } ; + +oper sMuseum : Str -> Subst = \muse -> + {s = table { + SF Sg Indef Nom => muse + "um" ; + SF Sg Indef Gen => muse + "ums" ; + SF Sg Def Nom => muse + "et" ; + SF Sg Def Gen => muse + "ets" ; + SF Pl Indef Nom => muse + "er" ; + SF Pl Indef Gen => muse + "ers" ; + SF Pl Def Nom => muse + "erna" ; + SF Pl Def Gen => muse + "ernas" + } ; + h1 = Neutr + } ; + +oper sRike : Str -> Subst = \rike -> + {s = table { + SF Sg Indef Nom => rike ; + SF Sg Indef Gen => rike + "s" ; + SF Sg Def Nom => rike + "t" ; + SF Sg Def Gen => rike + "ts" ; + SF Pl Indef Nom => rike + "n" ; + SF Pl Indef Gen => rike + "ns" ; + SF Pl Def Nom => rike + "na" ; + SF Pl Def Gen => rike + "nas" + } ; + h1 = Neutr + } ; + +oper sLik : Str -> Subst = \lik -> + {s = table { + SF Sg Indef Nom => lik ; + SF Sg Indef Gen => lik + "s" ; + SF Sg Def Nom => lik + "et" ; + SF Sg Def Gen => lik + "ets" ; + SF Pl Indef Nom => lik ; + SF Pl Indef Gen => lik + "s" ; + SF Pl Def Nom => lik + "en" ; + SF Pl Def Gen => lik + "ens" + } ; + h1 = Neutr + } ; + +oper sRum : Str -> Subst = \rum -> + {s = table { + SF Sg Indef Nom => rum ; + SF Sg Indef Gen => rum + "s" ; + SF Sg Def Nom => rum + "met" ; + SF Sg Def Gen => rum + "mets" ; + SF Pl Indef Nom => rum ; + SF Pl Indef Gen => rum + "s" ; + SF Pl Def Nom => rum + "men" ; + SF Pl Def Gen => rum + "mens" + } ; + h1 = Neutr + } ; + +oper sHus : Str -> Subst = \hus -> + {s = table { + SF Sg Indef Nom => hus ; + SF Sg Indef Gen => hus ; + SF Sg Def Nom => hus + "et" ; + SF Sg Def Gen => hus + "ets" ; + SF Pl Indef Nom => hus ; + SF Pl Indef Gen => hus ; + SF Pl Def Nom => hus + "en" ; + SF Pl Def Gen => hus + "ens" + } ; + h1 = Neutr + } ; + +oper sPapper : Str -> Subst = \papp -> + {s = table { + SF Sg Indef Nom => papp + "er" ; + SF Sg Indef Gen => papp + "ers" ; + SF Sg Def Nom => papp + "ret" ; + SF Sg Def Gen => papp + "rets" ; + SF Pl Indef Nom => papp + "er" ; + SF Pl Indef Gen => papp + "ers" ; + SF Pl Def Nom => papp + "ren" ; + SF Pl Def Gen => papp + "rens" + } ; + h1 = Neutr + } ; + +oper sNummer : Str -> Subst = \num -> + {s = table { + SF Sg Indef Nom => num + "mer" ; + SF Sg Indef Gen => num + "mers" ; + SF Sg Def Nom => num + "ret" ; + SF Sg Def Gen => num + "rets" ; + SF Pl Indef Nom => num + "mer" ; + SF Pl Indef Gen => num + "mers" ; + SF Pl Def Nom => num + "ren" ; + SF Pl Def Gen => num + "rens" + } ; + h1 = Neutr + } ; + +oper sKikare : Str -> Subst = \kikar -> + {s = table { + SF Sg Indef Nom => kikar + "e" ; + SF Sg Indef Gen => kikar + "es" ; + SF Sg Def Nom => kikar + "en" ; + SF Sg Def Gen => kikar + "ens" ; + SF Pl Indef Nom => kikar + "e" ; + SF Pl Indef Gen => kikar + "es" ; + SF Pl Def Nom => kikar + "na" ; + SF Pl Def Gen => kikar + "nas" + } ; + h1 = Utr + } ; + +oper sProgram : Str -> Subst = \program -> + {s = table { + SF Sg Indef Nom => program ; + SF Sg Indef Gen => program + "s" ; + SF Sg Def Nom => program + "met" ; + SF Sg Def Gen => program + "mets" ; + SF Pl Indef Nom => program ; + SF Pl Indef Gen => program + "s" ; + SF Pl Def Nom => program + "men" ; + SF Pl Def Gen => program + "mens" + } ; + h1 = Neutr + } ; + +oper aFin : Str -> Adj = \fin -> + {s = table { + AF (Posit (Strong (ASg Utr))) Nom => fin ; + AF (Posit (Strong (ASg Utr))) Gen => fin + "s" ; + AF (Posit (Strong (ASg Neutr))) Nom => fin + "t" ; + AF (Posit (Strong (ASg Neutr))) Gen => fin + "ts" ; + AF (Posit (Strong APl)) Nom => fin + "a" ; + AF (Posit (Strong APl)) Gen => fin + "as" ; + AF (Posit (Weak (AxSg NoMasc))) Nom => fin + "a" ; + AF (Posit (Weak (AxSg NoMasc))) Gen => fin + "as" ; + AF (Posit (Weak (AxSg Masc))) Nom => fin + "e" ; + AF (Posit (Weak (AxSg Masc))) Gen => fin + "es" ; + AF (Posit (Weak AxPl)) Nom => fin + "a" ; + AF (Posit (Weak AxPl)) Gen => fin + "as" ; + AF Compar Nom => fin + "are" ; + AF Compar Gen => fin + "ares" ; + AF (Super SupStrong) Nom => fin + "ast" ; + AF (Super SupStrong) Gen => fin + "asts" ; + AF (Super SupWeak) Nom => fin + "aste" ; + AF (Super SupWeak) Gen => fin + "astes" + } + } ; + +oper aFager : Str -> Adj = \fag -> + {s = table { + AF (Posit (Strong (ASg Utr))) Nom => fag + "er" ; + AF (Posit (Strong (ASg Utr))) Gen => fag + "ers" ; + AF (Posit (Strong (ASg Neutr))) Nom => fag + "ert" ; + AF (Posit (Strong (ASg Neutr))) Gen => fag + "erts" ; + AF (Posit (Strong APl)) Nom => fag + "era" ; + AF (Posit (Strong APl)) Gen => fag + "eras" ; + AF (Posit (Weak (AxSg NoMasc))) Nom => fag + "era" ; + AF (Posit (Weak (AxSg NoMasc))) Gen => fag + "eras" ; + AF (Posit (Weak (AxSg Masc))) Nom => fag + "ere" ; + AF (Posit (Weak (AxSg Masc))) Gen => fag + "eres" ; + AF (Posit (Weak AxPl)) Nom => fag + "era" ; + AF (Posit (Weak AxPl)) Gen => fag + "eras" ; + AF Compar Nom => fag + "erare" ; + AF Compar Gen => fag + "erares" ; + AF (Super SupStrong) Nom => fag + "erast" ; + AF (Super SupStrong) Gen => fag + "erasts" ; + AF (Super SupWeak) Nom => fag + "eraste" ; + AF (Super SupWeak) Gen => fag + "erastes" + } + } ; + +oper aGrund : Str -> Adj = \grun -> + {s = table { + AF (Posit (Strong (ASg Utr))) Nom => grun + "d" ; + AF (Posit (Strong (ASg Utr))) Gen => grun + "ds" ; + AF (Posit (Strong (ASg Neutr))) Nom => grun + "t" ; + AF (Posit (Strong (ASg Neutr))) Gen => grun + "ts" ; + AF (Posit (Strong APl)) Nom => grun + "da" ; + AF (Posit (Strong APl)) Gen => grun + "das" ; + AF (Posit (Weak (AxSg NoMasc))) Nom => grun + "da" ; + AF (Posit (Weak (AxSg NoMasc))) Gen => grun + "das" ; + AF (Posit (Weak (AxSg Masc))) Nom => grun + "de" ; + AF (Posit (Weak (AxSg Masc))) Gen => grun + "des" ; + AF (Posit (Weak AxPl)) Nom => grun + "da" ; + AF (Posit (Weak AxPl)) Gen => grun + "das" ; + AF Compar Nom => grun + "dare" ; + AF Compar Gen => grun + "dares" ; + AF (Super SupStrong) Nom => grun + "dast" ; + AF (Super SupStrong) Gen => grun + "dasts" ; + AF (Super SupWeak) Nom => grun + "daste" ; + AF (Super SupWeak) Gen => grun + "dastes" + } + } ; + +oper aVid : Str -> Adj = \vi -> + {s = table { + AF (Posit (Strong (ASg Utr))) Nom => vi + "d" ; + AF (Posit (Strong (ASg Utr))) Gen => vi + "ds" ; + AF (Posit (Strong (ASg Neutr))) Nom => vi + "tt" ; + AF (Posit (Strong (ASg Neutr))) Gen => vi + "tts" ; + AF (Posit (Strong APl)) Nom => vi + "da" ; + AF (Posit (Strong APl)) Gen => vi + "das" ; + AF (Posit (Weak (AxSg NoMasc))) Nom => vi + "da" ; + AF (Posit (Weak (AxSg NoMasc))) Gen => vi + "das" ; + AF (Posit (Weak (AxSg Masc))) Nom => vi + "de" ; + AF (Posit (Weak (AxSg Masc))) Gen => vi + "des" ; + AF (Posit (Weak AxPl)) Nom => vi + "da" ; + AF (Posit (Weak AxPl)) Gen => vi + "das" ; + AF Compar Nom => vi + "dare" ; + AF Compar Gen => vi + "dares" ; + AF (Super SupStrong) Nom => vi + "dast" ; + AF (Super SupStrong) Gen => vi + "dasts" ; + AF (Super SupWeak) Nom => vi + "daste" ; + AF (Super SupWeak) Gen => vi + "dastes" + } + } ; + +oper aVaken : Str -> Adj = \vak -> + {s = table { + AF (Posit (Strong (ASg Utr))) Nom => vak + "en" ; + AF (Posit (Strong (ASg Utr))) Gen => vak + "ens" ; + AF (Posit (Strong (ASg Neutr))) Nom => vak + "et" ; + AF (Posit (Strong (ASg Neutr))) Gen => vak + "ets" ; + AF (Posit (Strong APl)) Nom => vak + "na" ; + AF (Posit (Strong APl)) Gen => vak + "nas" ; + AF (Posit (Weak (AxSg NoMasc))) Nom => vak + "na" ; + AF (Posit (Weak (AxSg NoMasc))) Gen => vak + "nas" ; + AF (Posit (Weak (AxSg Masc))) Nom => vak + "ne" ; + AF (Posit (Weak (AxSg Masc))) Gen => vak + "nes" ; + AF (Posit (Weak AxPl)) Nom => vak + "na" ; + AF (Posit (Weak AxPl)) Gen => vak + "nas" ; + AF Compar Nom => vak + "nare" ; + AF Compar Gen => vak + "nares" ; + AF (Super SupStrong) Nom => vak + "nast" ; + AF (Super SupStrong) Gen => vak + "nasts" ; + AF (Super SupWeak) Nom => vak + "naste" ; + AF (Super SupWeak) Gen => vak + "nastes" + } + } ; + +oper aKorkad : Str -> Adj = \korka -> + {s = table { + AF (Posit (Strong (ASg Utr))) Nom => korka + "d" ; + AF (Posit (Strong (ASg Utr))) Gen => korka + "ds" ; + AF (Posit (Strong (ASg Neutr))) Nom => korka + "t" ; + AF (Posit (Strong (ASg Neutr))) Gen => korka + "ts" ; + AF (Posit (Strong APl)) Nom => korka + "de" ; + AF (Posit (Strong APl)) Gen => korka + "des" ; + AF (Posit (Weak (AxSg NoMasc))) Nom => korka + "de" ; + AF (Posit (Weak (AxSg NoMasc))) Gen => korka + "des" ; + AF (Posit (Weak (AxSg Masc))) Nom => korka + "de" ; + AF (Posit (Weak (AxSg Masc))) Gen => korka + "des" ; + AF (Posit (Weak AxPl)) Nom => korka + "de" ; + AF (Posit (Weak AxPl)) Gen => korka + "des" ; + AF Compar Nom => variants {} ; + AF Compar Gen => variants {} ; + AF (Super SupStrong) Nom => variants {} ; + AF (Super SupStrong) Gen => variants {} ; + AF (Super SupWeak) Nom => variants {} ; + AF (Super SupWeak) Gen => variants {} + } + } ; + +oper aAbstrakt : Str -> Adj = \abstrakt -> + {s = table { + AF (Posit (Strong (ASg Utr))) Nom => abstrakt ; + AF (Posit (Strong (ASg Utr))) Gen => abstrakt + "s" ; + AF (Posit (Strong (ASg Neutr))) Nom => abstrakt ; + AF (Posit (Strong (ASg Neutr))) Gen => abstrakt + "s" ; + AF (Posit (Strong APl)) Nom => abstrakt + "a" ; + AF (Posit (Strong APl)) Gen => abstrakt + "as" ; + AF (Posit (Weak (AxSg NoMasc))) Nom => abstrakt + "a" ; + AF (Posit (Weak (AxSg NoMasc))) Gen => abstrakt + "as" ; + AF (Posit (Weak (AxSg Masc))) Nom => abstrakt + "e" ; + AF (Posit (Weak (AxSg Masc))) Gen => abstrakt + "es" ; + AF (Posit (Weak AxPl)) Nom => abstrakt + "a" ; + AF (Posit (Weak AxPl)) Gen => abstrakt + "as" ; + AF Compar Nom => abstrakt + "are" ; + AF Compar Gen => abstrakt + "ares" ; + AF (Super SupStrong) Nom => abstrakt + "ast" ; + AF (Super SupStrong) Gen => abstrakt + "asts" ; + AF (Super SupWeak) Nom => abstrakt + "aste" ; + AF (Super SupWeak) Gen => abstrakt + "astes" + } + } ; + +oper vTala : Str -> Verbum = \tal -> + {s = table { + VF (Pres Ind Act) => tal + "ar" ; + VF (Pres Ind Pass) => tal + "as" ; + VF (Pres Cnj Act) => tal + "e" ; + VF (Pres Cnj Pass) => tal + "es" ; + VF (Pret Ind Act) => tal + "ade" ; + VF (Pret Ind Pass) => tal + "ades" ; + VF (Pret Cnj Act) => tal + "ade" ; + VF (Pret Cnj Pass) => tal + "ades" ; + VF Imper => tal + "a" ; + VI (Inf Act) => tal + "a" ; + VI (Inf Pass) => tal + "as" ; + VI (Supin Act) => tal + "at" ; + VI (Supin Pass) => tal + "ats" ; + VI (PtPres Nom) => tal + "ande" ; + VI (PtPres Gen) => tal + "andes" ; + VI (PtPret (Strong (ASg Utr)) Nom) => tal + "ad" ; + VI (PtPret (Strong (ASg Utr)) Gen) => tal + "ads" ; + VI (PtPret (Strong (ASg Neutr)) Nom) => tal + "at" ; + VI (PtPret (Strong (ASg Neutr)) Gen) => tal + "ats" ; + VI (PtPret (Strong APl) Nom) => tal + "ade" ; + VI (PtPret (Strong APl) Gen) => tal + "ades" ; + VI (PtPret (Weak (AxSg NoMasc)) Nom) => tal + "ade" ; + VI (PtPret (Weak (AxSg NoMasc)) Gen) => tal + "ades" ; + VI (PtPret (Weak (AxSg Masc)) Nom) => tal + "ade" ; + VI (PtPret (Weak (AxSg Masc)) Gen) => tal + "ades" ; + VI (PtPret (Weak AxPl) Nom) => tal + "ade" ; + VI (PtPret (Weak AxPl) Gen) => tal + "ades" + } + } ; + +oper vLeka : Str -> Verbum = \lek -> + {s = table { + VF (Pres Ind Act) => lek + "er" ; + VF (Pres Ind Pass) => variants {lek + "s" ; lek + "es"} ; + VF (Pres Cnj Act) => lek + "e" ; + VF (Pres Cnj Pass) => lek + "es" ; + VF (Pret Ind Act) => lek + "te" ; + VF (Pret Ind Pass) => lek + "tes" ; + VF (Pret Cnj Act) => lek + "te" ; + VF (Pret Cnj Pass) => lek + "tes" ; + VF Imper => lek ; + VI (Inf Act) => lek + "a" ; + VI (Inf Pass) => lek + "as" ; + VI (Supin Act) => lek + "t" ; + VI (Supin Pass) => lek + "ts" ; + VI (PtPres Nom) => lek + "ande" ; + VI (PtPres Gen) => lek + "andes" ; + VI (PtPret (Strong (ASg Utr)) Nom) => lek + "t" ; + VI (PtPret (Strong (ASg Utr)) Gen) => lek + "ts" ; + VI (PtPret (Strong (ASg Neutr)) Nom) => lek + "t" ; + VI (PtPret (Strong (ASg Neutr)) Gen) => lek + "ts" ; + VI (PtPret (Strong APl) Nom) => lek + "ta" ; + VI (PtPret (Strong APl) Gen) => lek + "tas" ; + VI (PtPret (Weak (AxSg NoMasc)) Nom) => lek + "ta" ; + VI (PtPret (Weak (AxSg NoMasc)) Gen) => lek + "tas" ; + VI (PtPret (Weak (AxSg Masc)) Nom) => lek + "te" ; + VI (PtPret (Weak (AxSg Masc)) Gen) => lek + "tes" ; + VI (PtPret (Weak AxPl) Nom) => lek + "ta" ; + VI (PtPret (Weak AxPl) Gen) => lek + "tas" + } + } ; + +oper vTyda : Str -> Verbum = \ty -> + {s = table { + VF (Pres Ind Act) => ty + "der" ; + VF (Pres Ind Pass) => variants {ty + "ds" ; ty + "des"} ; + VF (Pres Cnj Act) => ty + "de" ; + VF (Pres Cnj Pass) => ty + "des" ; + VF (Pret Ind Act) => ty + "dde" ; + VF (Pret Ind Pass) => ty + "ddes" ; + VF (Pret Cnj Act) => ty + "dde" ; + VF (Pret Cnj Pass) => ty + "ddes" ; + VF Imper => ty + "d" ; + VI (Inf Act) => ty + "da" ; + VI (Inf Pass) => ty + "das" ; + VI (Supin Act) => ty + "tt" ; + VI (Supin Pass) => ty + "tts" ; + VI (PtPres Nom) => ty + "dande" ; + VI (PtPres Gen) => ty + "dandes" ; + VI (PtPret (Strong (ASg Utr)) Nom) => ty + "dd" ; + VI (PtPret (Strong (ASg Utr)) Gen) => ty + "dds" ; + VI (PtPret (Strong (ASg Neutr)) Nom) => ty + "tt" ; + VI (PtPret (Strong (ASg Neutr)) Gen) => ty + "tts" ; + VI (PtPret (Strong APl) Nom) => ty + "dda" ; + VI (PtPret (Strong APl) Gen) => ty + "ddas" ; + VI (PtPret (Weak (AxSg NoMasc)) Nom) => ty + "dda" ; + VI (PtPret (Weak (AxSg NoMasc)) Gen) => ty + "ddas" ; + VI (PtPret (Weak (AxSg Masc)) Nom) => ty + "dde" ; + VI (PtPret (Weak (AxSg Masc)) Gen) => ty + "ddes" ; + VI (PtPret (Weak AxPl) Nom) => ty + "dda" ; + VI (PtPret (Weak AxPl) Gen) => ty + "ddas" + } + } ; + +oper vVända : Str -> Verbum = \vän -> + {s = table { + VF (Pres Ind Act) => vän + "der" ; + VF (Pres Ind Pass) => variants {vän + "ds" ; vän + "des"} ; + VF (Pres Cnj Act) => vän + "de" ; + VF (Pres Cnj Pass) => vän + "des" ; + VF (Pret Ind Act) => vän + "de" ; + VF (Pret Ind Pass) => vän + "des" ; + VF (Pret Cnj Act) => vän + "de" ; + VF (Pret Cnj Pass) => vän + "des" ; + VF Imper => vän + "d" ; + VI (Inf Act) => vän + "da" ; + VI (Inf Pass) => vän + "das" ; + VI (Supin Act) => vän + "t" ; + VI (Supin Pass) => vän + "ts" ; + VI (PtPres Nom) => vän + "dande" ; + VI (PtPres Gen) => vän + "dandes" ; + VI (PtPret (Strong (ASg Utr)) Nom) => vän + "d" ; + VI (PtPret (Strong (ASg Utr)) Gen) => vän + "ds" ; + VI (PtPret (Strong (ASg Neutr)) Nom) => vän + "t" ; + VI (PtPret (Strong (ASg Neutr)) Gen) => vän + "ts" ; + VI (PtPret (Strong APl) Nom) => vän + "da" ; + VI (PtPret (Strong APl) Gen) => vän + "das" ; + VI (PtPret (Weak (AxSg NoMasc)) Nom) => vän + "da" ; + VI (PtPret (Weak (AxSg NoMasc)) Gen) => vän + "das" ; + VI (PtPret (Weak (AxSg Masc)) Nom) => vän + "de" ; + VI (PtPret (Weak (AxSg Masc)) Gen) => vän + "des" ; + VI (PtPret (Weak AxPl) Nom) => vän + "da" ; + VI (PtPret (Weak AxPl) Gen) => vän + "das" + } + } ; + +oper vByta : Str -> Verbum = \by -> + {s = table { + VF (Pres Ind Act) => by + "ter" ; + VF (Pres Ind Pass) => variants {by + "ts" ; by + "tes"} ; + VF (Pres Cnj Act) => by + "te" ; + VF (Pres Cnj Pass) => by + "tes" ; + VF (Pret Ind Act) => by + "tte" ; + VF (Pret Ind Pass) => by + "ttes" ; + VF (Pret Cnj Act) => by + "tte" ; + VF (Pret Cnj Pass) => by + "ttes" ; + VF Imper => by + "t" ; + VI (Inf Act) => by + "ta" ; + VI (Inf Pass) => by + "tas" ; + VI (Supin Act) => by + "tt" ; + VI (Supin Pass) => by + "tts" ; + VI (PtPres Nom) => by + "tande" ; + VI (PtPres Gen) => by + "tandes" ; + VI (PtPret (Strong (ASg Utr)) Nom) => by + "tt" ; + VI (PtPret (Strong (ASg Utr)) Gen) => by + "tts" ; + VI (PtPret (Strong (ASg Neutr)) Nom) => by + "tt" ; + VI (PtPret (Strong (ASg Neutr)) Gen) => by + "tts" ; + VI (PtPret (Strong APl) Nom) => by + "tta" ; + VI (PtPret (Strong APl) Gen) => by + "ttas" ; + VI (PtPret (Weak (AxSg NoMasc)) Nom) => by + "tta" ; + VI (PtPret (Weak (AxSg NoMasc)) Gen) => by + "ttas" ; + VI (PtPret (Weak (AxSg Masc)) Nom) => by + "tte" ; + VI (PtPret (Weak (AxSg Masc)) Gen) => by + "ttes" ; + VI (PtPret (Weak AxPl) Nom) => by + "tta" ; + VI (PtPret (Weak AxPl) Gen) => by + "ttas" + } + } ; + +oper vGömma : Str -> Verbum = \göm -> + {s = table { + VF (Pres Ind Act) => göm + "mer" ; + VF (Pres Ind Pass) => variants {göm + "s" ; göm + "mes"} ; + VF (Pres Cnj Act) => göm + "me" ; + VF (Pres Cnj Pass) => göm + "mes" ; + VF (Pret Ind Act) => göm + "de" ; + VF (Pret Ind Pass) => göm + "des" ; + VF (Pret Cnj Act) => göm + "de" ; + VF (Pret Cnj Pass) => göm + "des" ; + VF Imper => göm ; + VI (Inf Act) => göm + "ma" ; + VI (Inf Pass) => göm + "mas" ; + VI (Supin Act) => göm + "t" ; + VI (Supin Pass) => göm + "ts" ; + VI (PtPres Nom) => göm + "mande" ; + VI (PtPres Gen) => göm + "mandes" ; + VI (PtPret (Strong (ASg Utr)) Nom) => göm + "d" ; + VI (PtPret (Strong (ASg Utr)) Gen) => göm + "ds" ; + VI (PtPret (Strong (ASg Neutr)) Nom) => göm + "t" ; + VI (PtPret (Strong (ASg Neutr)) Gen) => göm + "ts" ; + VI (PtPret (Strong APl) Nom) => göm + "da" ; + VI (PtPret (Strong APl) Gen) => göm + "das" ; + VI (PtPret (Weak (AxSg NoMasc)) Nom) => göm + "da" ; + VI (PtPret (Weak (AxSg NoMasc)) Gen) => göm + "das" ; + VI (PtPret (Weak (AxSg Masc)) Nom) => göm + "de" ; + VI (PtPret (Weak (AxSg Masc)) Gen) => göm + "des" ; + VI (PtPret (Weak AxPl) Nom) => göm + "da" ; + VI (PtPret (Weak AxPl) Gen) => göm + "das" + } + } ; + +oper vHyra : Str -> Verbum = \hyr -> + {s = table { + VF (Pres Ind Act) => hyr ; + VF (Pres Ind Pass) => variants {hyr + "s" ; hyr + "es"} ; + VF (Pres Cnj Act) => hyr + "e" ; + VF (Pres Cnj Pass) => hyr + "es" ; + VF (Pret Ind Act) => hyr + "de" ; + VF (Pret Ind Pass) => hyr + "des" ; + VF (Pret Cnj Act) => hyr + "de" ; + VF (Pret Cnj Pass) => hyr + "des" ; + VF Imper => hyr ; + VI (Inf Act) => hyr + "a" ; + VI (Inf Pass) => hyr + "as" ; + VI (Supin Act) => hyr + "t" ; + VI (Supin Pass) => hyr + "ts" ; + VI (PtPres Nom) => hyr + "ande" ; + VI (PtPres Gen) => hyr + "andes" ; + VI (PtPret (Strong (ASg Utr)) Nom) => hyr + "d" ; + VI (PtPret (Strong (ASg Utr)) Gen) => hyr + "ds" ; + VI (PtPret (Strong (ASg Neutr)) Nom) => hyr + "t" ; + VI (PtPret (Strong (ASg Neutr)) Gen) => hyr + "ts" ; + VI (PtPret (Strong APl) Nom) => hyr + "da" ; + VI (PtPret (Strong APl) Gen) => hyr + "das" ; + VI (PtPret (Weak (AxSg NoMasc)) Nom) => hyr + "da" ; + VI (PtPret (Weak (AxSg NoMasc)) Gen) => hyr + "das" ; + VI (PtPret (Weak (AxSg Masc)) Nom) => hyr + "de" ; + VI (PtPret (Weak (AxSg Masc)) Gen) => hyr + "des" ; + VI (PtPret (Weak AxPl) Nom) => hyr + "da" ; + VI (PtPret (Weak AxPl) Gen) => hyr + "das" + } + } ; + +oper vTåla : Str -> Verbum = \tål -> + {s = table { + VF (Pres Ind Act) => tål ; + VF (Pres Ind Pass) => variants {tål + "s" ; tål + "es"} ; + VF (Pres Cnj Act) => tål + "e" ; + VF (Pres Cnj Pass) => tål + "es" ; + VF (Pret Ind Act) => tål + "de" ; + VF (Pret Ind Pass) => tål + "des" ; + VF (Pret Cnj Act) => tål + "de" ; + VF (Pret Cnj Pass) => tål + "des" ; + VF Imper => tål ; + VI (Inf Act) => tål + "a" ; + VI (Inf Pass) => tål + "as" ; + VI (Supin Act) => tål + "t" ; + VI (Supin Pass) => tål + "ts" ; + VI (PtPres Nom) => tål + "ande" ; + VI (PtPres Gen) => tål + "andes" ; + VI (PtPret (Strong (ASg Utr)) Nom) => tål + "d" ; + VI (PtPret (Strong (ASg Utr)) Gen) => tål + "ds" ; + VI (PtPret (Strong (ASg Neutr)) Nom) => tål + "t" ; + VI (PtPret (Strong (ASg Neutr)) Gen) => tål + "ts" ; + VI (PtPret (Strong APl) Nom) => tål + "da" ; + VI (PtPret (Strong APl) Gen) => tål + "das" ; + VI (PtPret (Weak (AxSg NoMasc)) Nom) => tål + "da" ; + VI (PtPret (Weak (AxSg NoMasc)) Gen) => tål + "das" ; + VI (PtPret (Weak (AxSg Masc)) Nom) => tål + "de" ; + VI (PtPret (Weak (AxSg Masc)) Gen) => tål + "des" ; + VI (PtPret (Weak AxPl) Nom) => tål + "da" ; + VI (PtPret (Weak AxPl) Gen) => tål + "das" + } + } ; + +oper vFinna : (_,_,_ : Str) -> Verbum = \finn, fann, funn -> + {s = table { + VF (Pres Ind Act) => finn + "er" ; + VF (Pres Ind Pass) => variants {finn + "s" ; finn + "es"} ; + VF (Pres Cnj Act) => finn + "e" ; + VF (Pres Cnj Pass) => finn + "es" ; + VF (Pret Ind Act) => fann ; + VF (Pret Ind Pass) => fann + "s" ; + VF (Pret Cnj Act) => funn + "e" ; + VF (Pret Cnj Pass) => funn + "es" ; + VF Imper => finn ; + VI (Inf Act) => finn + "a" ; + VI (Inf Pass) => finn + "as" ; + VI (Supin Act) => funn + "it" ; + VI (Supin Pass) => funn + "its" ; + VI (PtPres Nom) => finn + "ande" ; + VI (PtPres Gen) => finn + "andes" ; + VI (PtPret (Strong (ASg Utr)) Nom) => funn + "en" ; + VI (PtPret (Strong (ASg Utr)) Gen) => funn + "ens" ; + VI (PtPret (Strong (ASg Neutr)) Nom) => funn + "et" ; + VI (PtPret (Strong (ASg Neutr)) Gen) => funn + "ets" ; + VI (PtPret (Strong APl) Nom) => funn + "a" ; + VI (PtPret (Strong APl) Gen) => funn + "as" ; + VI (PtPret (Weak (AxSg NoMasc)) Nom) => funn + "a" ; + VI (PtPret (Weak (AxSg NoMasc)) Gen) => funn + "as" ; + VI (PtPret (Weak (AxSg Masc)) Nom) => funn + "e" ; + VI (PtPret (Weak (AxSg Masc)) Gen) => funn + "es" ; + VI (PtPret (Weak AxPl) Nom) => funn + "a" ; + VI (PtPret (Weak AxPl) Gen) => funn + "as" + } + } ; + +-- machine-generated exceptional inflection tables from rules.Swe.gf + +oper mor_1 : Subst = + {s = table { + SF Sg Indef Nom => variants {"mor" ; "moder"} ; + SF Sg Indef Gen => variants {"mors" ; "moders"} ; + SF Sg Def Nom => "modern" ; + SF Sg Def Gen => "moderns" ; + SF Pl Indef Nom => "mödrar" ; + SF Pl Indef Gen => "mödrars" ; + SF Pl Def Nom => "mödrarna" ; + SF Pl Def Gen => "mödrarnas" + } ; + h1 = Utr + } ; + +oper farbror_8 : Subst = + {s = table { + SF Sg Indef Nom => variants {"farbror" ; "farbroder"} ; + SF Sg Indef Gen => variants {"farbrors" ; "farbroders"} ; + SF Sg Def Nom => "farbrodern" ; + SF Sg Def Gen => "farbroderns" ; + SF Pl Indef Nom => "farbröder" ; + SF Pl Indef Gen => "farbröders" ; + SF Pl Def Nom => "farbröderna" ; + SF Pl Def Gen => "farbrödernas" + } ; + h1 = Utr + } ; + +oper gammal_16 : Adj = + {s = table { + AF (Posit (Strong (ASg Utr))) Nom => "gammal" ; + AF (Posit (Strong (ASg Utr))) Gen => "gammals" ; + AF (Posit (Strong (ASg Neutr))) Nom => "gammalt" ; + AF (Posit (Strong (ASg Neutr))) Gen => "gammalts" ; + AF (Posit (Strong APl)) Nom => "gamla" ; + AF (Posit (Strong APl)) Gen => "gamlas" ; + AF (Posit (Weak (AxSg NoMasc))) Nom => "gamla" ; + AF (Posit (Weak (AxSg NoMasc))) Gen => "gamlas" ; + AF (Posit (Weak (AxSg Masc))) Nom => "gamle" ; + AF (Posit (Weak (AxSg Masc))) Gen => "gamles" ; + AF (Posit (Weak AxPl)) Nom => "gamla" ; + AF (Posit (Weak AxPl)) Gen => "gamlas" ; + AF Compar Nom => "äldre" ; + AF Compar Gen => "äldres" ; + AF (Super SupStrong) Nom => "äldst" ; + AF (Super SupStrong) Gen => "äldsts" ; + AF (Super SupWeak) Nom => "äldsta" ; + AF (Super SupWeak) Gen => "äldstas" + } + } ; + + +oper stor_25 : Adj = + {s = table { + AF (Posit (Strong (ASg Utr))) Nom => "stor" ; + AF (Posit (Strong (ASg Utr))) Gen => "stors" ; + AF (Posit (Strong (ASg Neutr))) Nom => "stort" ; + AF (Posit (Strong (ASg Neutr))) Gen => "storts" ; + AF (Posit (Strong APl)) Nom => "stora" ; + AF (Posit (Strong APl)) Gen => "storas" ; + AF (Posit (Weak (AxSg NoMasc))) Nom => "stora" ; + AF (Posit (Weak (AxSg NoMasc))) Gen => "storas" ; + AF (Posit (Weak (AxSg Masc))) Nom => "store" ; + AF (Posit (Weak (AxSg Masc))) Gen => "stores" ; + AF (Posit (Weak AxPl)) Nom => "stora" ; + AF (Posit (Weak AxPl)) Gen => "storas" ; + AF Compar Nom => "större" ; + AF Compar Gen => "störres" ; + AF (Super SupStrong) Nom => "störst" ; + AF (Super SupStrong) Gen => "störsts" ; + AF (Super SupWeak) Nom => "största" ; + AF (Super SupWeak) Gen => "störstas" + } + } ; + +oper ung_29 : Adj = + {s = table { + AF (Posit (Strong (ASg Utr))) Nom => "ung" ; + AF (Posit (Strong (ASg Utr))) Gen => "ungs" ; + AF (Posit (Strong (ASg Neutr))) Nom => "ungt" ; + AF (Posit (Strong (ASg Neutr))) Gen => "ungts" ; + AF (Posit (Strong APl)) Nom => "unga" ; + AF (Posit (Strong APl)) Gen => "ungas" ; + AF (Posit (Weak (AxSg NoMasc))) Nom => "unga" ; + AF (Posit (Weak (AxSg NoMasc))) Gen => "ungas" ; + AF (Posit (Weak (AxSg Masc))) Nom => "unge" ; + AF (Posit (Weak (AxSg Masc))) Gen => "unges" ; + AF (Posit (Weak AxPl)) Nom => "unga" ; + AF (Posit (Weak AxPl)) Gen => "ungas" ; + AF Compar Nom => "yngre" ; + AF Compar Gen => "yngres" ; + AF (Super SupStrong) Nom => "yngst" ; + AF (Super SupStrong) Gen => "yngsts" ; + AF (Super SupWeak) Nom => "yngsta" ; + AF (Super SupWeak) Gen => "yngstas" + } + } ; + + +oper jag_32 : ProPN = + {s = table { + PNom => "jag" ; + PAcc => "mig" ; + PGen (ASg Utr) => "min" ; + PGen (ASg Neutr) => "mitt" ; + PGen APl => "mina" + } ; + h1 = Utr ; + h2 = Sg ; + h3 = P1 + } ; + +oper du_33 : ProPN = + {s = table { + PNom => "du" ; + PAcc => "dig" ; + PGen (ASg Utr) => "din" ; + PGen (ASg Neutr) => "ditt" ; + PGen APl => "dina" + } ; + h1 = Utr ; + h2 = Sg ; + h3 = P2 + } ; + +oper han_34 : ProPN = + {s = table { + PNom => "han" ; + PAcc => "honom" ; + PGen (ASg Utr) => "hans" ; + PGen (ASg Neutr) => "hans" ; + PGen APl => "hans" + } ; + h1 = Utr ; + h2 = Sg ; + h3 = P3 + } ; + +oper hon_35 : ProPN = + {s = table { + PNom => "hon" ; + PAcc => "henne" ; + PGen (ASg Utr) => "hennes" ; + PGen (ASg Neutr) => "hennes" ; + PGen APl => "hennes" + } ; + h1 = Utr ; + h2 = Sg ; + h3 = P3 + } ; + +oper vi_36 : ProPN = + {s = table { + PNom => "vi" ; + PAcc => "oss" ; + PGen (ASg Utr) => "vår" ; + PGen (ASg Neutr) => "vårt" ; + PGen APl => "våra" + } ; + h1 = Utr ; + h2 = Pl ; + h3 = P1 + } ; + +oper ni_37 : ProPN = + {s = table { + PNom => "ni" ; + PAcc => "er" ; + PGen (ASg Utr) => "er" ; + PGen (ASg Neutr) => "ert" ; + PGen APl => "era" + } ; + h1 = Utr ; + h2 = Pl ; + h3 = P2 + } ; + +oper de_38 : ProPN = + {s = table { + PNom => "de" ; + PAcc => "dem" ; + PGen (ASg Utr) => "deras" ; + PGen (ASg Neutr) => "deras" ; + PGen APl => "deras" + } ; + h1 = Utr ; + h2 = Pl ; + h3 = P3 + } ; + +oper den_39 : ProPN = + {s = table { + PNom => "den" ; + PAcc => "den" ; + PGen (ASg Utr) => "dess" ; + PGen (ASg Neutr) => "dess" ; + PGen APl => "dess" + } ; + h1 = Utr ; + h2 = Sg ; + h3 = P3 + } ; + +oper det_40 : ProPN = + {s = table { + PNom => "det" ; + PAcc => "det" ; + PGen (ASg Utr) => "dess" ; + PGen (ASg Neutr) => "dess" ; + PGen APl => "dess" + } ; + h1 = Neutr ; + h2 = Sg ; + h3 = P3 + } ; + +oper man_1144 : Subst = + {s = table { + SF Sg Indef Nom => "man" ; + SF Sg Indef Gen => "mans" ; + SF Sg Def Nom => "mannen" ; + SF Sg Def Gen => "mannens" ; + SF Pl Indef Nom => "män" ; + SF Pl Indef Gen => "mäns" ; + SF Pl Def Nom => "männen" ; + SF Pl Def Gen => "männens" + } ; + h1 = Utr + } ; + +oper liten_1146 : Adj = + {s = table { + AF (Posit (Strong (ASg Utr))) Nom => "liten" ; + AF (Posit (Strong (ASg Utr))) Gen => "litens" ; + AF (Posit (Strong (ASg Neutr))) Nom => "litet" ; + AF (Posit (Strong (ASg Neutr))) Gen => "litets" ; + AF (Posit (Strong APl)) Nom => "små" ; + AF (Posit (Strong APl)) Gen => "smås" ; + AF (Posit (Weak (AxSg NoMasc))) Nom => "lilla" ; + AF (Posit (Weak (AxSg NoMasc))) Gen => "lillas" ; + AF (Posit (Weak (AxSg Masc))) Nom => "lille" ; + AF (Posit (Weak (AxSg Masc))) Gen => "lilles" ; + AF (Posit (Weak AxPl)) Nom => "små" ; + AF (Posit (Weak AxPl)) Gen => "smås" ; + AF Compar Nom => "mindre" ; + AF Compar Gen => "mindres" ; + AF (Super SupStrong) Nom => "minst" ; + AF (Super SupStrong) Gen => "minsts" ; + AF (Super SupWeak) Nom => "minsta" ; + AF (Super SupWeak) Gen => "minstas" + } + } ; + +oper giva_1147 : Verbum = + {s = table { + VF (Pres Ind Act) => variants {"giver" ; "ger"} ; + VF (Pres Ind Pass) => variants {"gives" ; "givs" ; "ges"} ; + VF (Pres Conj Act) => "give" ; + VF (Pres Conj Pass) => "gives" ; + VF (Pret Ind Act) => "gav" ; + VF (Pret Ind Pass) => "gavs" ; + VF (Pret Conj Act) => "give" ; + VF (Pret Conj Pass) => "gives" ; + VF Imper => variants {"giv" ; "ge"} ; + VI (Inf Act) => variants {"giva" ; "ge"} ; + VI (Inf Pass) => variants {"givas" ; "ges"} ; + VI (Supin Act) => "givit" ; + VI (Supin Pass) => "givits" ; + VI (PtPres Nom) => "givande" ; + VI (PtPres Gen) => "givandes" ; + VI (PtPret (Strong (ASg Utr)) Nom) => "given" ; + VI (PtPret (Strong (ASg Utr)) Gen) => "givens" ; + VI (PtPret (Strong (ASg Neutr)) Nom) => "givet" ; + VI (PtPret (Strong (ASg Neutr)) Gen) => "givets" ; + VI (PtPret (Strong APl) Nom) => "givna" ; + VI (PtPret (Strong APl) Gen) => "givnas" ; + VI (PtPret (Weak (AxSg NoMasc)) Nom) => "givna" ; + VI (PtPret (Weak (AxSg NoMasc)) Gen) => "givnas" ; + VI (PtPret (Weak (AxSg Masc)) Nom) => "givne" ; + VI (PtPret (Weak (AxSg Masc)) Gen) => "givnes" ; + VI (PtPret (Weak AxPl) Nom) => "givna" ; + VI (PtPret (Weak AxPl) Gen) => "givnas" + } + } ; + +oper gå_1174 : Verbum = + {s = table { + VF (Pres Ind Act) => "går" ; + VF (Pres Ind Pass) => "gås" ; + VF (Pres Cnj Act) => "gå" ; + VF (Pres Cnj Pass) => "gås" ; + VF (Pret Ind Act) => "gick" ; + VF (Pret Ind Pass) => "gicks" ; + VF (Pret Cnj Act) => "ginge" ; + VF (Pret Cnj Pass) => "ginges" ; + VF Imper => "gå" ; + VI (Inf Act) => "gå" ; + VI (Inf Pass) => "gås" ; + VI (Supin Act) => "gått" ; + VI (Supin Pass) => "gåtts" ; + VI (PtPres Nom) => "gående" ; + VI (PtPres Gen) => "gåendes" ; + VI (PtPret (Strong (ASg Utr)) Nom) => "gången" ; + VI (PtPret (Strong (ASg Utr)) Gen) => "gångens" ; + VI (PtPret (Strong (ASg Neutr)) Nom) => "gånget" ; + VI (PtPret (Strong (ASg Neutr)) Gen) => "gångets" ; + VI (PtPret (Strong APl) Nom) => "gångna" ; + VI (PtPret (Strong APl) Gen) => "gångnas" ; + VI (PtPret (Weak (AxSg NoMasc)) Nom) => "gångna" ; + VI (PtPret (Weak (AxSg NoMasc)) Gen) => "gångnas" ; + VI (PtPret (Weak (AxSg Masc)) Nom) => "gångne" ; + VI (PtPret (Weak (AxSg Masc)) Gen) => "gångnes" ; + VI (PtPret (Weak AxPl) Nom) => "gångna" ; + VI (PtPret (Weak AxPl) Gen) => "gångnas" + } + } ; +oper hava_1198 : Verbum = + {s = table { + VF (Pres Ind Act) => variants {"haver" ; "har"} ; + VF (Pres Ind Pass) => variants {"havs" ; "has"} ; + VF (Pres Conj Act) => "have" ; + VF (Pres Conj Pass) => "haves" ; + VF (Pret Ind Act) => "hade" ; + VF (Pret Ind Pass) => "hades" ; + VF (Pret Conj Act) => "hade" ; + VF (Pret Conj Pass) => "hades" ; + VF Imper => variants {"hav" ; "ha"} ; + VI (Inf Act) => variants {"hava" ; "ha"} ; + VI (Inf Pass) => variants {"havas" ; "has"} ; + VI (Supin Act) => "haft" ; + VI (Supin Pass) => "hafts" ; + VI (PtPres Nom) => "havande" ; + VI (PtPres Gen) => "havandes" ; + VI (PtPret (Strong (ASg Utr)) Nom) => variants {} ; + VI (PtPret (Strong (ASg Utr)) Gen) => variants {} ; + VI (PtPret (Strong (ASg Neutr)) Nom) => variants {} ; + VI (PtPret (Strong (ASg Neutr)) Gen) => variants {} ; + VI (PtPret (Strong APl) Nom) => variants {} ; + VI (PtPret (Strong APl) Gen) => variants {} ; + VI (PtPret (Weak (AxSg NoMasc)) Nom) => variants {} ; + VI (PtPret (Weak (AxSg NoMasc)) Gen) => variants {} ; + VI (PtPret (Weak (AxSg Masc)) Nom) => variants {} ; + VI (PtPret (Weak (AxSg Masc)) Gen) => variants {} ; + VI (PtPret (Weak AxPl) Nom) => variants {} ; + VI (PtPret (Weak AxPl) Gen) => variants {} + } + } ; + +oper vara_1200 : Verbum = + {s = table { + VF (Pres Ind Act) => "är" ; + VF (Pres Ind Pass) => variants {} ; + VF (Pres Conj Act) => "vare" ; + VF (Pres Conj Pass) => variants {} ; + VF (Pret Ind Act) => "var" ; + VF (Pret Ind Pass) => variants {} ; + VF (Pret Conj Act) => "vore" ; + VF (Pret Conj Pass) => variants {} ; + VF Imper => "var" ; + VI (Inf Act) => "vara" ; + VI (Inf Pass) => variants {} ; + VI (Supin Act) => "varit" ; + VI (Supin Pass) => variants {} ; + VI (PtPres Nom) => "varande" ; + VI (PtPres Gen) => "varandes" ; + VI (PtPret (Strong (ASg Utr)) Nom) => variants {} ; + VI (PtPret (Strong (ASg Utr)) Gen) => variants {} ; + VI (PtPret (Strong (ASg Neutr)) Nom) => variants {} ; + VI (PtPret (Strong (ASg Neutr)) Gen) => variants {} ; + VI (PtPret (Strong APl) Nom) => variants {} ; + VI (PtPret (Strong APl) Gen) => variants {} ; + VI (PtPret (Weak (AxSg NoMasc)) Nom) => variants {} ; + VI (PtPret (Weak (AxSg NoMasc)) Gen) => variants {} ; + VI (PtPret (Weak (AxSg Masc)) Nom) => variants {} ; + VI (PtPret (Weak (AxSg Masc)) Gen) => variants {} ; + VI (PtPret (Weak AxPl) Nom) => variants {} ; + VI (PtPret (Weak AxPl) Gen) => variants {} + } + } ; + +-- for Numerals + +param DForm = ental | ton | tiotal ; + +oper + LinDigit = {s : DForm => Str} ; + + mkTal : Str -> Str -> Str -> LinDigit = \två, tolv, tjugo -> + {s = table {ental => två ; ton => tolv ; tiotal => tjugo}} ; + + regTal : Str -> LinDigit = \fem -> + mkTal fem (fem + "ton") (fem + "tio") ; + + + +} diff --git a/lib/resource/swedish/NumeralsSwe.gf b/lib/resource/swedish/NumeralsSwe.gf new file mode 100644 index 000000000..83d146022 --- /dev/null +++ b/lib/resource/swedish/NumeralsSwe.gf @@ -0,0 +1,34 @@ +concrete NumeralsSwe of Numerals = open MorphoSwe, Prelude in { + +lincat + Digit = {s : DForm => Str} ; + Sub10 = {s : DForm => Str} ; + +lin + num x = x ; + + n2 = mkTal "två" "tolv" "tjugo" ; + n3 = mkTal "tre" "tretton" "trettio" ; + n4 = mkTal "fyra" "fjorton" "fyrtio" ; + n5 = regTal "fem" ; + n6 = regTal "sex" ; + n7 = mkTal "sju" "sjutton" "sjuttio" ; + n8 = mkTal "åtta" "arton" "åttio" ; + n9 = mkTal "nio" "nitton" "nittio" ; + + pot01 = {s = table {f => "ett"}} ; + pot0 d = {s = table {f => d.s ! f}} ; + pot110 = ss "tio" ; + pot111 = ss "elva" ; + pot1to19 d = ss (d.s ! ton) ; + pot0as1 n = ss (n.s ! ental) ; + pot1 d = ss (d.s ! tiotal) ; + pot1plus d e = ss (d.s ! tiotal ++ e.s ! ental) ; + pot1as2 n = n ; + pot2 d = ss (d.s ! ental ++ "hundra") ; + pot2plus d e = ss (d.s ! ental ++ "hundra" ++ e.s) ; + pot2as3 n = n ; + pot3 n = ss (n.s ++ "tusen") ; + pot3plus n m = ss (n.s ++ "tusen" ++ m.s) ; + +} \ No newline at end of file diff --git a/lib/resource/swedish/RulesSwe.gf b/lib/resource/swedish/RulesSwe.gf new file mode 100644 index 000000000..f131871d2 --- /dev/null +++ b/lib/resource/swedish/RulesSwe.gf @@ -0,0 +1,134 @@ +concrete RulesSwe of Rules = CategoriesSwe, NumeralsSwe ** open Prelude, SyntaxSwe in { + +lin + UseN = noun2CommNounPhrase ; + ModAdj = modCommNounPhrase ; + ModGenOne = npGenDet singular noNum ; + ModGenNum = npGenDet plural ; + UsePN = nameNounPhrase ; + UseN2 = funAsCommNounPhrase ; + AppN2 = appFunComm ; + AppN3 = appFun2 ; + UseA1 = adj2adjPhrase ; + ComplA2 = complAdj ; + PositADeg = positAdjPhrase ; + ComparADeg = comparAdjPhrase ; + SuperlADeg = superlAdjPhrase ; + + DetNP = detNounPhrase ; + IndefOneNP = indefNounPhrase singular ; + IndefNumNP = indefNounPhraseNum plural ; + DefOneNP = defNounPhrase singular ; + DefNumNP = defNounPhraseNum plural ; + MassNP = detNounPhrase (mkDeterminerSg (detSgInvar []) IndefP) ; + UseInt i = {s = table {Nom => i.s ; Gen => i.s ++ "s"}} ; --- + UseNumeral i = {s = table {Nom => i.s ; Gen => i.s ++ "s"}} ; --- + NoNum = noNum ; + + SymbPN i = {s = \\_ => i.s ; g = Neutr ; x = NoMasc} ; + SymbCN cn s = + {s = \\a,n,c => cn.s ! a ! n ! c ++ s.s ; + g = cn.g ; + x = cn.x ; + p = cn.p + } ; + + CNthatS = nounThatSentence ; + + PredVP = predVerbPhrase ; + + PosVG = predVerbGroup True ; + NegVG = predVerbGroup False ; + + PredVG = predVerbGroupClause ; + + PredV = predVerb ; + PredAP = predAdjective ; + PredCN = predCommNoun ; + PredV2 = complTransVerb ; + PredV3 = complDitransVerb ; + PredPassV = passVerb ; + PredNP = predNounPhrase ; + PredAdv = predAdverb ; + PredVS = complSentVerb ; + PredVV = complVerbVerb ; + VTrans = transAsVerb ; + + AdjAdv a = advPost (a.s ! adverbForm ! Nom) ; + AdvPP p = p ; + PrepNP p = prepPhrase p.s ; --- + AdvVP = adVerbPhrase ; + AdvCN = advCommNounPhrase ; + AdvAP = advAdjPhrase ; + + ThereNP A = predVerbPhrase npDet + (predVerbGroup True + (complTransVerb (mkDirectVerb (deponentVerb verbFinnas)) A)) ; + + PosSlashV2 = slashTransVerb True ; + NegSlashV2 = slashTransVerb False ; + OneVP = predVerbPhrase npMan ; + + IdRP = identRelPron ; + FunRP = funRelPron ; + RelVP = relVerbPhrase ; + RelSlash = relSlash ; + ModRC = modRelClause ; + RelSuch = relSuch ; + + WhoOne = intPronWho singular ; + WhoMany = intPronWho plural ; + WhatOne = intPronWhat singular ; + WhatMany = intPronWhat plural ; + FunIP = funIntPron ; + NounIPOne = nounIntPron singular ; + NounIPMany = nounIntPron plural ; + + QuestVP = questVerbPhrase ; + IntVP = intVerbPhrase ; + IntSlash = intSlash ; + QuestAdv = questAdverbial ; + IsThereNP A = questVerbPhrase npDet + (predVerbGroup True + (complTransVerb (mkDirectVerb (deponentVerb verbFinnas)) A)) ; + + ImperVP = imperVerbPhrase ; + + IndicPhrase = indicUtt ; + QuestPhrase = interrogUtt ; + ImperOne = imperUtterance singular ; + ImperMany = imperUtterance plural ; + + PrepS p = ss (p.s ++ ",") ; + AdvS = advSentence ; + + TwoS = twoSentence ; + ConsS = consSentence ; + ConjS = conjunctSentence ; + ConjDS = conjunctDistrSentence ; + + TwoAP = twoAdjPhrase ; + ConsAP = consAdjPhrase ; + ConjAP = conjunctAdjPhrase ; + ConjDAP = conjunctDistrAdjPhrase ; + + TwoNP = twoNounPhrase ; + ConsNP = consNounPhrase ; + ConjNP = conjunctNounPhrase ; + ConjDNP = conjunctDistrNounPhrase ; + + SubjS = subjunctSentence ; + SubjImper = subjunctImperative ; + SubjQu = subjunctQuestion ; + SubjVP = subjunctVerbPhrase ; + + PhrNP = useNounPhrase ; + PhrOneCN = useCommonNounPhrase singular ; + PhrManyCN = useCommonNounPhrase plural ; + PhrIP ip = ip ; + PhrIAdv ia = ia ; + + OnePhr p = p ; + ConsPhr = cc2 ; + +} ; diff --git a/lib/resource/swedish/StructuralSwe.gf b/lib/resource/swedish/StructuralSwe.gf new file mode 100644 index 000000000..de215541f --- /dev/null +++ b/lib/resource/swedish/StructuralSwe.gf @@ -0,0 +1,114 @@ +--# -path=.:../abstract:../../prelude + +--1 The Top-Level Swedish Resource Grammar: Structural Words +-- +-- Aarne Ranta 2002 -- 2004 +-- +concrete StructuralSwe of Structural = + CategoriesSwe ** open Prelude, SyntaxSwe in { + lin + + INP = pronNounPhrase jag_32 ; + ThouNP = pronNounPhrase du_33 ; + HeNP = pronNounPhrase han_34 ; + SheNP = pronNounPhrase hon_35 ; + WeNumNP n = pronNounPhrase (pronWithNum vi_36 n) ; + YeNumNP n = pronNounPhrase (pronWithNum ni_37 n) ; + TheyNP = pronNounPhrase de_38 ; + + YouNP = let {ni = pronNounPhrase ni_37 } in {s = ni.s ; g = ni.g ; n = Sg} ; + + ItNP = pronNounPhrase det_40 ; ---- + ThisNP = regNameNounPhrase ["det här"] Neutr NoMasc ; + ThatNP = regNameNounPhrase ["det där"] Neutr NoMasc ; + TheseNumNP n = + {s = \\c => ["det här"] ++ n.s ! npCase c ; g = Neutr ; n = Pl} ; + ThoseNumNP n = + {s = \\c => ["det där"] ++ n.s ! npCase c ; g = Neutr ; n = Pl} ; + + EveryDet = varjeDet ; + AllMassDet = mkDeterminerSgGender2 "all" "allt" IndefP ; + AllNumDet = mkDeterminerPlNum "alla" IndefP ; + AnyDet = mkDeterminerSgGender2 "någon" "något" IndefP ; + AnyNumDet = mkDeterminerPlNum "några" IndefP ; + SomeDet = mkDeterminerSgGender2 "någon" "något" IndefP ; + SomeNumDet = mkDeterminerPlNum "några" IndefP ; + ManyDet = mkDeterminerPl "många" IndefP ; + NoDet = mkDeterminerSgGender2 "ingen" "inget" IndefP ; + NoNumDet = mkDeterminerPlNum "inga" IndefP ; + WhichNumDet = mkDeterminerPlNum "vilka" IndefP ; + + WhichDet = vilkenDet ; + MostDet = mkDeterminerSgGender2 ["den mesta"] ["det mesta"] (DefP Def) ; + MostsDet = flestaDet ; + MuchDet = mkDeterminerSg (detSgInvar "mycket") IndefP ; + + ThisDet = mkDeterminerSgGender2 ["den här"] ["det här"] (DefP Def) ; + ThatDet = mkDeterminerSgGender2 ["den där"] ["det där"] (DefP Def) ; + TheseNumDet = mkDeterminerPlNum ["de här"] (DefP Def) ; + ThoseNumDet = mkDeterminerPlNum ["de där"] (DefP Def) ; + + HowIAdv = ss "hur" ; + WhenIAdv = ss "när" ; + WhereIAdv = ss "var" ; + WhyIAdv = ss "varför" ; + + AndConj = ss "och" ** {n = Pl} ; + OrConj = ss "eller" ** {n = Sg} ; + BothAnd = sd2 "både" "och" ** {n = Pl} ; + EitherOr = sd2 "antingen" "eller" ** {n = Sg} ; + NeitherNor = sd2 "varken" "eller" ** {n = Sg} ; + IfSubj = ss "om" ; + WhenSubj = ss "när" ; + + PhrYes = ss ["Ja ."] ; + PhrNo = ss ["Nej ."] ; + + VeryAdv = ss "mycket" ; + TooAdv = ss "för" ; + OtherwiseAdv = ss "annars" ; + ThereforeAdv = ss "därför" ; + + EverybodyNP = let alla = table {Nom => "alla" ; Gen => "allas"} in + {s = \\c => alla ! npCase c ; g = Utr ; n = Pl} ; + SomebodyNP = nameNounPhrase (mkProperName "någon" Utr Masc) ; + NobodyNP = nameNounPhrase (mkProperName "ingen" Utr Masc) ; + EverythingNP = nameNounPhrase (mkProperName "allting" Neutr NoMasc) ; + SomethingNP = nameNounPhrase (mkProperName "någonting" Neutr NoMasc) ; + NothingNP = nameNounPhrase (mkProperName "ingenting" Neutr NoMasc) ; + +---- CanVV = mkVerb "kunna" "kan" "kunn" "kunde" "kunnat" ** {isAux = True} ; --- +---- CanKnowVV = mkVerb "kunna" "kan" "kunn" "kunde" "kunnat" ** {isAux = True} ; --- +---- MustVV = mkVerb "få" "måste" "få" "fick" "måst" ** {isAux = True} ; --- +---- WantVV = mkVerb "vilja" "vill" "vilj" ** {isAux = True} ; --- + + EverywhereNP = advPost "varstans" ; + SomewhereNP = advPost "någonstans" ; + NowhereNP = advPost "ingenstans" ; + + AlthoughSubj = ss "fast" ; + + AlmostAdv = ss "nästan" ; + QuiteAdv = ss "ganska" ; + + InPrep = ss "i" ; + OnPrep = ss "på" ; + ToPrep = ss "till" ; + ThroughPrep = ss "genom" ; + AbovePrep = ss "ovanför" ; + UnderPrep = ss "under" ; + InFrontPrep = ss "framför" ; + BehindPrep = ss "bakom" ; + BetweenPrep = ss "mellan" ; + FromPrep = ss "från" ; + BeforePrep = ss "före" ; + DuringPrep = ss "under" ; + AfterPrep = ss "efter" ; + WithPrep = ss "med" ; + WithoutPrep = ss "utan" ; + ByMeansPrep = ss "med" ; + PossessPrep = ss "av" ; + PartPrep = ss "av" ; + AgentPrep = ss "av" ; + +} diff --git a/lib/resource/swedish/SyntaxSwe.gf b/lib/resource/swedish/SyntaxSwe.gf new file mode 100644 index 000000000..8385498a2 --- /dev/null +++ b/lib/resource/swedish/SyntaxSwe.gf @@ -0,0 +1,1229 @@ +--1 A Small Swedish Resource Syntax +-- +-- Aarne Ranta 2002 +-- +-- This resource grammar contains definitions needed to construct +-- indicative, interrogative, and imperative sentences in Swedish. +-- +-- The following modules are presupposed: + +resource SyntaxSwe = MorphoSwe ** open Prelude, (CO = Coordination) in { + +--2 Common Nouns +-- +--3 Simple common nouns + +oper + CommNoun : Type = {s : Number => Species => Case => Str ; g : Gender ; x : Sex} ; + +-- When common nouns are extracted from lexicon, the composite noun form is ignored. +-- But we have to indicate a sex. + extCommNoun : Sex -> Subst -> CommNoun = \x,sb -> + {s = \\n,b,c => sb.s ! SF n b c ; + g = sb.h1 ; + x = x} ; + +-- These constants are used for data abstraction over the parameter type $Num$. + singular = Sg ; + plural = Pl ; + +--3 Common noun phrases + +-- The need for this more complex type comes from the variation in the way in +-- which a modifying adjective is inflected after different determiners: +-- "(en) ful orm" / "(den) fula ormen" / "(min) fula orm". +param + SpeciesP = IndefP | DefP Species ; + +-- We also have to be able to decide if a $CommNounPhrase$ is complex +-- (to form the definite form: "bilen" / "den stora bilen"). + +oper + IsComplexCN : Type = Bool ; + +-- Coercions between simple $Species$ and $SpeciesP$: + unSpeciesP : SpeciesP -> Species = \b -> + case b of {IndefP => Indef ; DefP p => p} ; -- bil/bil/bilen + unSpeciesAdjP : SpeciesP -> Species = \b -> + case b of {IndefP => Indef ; DefP _ => Def} ; -- gammal/gamla/gamla + +-- Here's the type itself. + CommNounPhrase : Type = + {s : Number => SpeciesP => Case => Str ; + g : Gender ; x : Sex ; p : IsComplexCN} ; + +-- To use a $CommNoun$ as $CommNounPhrase$. + noun2CommNounPhrase : CommNoun -> CommNounPhrase = \hus -> + {s = \\n,b,c => hus.s ! n ! unSpeciesP b ! c ; + g = hus.g ; x = hus.x ; p = False} ; + + n2n = noun2CommNounPhrase ; + + +--2 Noun Phrases +-- +-- The worst case for noun phrases is pronouns, which have inflection +-- in (what is syntactically) their genitive. Most noun phrases can +-- ignore this variation. + +oper + npCase : NPForm -> Case = \c -> case c of {PGen _ => Gen ; _ => Nom} ; + mkNPForm : Case -> NPForm = \c -> case c of {Gen => PGen APl ; _ => PNom} ; + + NounPhrase : Type = {s : NPForm => Str ; g : Gender ; n : Number} ; + +-- Proper names are a simple kind of noun phrases. However, we want to +-- anticipate the rule that proper names can be modified by +-- adjectives, even though noun phrases in general cannot - hence the sex. + + ProperName : Type = {s : Case => Str ; g : Gender ; x : Sex} ; + + mkProperName : Str -> Gender -> Sex -> ProperName = \john,g,x -> + {s = table {Nom => john ; Gen => john + "s"} ; g = g ; x = x} ; + + nameNounPhrase : ProperName -> NounPhrase = + \john -> {s = table {c => john.s ! npCase c} ; g = john.g ; n = Sg} ; + + regNameNounPhrase : Str -> Gender -> Sex -> NounPhrase = \john,g,x -> + nameNounPhrase (mkProperName john g x) ; + + pronNounPhrase : ProPN -> NounPhrase = \jag -> + {s = jag.s ; g = jag.h1 ; n = jag.h2} ; + +-- The following construction has to be refined for genitive forms: +-- "vi tre", "oss tre" are OK, but "vår tres" is not. + + Numeral : Type = {s : Case => Str} ; + + pronWithNum : ProPN -> Numeral -> ProPN = \we,two -> + {s = \\c => we.s ! c ++ two.s ! npCase c ; + h1 = we.h1 ; + h2 = we.h2 ; + h3 = we.h3 + } ; + + noNum : Numeral = {s = \\_ => []} ; + +-- Formal subjects + + npMan = nameNounPhrase (mkProperName "man" Utr Masc) ; + npDet = nameNounPhrase (mkProperName "det" Neutr NoMasc) ; + +--2 Determiners +-- +-- Determiners are inflected according to noun in gender and sex. +-- The number and species of the noun are determined by the determiner. + + Determiner : Type = {s : Gender => Sex => Str ; n : Number ; b : SpeciesP} ; + +-- This is the rule for building noun phrases. + + detNounPhrase : Determiner -> CommNounPhrase -> NounPhrase = \en, man -> + {s = table {c => en.s ! man.g ! man.x ++ man.s ! en.n ! en.b ! npCase c} ; + g = man.g ; n = en.n} ; + +-- The following macros are sufficient to define most determiners. +-- All $SpeciesP$ values come into question: +-- "en god vän" - "min gode vän" - "den gode vännen". + + DetSg : Type = Gender => Sex => Str ; + DetPl : Type = Str ; + + mkDeterminerSg : DetSg -> SpeciesP -> Determiner = \en, b -> + {s = en ; n = Sg ; b = b} ; + + mkDeterminerPl : DetPl -> SpeciesP -> Determiner = \alla,b -> + mkDeterminerPlNum alla b noNum ; + + mkDeterminerPlNum : DetPl -> SpeciesP -> Numeral -> Determiner = \alla,b,n -> + {s = \\_,_ => alla ++ n.s ! Nom ; + n = Pl ; + b = b + } ; + + detSgInvar : Str -> DetSg = \varje -> table {_ => table {_ => varje}} ; + +-- A large class of determiners can be built from a gender-dependent table. + + mkDeterminerSgGender : (Gender => Str) -> SpeciesP -> Determiner = \en -> + mkDeterminerSg (table {g => table {_ => en ! g}}) ; + + mkDeterminerSgGender2 : Str -> Str -> SpeciesP -> Determiner = \en,ett -> + mkDeterminerSgGender (table {Utr => en ; Neutr => ett}) ; + +-- Here are some examples. We are in fact doing some ad hoc morphology here, +-- instead of importing the lexicon. + + varjeDet = mkDeterminerSg (detSgInvar "varje") IndefP ; + allaDet = mkDeterminerPl "alla" IndefP ; + enDet = mkDeterminerSgGender artIndef IndefP ; + + flestaDet = mkDeterminerPl ["de flesta"] IndefP ; + vilkenDet = mkDeterminerSgGender + (table {Utr => "vilken" ; Neutr => "vilket"}) IndefP ; + vilkaDet = mkDeterminerPl "vilka" IndefP ; + + vilkDet : Number -> Determiner = \n -> case n of { + Sg => vilkenDet ; + Pl => vilkaDet + } ; + + någDet : Number -> Determiner = \n -> case n of { + Sg => mkDeterminerSgGender + (table {Utr => "någon" ; Neutr => "något"}) IndefP ; + Pl => mkDeterminerPl "några" IndefP + } ; + + +-- Genitives of noun phrases can be used like determiners, to build noun phrases. +-- The number argument makes the difference between "min bil" - "mina bilar". + + npGenDet : Number -> Numeral -> NounPhrase -> CommNounPhrase -> NounPhrase = + \n,tre,huset,vin -> { + s = \\c => case n of { + Sg => huset.s ! PGen (ASg vin.g) ++ + vin.s ! Sg ! DefP Indef ! npCase c ; + Pl => huset.s ! PGen APl ++ tre.s ! Nom ++ + vin.s ! Pl ! DefP Indef ! npCase c + } ; + g = vin.g ; + n = n + } ; + +-- *Bare plural noun phrases* like "män", "goda vänner", are built without a +-- determiner word. But a $Numeral$ may occur. + + plurDet : CommNounPhrase -> NounPhrase = plurDetNum noNum ; + + plurDetNum : Numeral -> CommNounPhrase -> NounPhrase = \num,cn -> + {s = \\c => num.s ! Nom ++ cn.s ! Pl ! IndefP ! npCase c ; + g = cn.g ; + n = Pl + } ; + +-- Definite phrases in Swedish are special, since determiner may be absent +-- depending on if the noun is complex: "bilen" - "den nya bilen". + + denDet : CommNounPhrase -> NounPhrase = \cn -> + detNounPhrase + (mkDeterminerSgGender (table {g => artDef ! cn.p ! ASg g}) (DefP Def)) cn ; + deDet : Numeral -> CommNounPhrase -> NounPhrase = \n,cn -> + detNounPhrase (mkDeterminerPlNum (artDef ! cn.p ! APl) (DefP Def) n) cn ; + +-- It is useful to have macros for indefinite and definite, singular and plural +-- noun-phrase-like syncategorematic expressions. + + indefNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n -> + indefNounPhraseNum n noNum ; + + indefNounPhraseNum : Number -> Numeral -> CommNounPhrase -> NounPhrase = + \n,num,hus -> + case n of { + Sg => detNounPhrase enDet hus ; + Pl => plurDetNum num hus + } ; + + defNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n -> + defNounPhraseNum n noNum ; + + defNounPhraseNum : Number -> Numeral -> CommNounPhrase -> NounPhrase = + \n,num,hus -> case n of { + Sg => denDet hus ; + Pl => deDet num hus + } ; + + indefNoun : Number -> CommNounPhrase -> Str = \n,man -> case n of { + Sg => artIndef ! man.g ++ man.s ! Sg ! IndefP ! Nom ; + Pl => man.s ! Pl ! IndefP ! Nom + } ; + +-- Constructions like "tanken att två är jämnt" are formed at the +-- first place as common nouns, so that one can also have "ett förslag att...". + + nounThatSentence : CommNounPhrase -> Sentence -> CommNounPhrase = \tanke,x -> + {s = \\n,d,c => tanke.s ! n ! d ! c ++ "att" ++ x.s ! Sub ; + g = tanke.g ; + x = tanke.x ; + p = tanke.p + } ; + + +--2 Adjectives +--3 Simple adjectives +-- +-- A special type of adjectives just having positive forms (for semantic reasons) +-- is useful, e.g. "finsk", "trekantig". + + Adjective : Type = {s : AdjFormPos => Case => Str} ; + + extAdjective : Adj -> Adjective = \adj -> + {s = table {f => table {c => adj.s ! AF (Posit f) c}}} ; + +-- Coercions between the compound gen-num type and gender and number: + + gNum : Gender -> Number -> GenNum = \g,n -> + case n of {Sg => ASg g ; Pl => APl} ; + + genGN : GenNum -> Gender = \gn -> + case gn of {ASg g => g ; _ => Utr} ; + numGN : GenNum -> Number = \gn -> + case gn of {ASg _ => Sg ; APl => Pl} ; + +--3 Adjective phrases +-- +-- An adjective phrase may contain a complement, e.g. "yngre än Rolf". +-- Then it is used as postfix in modification, e.g. "en man yngre än Rolf". + + IsPostfixAdj = Bool ; + + AdjPhrase : Type = Adjective ** {p : IsPostfixAdj} ; + +-- Simple adjectives are not postfix: + + adj2adjPhrase : Adjective -> AdjPhrase = \ny -> ny ** {p = False} ; + +--3 Comparison adjectives + +-- We take comparison adjectives directly from +-- the lexicon, which has full adjectives: + + AdjDegr = Adj ; + +-- Each of the comparison forms has a characteristic use: +-- +-- Positive forms are used alone, as adjectival phrases ("ung"). + + positAdjPhrase : AdjDegr -> AdjPhrase = \ung -> + {s = table {a => \\c => ung.s ! AF (Posit a) c} ; + p = False + } ; + +-- Comparative forms are used with an object of comparison, as +-- adjectival phrases ("yngre än Rolf"). + + comparAdjPhrase : AdjDegr -> NounPhrase -> AdjPhrase = \yngre,rolf -> + {s = \\_, c => yngre.s ! AF Compar Nom ++ "än" ++ rolf.s ! mkNPForm c ; + p = True + } ; + +-- Superlative forms are used with a modified noun, picking out the +-- maximal representative of a domain ("den yngste mannen"). + + superlNounPhrase : AdjDegr -> CommNounPhrase -> NounPhrase = \yngst,man -> + {s = \\c => let {gn = gNum man.g Sg} in + artDef ! True ! gn ++ + yngst.s ! AF (Super SupWeak) Nom ++ + man.s ! Sg ! DefP Def ! npCase c ; + g = man.g ; + n = Sg + } ; + +-- Moreover, superlatives can be used alone as adjectival phrases +-- ("yngst", "den yngste" - in free variation). +-- N.B. the former is only permitted in predicative position. + + superlAdjPhrase : AdjDegr -> AdjPhrase = \ung -> + {s = \\a,c => variants { + --- artDef ! True ! gn ++ yngst.s ! AF (Super SupWeak) c + ung.s ! AF (Super SupStrong) c + } ; + p = False + } ; + +--3 Two-place adjectives +-- +-- A two-place adjective is an adjective with a preposition used before +-- the complement. (Rem. $Preposition = Str$). + + AdjCompl = Adjective ** {s2 : Preposition} ; + + complAdj : AdjCompl -> NounPhrase -> AdjPhrase = \förtjust,dig -> + {s = \\a,c => förtjust.s ! a ! c ++ förtjust.s2 ++ dig.s ! PAcc ; + p = True + } ; + + +--3 Modification of common nouns +-- +-- The two main functions of adjective are in predication ("Johan är ung") +-- and in modification ("en ung man"). Predication will be defined +-- later, in the chapter on verbs. + + modCommNounPhrase : AdjPhrase -> CommNounPhrase -> CommNounPhrase = \God,Nybil -> + {s = \\n, b, c => + let { + god = God.s ! mkAdjForm (unSpeciesAdjP b) n Nybil.g Nybil.x ! Nom ; + nybil = Nybil.s ! n ! b ! c + } in + preOrPost God.p nybil god ; + g = Nybil.g ; + x = Nybil.x ; + p = True} ; + +-- A special case is modification of a noun that has not yet been modified. +-- But it is simply a special case. + + modCommNoun : Adjective -> CommNoun -> CommNounPhrase = \god,bil -> + modCommNounPhrase (adj2adjPhrase god) (n2n bil) ; + +-- We have used a straightforward +-- method building adjective forms from simple parameters. + + mkAdjForm : Species -> Number -> Gender -> Sex -> AdjFormPos = \b,n,g,x -> + case of { + => Strong (ASg g) ; + => Strong APl ; + => Weak (AxSg x) ; ---- add masc! + => Weak AxPl + } ; + + +--2 Function expressions + +-- A function expression is a common noun together with the +-- preposition prefixed to its argument ("mor till x"). +-- The type is analogous to two-place adjectives and transitive verbs. + + Function = CommNoun ** {s2 : Preposition} ; + + mkFun : CommNoun -> Preposition -> Function = \f,p -> + f ** {s2 = p} ; + +-- The application of a function gives, in the first place, a common noun: +-- "mor/mödrar till Johan". From this, other rules of the resource grammar +-- give noun phrases, such as "modern till Johan", "mödrarna till Johan", +-- "mödrarna till Johan och Maria", and "modern till Johan och Maria" (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 = \värde,x -> + noun2CommNounPhrase + {s = \\n,b => table { + Gen => nonExist ; + _ => värde.s ! n ! b ! Nom ++ värde.s2 ++ x.s ! PAcc + } ; + g = värde.g ; + x = värde.x + } ; + +-- It is possible to use a function word as a common noun; the semantics is +-- often existential or indexical. + + funAsCommNounPhrase : Function -> CommNounPhrase = + noun2CommNounPhrase ; + +-- The following is an aggregate corresponding to the original function application +-- producing "Johans mor" and "modern till Johan". It does not appear in the +-- resource grammar API any longer. + + appFun : Bool -> Function -> NounPhrase -> NounPhrase = \coll,värde,x -> + let {n = x.n ; nf = if_then_else Number coll Sg n} in + variants { + defNounPhrase nf (appFunComm värde x) ; + npGenDet nf noNum x (noun2CommNounPhrase värde) + } ; + +-- Two-place functions add one argument place. + + Function2 = Function ** {s3 : Preposition} ; + +-- Their application starts by filling the first place. + + appFun2 : Function2 -> NounPhrase -> Function = \flyg, paris -> + {s = \\n,d,c => flyg.s ! n ! d ! c ++ flyg.s2 ++ paris.s ! PAcc ; + g = flyg.g ; + x = flyg.x ; + s2 = flyg.s3 + } ; + + +--2 Verbs + +-- Although the Swedish lexicon has full verb inflection, +-- we have limited this first version of the resource syntax to +-- verbs in present tense. Their mode can be infinitive, imperative, and indicative. + + +--3 Verb phrases +-- +-- Sentence forms are tense-mood combinations used in sentences and +-- verb phrases. + +param + Tense = Present | Past ; + Anteriority = Simul | Anter ; + SForm = + VIndic Tense Anteriority + | VFut Anteriority + | VCondit Anteriority + | VImperat + | VInfinit Anteriority ; + +oper + verbSForm : Verbum -> Voice -> SForm -> {fin,inf : Str} = \se,vo,sf -> + let + tense : Tense -> Voice -> VFin = \t,v -> case t of { + Present => Pres Ind v ; + Past => Pret Ind v + } ; + simple : VerbForm -> {fin,inf : Str} = \v -> { + fin = se.s ! v ; + inf = [] + } ; + compound : Str -> Str -> {fin,inf : Str} = \x,y -> { + fin = x ; + inf = y + } ; + see : Voice -> Str = \v -> (se.s ! (VI (Inf v))) ; + sett : Voice -> Str = \v -> (se.s ! (VI (Supin v))) ; + hasett : Voice -> Str = \v -> "ha" ++ sett v + + in case sf of { + VIndic t Simul => simple (VF (tense t vo)) ; + VIndic Present Anter => compound "har" (sett vo) ; + VIndic Past Anter => compound "hade" (sett vo) ; + VFut Simul => compound "ska" (see vo) ; + VFut Anter => compound "ska" (hasett vo) ; + VCondit Simul => compound "skulle" (see vo) ; + VCondit Anter => compound "skulle" (hasett vo) ; + VImperat => simple (VF Imper) ; --- no passive + VInfinit Simul => simple (VI (Inf vo)) ; + VInfinit Anter => compound "ha" (sett vo) + } ; + + useVerb : Verb -> (Gender => Number => Str) -> VerbGroup = \verb,arg -> + let aer = verbSForm verb Act in { + s = \\sf => (aer sf).fin ; + s2 = negation ; + s3 = \\sf,g,n => (aer sf).inf ++ arg ! g ! n + } ; + +-- Verb phrases are discontinuous: the parts of a verb phrase are +-- (s) an inflected verb, (s2) verb adverbials (such as negation), and +-- (s3) complement. This discontinuity is needed in sentence formation +-- to account for word order variations. No particle needs to be retained. + + VerbPhrase : Type = { + s : SForm => Str ; + s2 : Str ; + s3 : SForm => Gender => Number => Str + } ; + VerbGroup : Type = { + s : SForm => Str ; + s2 : Bool => Str ; + s3 : SForm => Gender => Number => Str + } ; + + predVerbGroup : Bool -> VerbGroup -> VerbPhrase = \b,vg -> { + s = vg.s ; + s2 = vg.s2 ! b ; + s3 = vg.s3 + } ; + +-- A simple verb can be made into a verb phrase with an empty complement. +-- There are two versions, depending on if we want to negate the verb. +-- N.B. negation is *not* a function applicable to a verb phrase, since +-- double negations with "inte" are not grammatical. + + predVerb : Verb -> VerbGroup = \se -> useVerb se (\\_,_ => se.s1) ; + + negation : Bool => Str = \\b => if_then_Str b [] "inte" ; + +-- Verb phrases can also be formed from adjectives ("är snäll"), +-- common nouns ("är en man"), and noun phrases ("är den yngste mannen"). +-- The third rule is overgenerating: "är varje man" has to be ruled out +-- on semantic grounds. + + vara : (Gender => Number => Str) -> VerbGroup = + useVerb (verbVara ** {s1 = []}) ; + + predAdjective : Adjective -> VerbGroup = \arg -> + vara (\\g,n => arg.s ! mkAdjForm Indef n g NoMasc ! Nom) ; + + predCommNoun : CommNounPhrase -> VerbGroup = \man -> + vara (\\_,n => indefNoun n man) ; + + predNounPhrase : NounPhrase -> VerbGroup = \john -> + vara (\\_,_ => john.s ! PNom) ; + + predAdverb : Adverb -> VerbGroup = \ute -> + vara (\\_,_ => ute.s) ; + +--3 Transitive verbs +-- +-- Transitive verbs are verbs with a preposition 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*. + + TransVerb : Type = Verb ** {s2 : Preposition} ; + + mkTransVerb : Verb -> Preposition -> TransVerb = \v,p -> + v ** {s2 = p} ; + + mkDirectVerb : Verb -> TransVerb = \v -> + mkTransVerb v nullPrep ; + + nullPrep : Preposition = [] ; + + + extTransVerb : Verbum -> Preposition -> TransVerb = \v,p -> + mkTransVerb (v ** {s1 = []}) p ; + + +-- The rule for using transitive verbs is the complementization rule: + + complTransVerb : TransVerb -> NounPhrase -> VerbGroup = \se,dig -> + useVerb se (\\_,_ => se.s1 ++ se.s2 ++ dig.s ! PAcc) ; + +-- Transitive verbs with accusative objects can be used passively. +-- The function does not check that the verb is transitive. +-- Therefore, the function can also be used for "han löps", etc. +-- The syntax is the same as for active verbs, with the choice of the +-- "s" passive form. + + passVerb : Verb -> VerbGroup = \se -> + let ses = verbSForm se Pass in { + s = \\sf => (ses sf).fin ; + s2 = negation ; + s3 = \\sf,g,n => (ses sf).inf ++ se.s1 + } ; + +-- 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 = \love -> + love ; + +-- *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 ** {s3 : Preposition} ; + + mkDitransVerb : Verb -> Preposition -> Preposition -> DitransVerb = \v,p1,p2 -> + v ** {s2 = p1 ; s3 = p2} ; + + complDitransVerb : + DitransVerb -> NounPhrase -> NounPhrase -> VerbGroup = \ge,dig,vin -> + useVerb + ge + (\\_,_ => ge.s1 ++ ge.s2 ++ dig.s ! PAcc ++ ge.s3 ++ vin.s ! PAcc) ; + + +--2 Adverbs +-- +-- Adverbs that modify verb phrases are either post- or pre-verbal. +-- As a rule of thumb, simple adverbs ("bra","alltid") are pre-verbal, +-- but this is not always the case ("här" is post-verbal). +-- Even prepositional phrases can be both +-- ("att han i alla fall skulle komma"). + + Adverb : Type = SS ** {isPost : Bool} ; + PrepPhrase : Type = Adverb ; + + advPre : Str -> Adverb = \alltid -> ss alltid ** {isPost = False} ; + advPost : Str -> Adverb = \bra -> ss bra ** {isPost = True} ; + + adVerbPhrase : VerbPhrase -> Adverb -> VerbPhrase = \spelar, bra -> + let {postp = bra.isPost} in + { + --- this unfortunately generates VP#2 ::= VP#2 + s = spelar.s ; + s2 = (if_then_else Str postp [] bra.s) ++ spelar.s2 ; + s3 = \\sf,g,n => spelar.s3 ! sf ! g ! n ++ (if_then_else Str postp bra.s []) + } ; + + advAdjPhrase : SS -> AdjPhrase -> AdjPhrase = \mycket, dyr -> + {s = \\a,c => mycket.s ++ dyr.s ! a ! c ; + p = dyr.p + } ; + +-- Adverbials are typically generated by prefixing prepositions. +-- The rule for creating locative noun phrases by the preposition "i" +-- is a little shaky: "i Sverige" but "på Island". + + prepPhrase : Preposition -> NounPhrase -> Adverb = \i,huset -> + advPost (i ++ huset.s ! PAcc) ; + + locativeNounPhrase : NounPhrase -> Adverb = + prepPhrase "i" ; + +-- This is a source of the "mannen med teleskopen" ambiguity, and may produce +-- strange things, like "bilar alltid" (while "bilar idag" is OK). +-- Semantics will have to make finer distinctions among adverbials. + + advCommNounPhrase : CommNounPhrase -> PrepPhrase -> CommNounPhrase = \bil,idag -> + {s = \\n, b, c => bil.s ! n ! b ! c ++ idag.s ; + g = bil.g ; + x = bil.x ; + p = bil.p} ; + + +--2 Sentences +-- +-- Sentences depend on a *word order parameter* selecting between main clause, +-- inverted, and subordinate clause. + +param + Order = Main | Inv | Sub ; + +oper + Sentence : Type = SS1 Order ; + +-- This is the traditional $S -> NP VP$ rule. It takes care of both +-- word order and agreement. + + predVerbPhrase : NounPhrase -> VerbPhrase -> Sentence = + \Jag, serdiginte -> + let { + jag = Jag.s ! PNom ; + t = VIndic Present Simul ; ---- to be made parameter of S + ser = serdiginte.s ! t ; + dig = serdiginte.s3 ! t ! Jag.g ! Jag.n ; + inte = serdiginte.s2 + } in + {s = table { + Main => jag ++ ser ++ inte ++ dig ; + Inv => ser ++ jag ++ inte ++ dig ; + Sub => jag ++ inte ++ ser ++ dig + } + } ; + +param + ClForm = + ClIndic Tense Anteriority Order + | ClFut Anteriority Order + | ClCondit Anteriority Order + | ClInfinit Anteriority -- "naked infinitive" clauses + ; + +oper cl2s : ClForm -> {o : Order ; sf : SForm} = \c -> case c of { + ClIndic t a o => {o = o ; sf = VIndic t a} ; + ClFut a o => {o = o ; sf = VFut a} ; + ClCondit a o => {o = o ; sf = VCondit a} ; + ClInfinit a => {o = Sub ; sf = VInfinit a} -- "jag såg John inte hälsa" + } ; + + Clause = {s : Bool => ClForm => Str} ; + + predVerbGroupClause : NounPhrase -> VerbGroup -> Clause = + \Jag, serdiginte -> { + s = \\b,c => let { + jag = Jag.s ! (case c of {ClInfinit _ => PAcc ; _ => PNom}) ; + osf = cl2s c ; + t = osf.sf ; + o = osf.o ; + ser = serdiginte.s ! t ; + dig = serdiginte.s3 ! t ! Jag.g ! Jag.n ; + inte = serdiginte.s2 ! b + } in + case o of { + Main => jag ++ ser ++ inte ++ dig ; + Inv => ser ++ jag ++ inte ++ dig ; + Sub => jag ++ inte ++ ser ++ dig + } + } ; + + +--3 Sentence-complement verbs +-- +-- Sentence-complement verbs take sentences as complements. + + SentenceVerb : Type = Verb ; + + complSentVerb : SentenceVerb -> Sentence -> VerbGroup = \se,duler -> + useVerb se (\\_,_ => se.s1 ++ optStr "att" ++ duler.s ! Main) ; + +--3 Verb-complement verbs +-- +-- Verb-complement verbs take verb phrases as complements. +-- They can be auxiliaries ("kan", "måste") or ordinary verbs +-- ("försöka"); this distinction cannot be done in the multilingual +-- API and leads to some anomalies in Swedish, but less so than in English. + + VerbVerb : Type = Verb ** {isAux : Bool} ; + + complVerbVerb : VerbVerb -> VerbGroup -> VerbGroup = \vilja, simma -> + useVerb vilja + (\\g,n => + vilja.s1 ++ + if_then_Str vilja.isAux [] "att" ++ + simma.s ! VInfinit Simul ++ simma.s2 ! True ++ ---- Anter! + simma.s3 ! VInfinit Simul ! g ! n) ; + + +--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 the same relation to sentences as +-- transitive verbs have to verbs: it's like a *sentence taking a complement*. + + SentenceSlashNounPhrase : Type = Sentence ** {s2 : Preposition} ; + + slashTransVerb : Bool -> NounPhrase -> TransVerb -> SentenceSlashNounPhrase = + \b, Jag, se -> + let { + jag = Jag.s ! PNom ; + ser = se.s ! VF (Pres Ind Act) ; ---- other tenses + inte = negation ! b ++ se.s1 + } in + {s = table { + Main => jag ++ ser ++ inte ; + Inv => ser ++ jag ++ inte ; + Sub => jag ++ inte ++ ser + } ; + s2 = se.s2 + } ; + + +--2 Relative pronouns and relative clauses +-- +-- Relative pronouns can be nominative, accusative, or genitive, and +-- they depend on gender and number just like adjectives. +-- Moreover they may or may not carry their own genders: for instance, +-- "som" just transmits the gender of a noun ("tal som är primt"), whereas +-- "vars efterföljare" is $Utrum$ independently of the noun +-- ("tal vars efterföljare är prim"). +-- This variation is expressed by the $RelGender$ type. + + RelPron : Type = {s : RelCase => GenNum => Str ; g : RelGender} ; + +param + RelGender = RNoGen | RG Gender ; + +-- The following functions are selectors for relative-specific parameters. + +oper + -- this will be needed in "tal som är jämnt" / "tal vars efterföljare är jämn" + mkGenderRel : RelGender -> Gender -> Gender = \rg,g -> case rg of { + RG gen => gen ; + _ => g + } ; + + relCase : RelCase -> Case = \c -> case c of { + RGen => Gen ; + _ => Nom + } ; + +-- The simplest relative pronoun has no gender of its own. As accusative variant, +-- it has the omission of the pronoun ("mannen (som) jag ser"). + + identRelPron : RelPron = + {s = table { + RNom => \\_ => "som" ; + RAcc => \\_ => variants {"som" ; []} ; + RGen => \\_ => "vars" ; + RPrep => pronVilken + } ; + g = RNoGen + } ; + +-- Composite relative pronouns have the same variation as function +-- applications ("efterföljaren till vilket" - "vars efterföljare"). + + funRelPron : Function -> RelPron -> RelPron = \värde,vilken -> + {s = \\c,gn => + variants { + vilken.s ! RGen ! gn ++ värde.s ! numGN gn ! Indef ! relCase c ; + värde.s ! numGN gn ! Def ! Nom ++ värde.s2 ++ vilken.s ! RPrep ! gn + } ; + g = RG värde.g + } ; + +-- Relative clauses can be formed from both verb phrases ("som sover") and +-- slash expressions ("som jag ser"). The latter has moreover the variation +-- as for the place of the preposition ("som jag talar om" - "om vilken jag talar"). + + RelClause : Type = {s : GenNum => Str} ; + + relVerbPhrase : RelPron -> VerbPhrase -> RelClause = \som,sover -> + {s = \\gn => + som.s ! RNom ! gn ++ sover.s2 ++ sover.s ! VIndic Present Simul + ---- Past and Anter ! + ++ + sover.s3 ! VIndic Present Simul ! mkGenderRel som.g (genGN gn) ! numGN gn + } ; + + relSlash : RelPron -> SentenceSlashNounPhrase -> RelClause = \som,jagTalar -> + {s = \\gn => + let {jagtalar = jagTalar.s ! Sub ; om = jagTalar.s2} in + variants { + som.s ! RAcc ! gn ++ jagtalar ++ om ; + om ++ som.s ! RPrep ! gn ++ jagtalar + } + } ; + +-- A 'degenerate' relative clause is the one often used in mathematics, e.g. +-- "tal x sådant att x är primt". + + relSuch : Sentence -> RelClause = \A -> + {s = \\g => pronSådan ! g ++ "att" ++ A.s ! Sub} ; + +-- 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. + + modRelClause : CommNounPhrase -> RelClause -> CommNounPhrase = \man,somsover -> + {s = \\n,b,c => man.s ! n ! b ! c ++ somsover.s ! gNum man.g n ; + g = man.g ; + x = man.x ; + p = False + } ; + +-- N.B. we do not get the determinative pronoun +-- construction "den man som sover" in this way, but only "mannen som sover". +-- Thus we need an extra rule: + + detRelClause : Number -> CommNounPhrase -> RelClause -> NounPhrase = + \n,man,somsover -> + {s = \\c => let {gn = gNum man.g n} in + artDef ! True ! gn ++ + man.s ! n ! DefP Indef ! npCase c ++ somsover.s ! gn ; + g = man.g ; + n = n + } ; + + +--2 Interrogative pronouns +-- +-- If relative pronouns are adjective-like, interrogative pronouns are +-- noun-phrase-like. Actually we can use the very same type! + + IntPron : Type = NounPhrase ; + +-- In analogy with relative pronouns, we have a rule for applying a function +-- to a relative pronoun to create a new one. We can reuse the rule applying +-- functions to noun phrases! + + funIntPron : Function -> IntPron -> IntPron = + appFun False ; + +-- There is a variety of simple interrogative pronouns: +-- "vilken bil", "vem", "vad". + + nounIntPron : Number -> CommNounPhrase -> IntPron = \n -> + detNounPhrase (vilkDet n) ; + + intPronWho : Number -> IntPron = \num -> { + s = table { + PGen _ => "vems" ; + _ => "vem" + } ; + g = Utr ; + n = num + } ; + + intPronWhat : Number -> IntPron = \num -> { + s = table { + PGen _ => nonExist ; --- + _ => "vad" + } ; + n = num ; + g = Neutr + } ; + +--2 Utterances + +-- By utterances we mean whole 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 -> postfixSS "." (defaultSentence x) ; + interrogUtt : Question -> Utterance = \x -> postfixSS "?" (defaultQuestion x) ; + + +--2 Questions +-- +-- Questions are either direct ("vem tog bollen") or indirect +-- ("vem som tog bollen"). + +param + QuestForm = DirQ | IndirQ ; + +oper + Question = SS1 QuestForm ; + +--3 Yes-no questions +-- +-- Yes-no questions are used both independently ("tog du bollen") +-- and after interrogative adverbials ("varför tog du bollen"). +-- It is economical to handle with these two cases by the one +-- rule, $questVerbPhrase'$. The only difference is if "om" appears +-- in the indirect form. + + questVerbPhrase : NounPhrase -> VerbPhrase -> Question = + questVerbPhrase' False ; + + questVerbPhrase' : Bool -> NounPhrase -> VerbPhrase -> Question = + \adv,du,sover -> + let {dusover = (predVerbPhrase du sover).s} in + {s = table { + DirQ => dusover ! Inv ; + IndirQ => (if_then_else Str adv [] "om") ++ dusover ! Sub + } + } ; + +--3 Wh-questions +-- +-- Wh-questions are of two kinds: ones that are like $NP - VP$ sentences, +-- others that are line $S/NP - NP$ sentences. + + intVerbPhrase : IntPron -> VerbPhrase -> Question = \vem,sover -> + let {vemsom : NounPhrase = + {s = \\c => vem.s ! c ++ "som" ; g = vem.g ; n = vem.n} + } in + {s = table { + DirQ => (predVerbPhrase vem sover).s ! Main ; + IndirQ => (predVerbPhrase vemsom sover).s ! Sub + } + } ; + + intSlash : IntPron -> SentenceSlashNounPhrase -> Question = \Vem, jagTalar -> + let { + vem = Vem.s ! PAcc ; + jagtalar = jagTalar.s ! Sub ; + talarjag = jagTalar.s ! Inv ; + om = jagTalar.s2 + } in + {s = table { + DirQ => variants { + vem ++ talarjag ++ om ; + om ++ vem ++ talarjag + } ; + IndirQ => variants { + vem ++ jagtalar ++ om ; + om ++ vem ++ jagtalar + } + } + } ; + +--3 Interrogative adverbials +-- +-- These adverbials will be defined in the lexicon: they include +-- "när", "var", "hur", "varför", etc, which are all invariant one-word +-- expressions. In addition, they can be formed by adding prepositions +-- to interrogative pronouns, in the same way as adverbials are formed +-- from noun phrases. N.B. we rely on record subtyping when ignoring the +-- position component. + + IntAdverb = SS ; + + prepIntAdverb : Preposition -> IntPron -> IntAdverb = + prepPhrase ; + +-- A question adverbial can be applied to anything, and whether this makes +-- sense is a semantic question. + + questAdverbial : IntAdverb -> NounPhrase -> VerbPhrase -> Question = + \hur, du, mår -> + {s = \\q => hur.s ++ (questVerbPhrase' True du mår).s ! q} ; + + +--2 Imperatives +-- +-- We only consider second-person imperatives. + + Imperative = SS1 Number ; + + imperVerbPhrase : VerbPhrase -> Imperative = \titta -> + {s = \\n => titta.s ! VImperat ++ titta.s2 ++ titta.s3 ! VImperat ! Utr ! n} ; + + imperUtterance : Number -> Imperative -> Utterance = \n,I -> + ss (I.s ! n ++ "!") ; + +--2 Sentence adverbials +-- +-- This class covers adverbials such as "annars", "därför", which are prefixed +-- to a sentence to form a phrase. + + advSentence : SS -> Sentence -> Utterance = \annars,soverhan -> + ss (annars.s ++ soverhan.s ! Inv ++ ".") ; + + +--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 ("och", "eller") or distributed ("både - och", "antingen - eller"). +-- +-- The conjunction has an inherent number, which is used when conjoining +-- noun phrases: "John och Mary är rika" vs. "John eller Mary är rik"; in the +-- case of "eller", 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 = {s1,s2 : Order => Str} ; + + twoSentence : (_,_ : Sentence) -> ListSentence = + CO.twoTable Order ; + + consSentence : ListSentence -> Sentence -> ListSentence = + CO.consTable Order 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. "månen lyser, solen skiner och stjärnorna blinkar". + + conjunctSentence : Conjunction -> ListSentence -> Sentence = + CO.conjunctTable Order ; + + conjunctOrd : Bool -> Conjunction -> CO.ListTable Order -> {s : Order => Str} = + \b,or,xs -> + {s = \\p => xs.s1 ! p ++ or.s ++ xs.s2 ! p} ; + + +-- To coordinate a list of sentences by a distributed conjunction, we place +-- the first part (e.g. "antingen") in front of the first element, the second +-- part ("eller") between the last two elements, and commas in the other slots. +-- For sentences this is really not used. + + conjunctDistrSentence : ConjunctionDistr -> ListSentence -> Sentence = + CO.conjunctDistrTable Order ; + +--3 Coordinating adjective phrases +-- +-- The structure is the same as for sentences. The result is a prefix adjective +-- if and only if all elements are prefix. + + ListAdjPhrase : Type = + {s1,s2 : AdjFormPos => Case => Str ; p : Bool} ; + + twoAdjPhrase : (_,_ : AdjPhrase) -> ListAdjPhrase = \x,y -> + CO.twoTable2 AdjFormPos Case x y ** {p = andB x.p y.p} ; + consAdjPhrase : ListAdjPhrase -> AdjPhrase -> ListAdjPhrase = \xs,x -> + CO.consTable2 AdjFormPos Case CO.comma xs x ** {p = andB xs.p x.p} ; + + conjunctAdjPhrase : Conjunction -> ListAdjPhrase -> AdjPhrase = \c,xs -> + CO.conjunctTable2 AdjFormPos Case c xs ** {p = xs.p} ; + + conjunctDistrAdjPhrase : ConjunctionDistr -> ListAdjPhrase -> AdjPhrase = \c,xs -> + CO.conjunctDistrTable2 AdjFormPos Case c xs ** {p = xs.p} ; + + +--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. +-- The gender is neuter if any of the components is. + + ListNounPhrase : Type = {s1,s2 : NPForm => Str ; g : Gender ; n : Number} ; + + twoNounPhrase : (_,_ : NounPhrase) -> ListNounPhrase = \x,y -> + CO.twoTable NPForm x y ** {n = conjNumber x.n y.n ; g = conjGender x.g y.g} ; + + consNounPhrase : ListNounPhrase -> NounPhrase -> ListNounPhrase = \xs,x -> + CO.consTable NPForm CO.comma xs x ** + {n = conjNumber xs.n x.n ; g = conjGender xs.g x.g} ; + + conjunctNounPhrase : Conjunction -> ListNounPhrase -> NounPhrase = \c,xs -> + CO.conjunctTable NPForm c xs ** {n = conjNumber c.n xs.n ; g = xs.g} ; + + conjunctDistrNounPhrase : ConjunctionDistr -> ListNounPhrase -> NounPhrase = + \c,xs -> + CO.conjunctDistrTable NPForm c xs ** {n = conjNumber c.n xs.n ; g = xs.g} ; + +-- We hve to define a calculus of numbers of genders. For numbers, +-- it is like the conjunction with $Pl$ corresponding to $False$. For genders, +-- $Neutr$ corresponds to $False$. + + conjNumber : Number -> Number -> Number = \m,n -> case of { + => Sg ; + _ => Pl + } ; + + conjGender : Gender -> Gender -> Gender = \m,n -> case of { + => Utr ; + _ => Neutr + } ; + + +--2 Subjunction +-- +-- Subjunctions ("om", "när", 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. "om du sover kommer björnen" +-- and "björnen kommer om du sover". + + Subjunction = SS ; + + subjunctSentence : Subjunction -> Sentence -> Sentence -> Sentence = \if, A, B -> + let {As = A.s ! Sub} in + {s = table { + Main => variants {if.s ++ As ++ "," ++ B.s ! Inv ; + B.s ! Main ++ "," ++ if.s ++ As} ; + o => B.s ! o ++ "," ++ if.s ++ As + } + } ; + + subjunctImperative : Subjunction -> Sentence -> Imperative -> Imperative = + \if, A, B -> + {s = \\n => subjunctVariants if A (B.s ! n)} ; + + subjunctQuestion : Subjunction -> Sentence -> Question -> Question = \if, A, B -> + {s = \\q => subjunctVariants if A (B.s ! q)} ; + + subjunctVariants : Subjunction -> Sentence -> Str -> Str = \if,A,B -> + let {As = A.s ! Sub} in + variants {if.s ++ As ++ "," ++ B ; B ++ "," ++ if.s ++ As} ; + + subjunctVerbPhrase : VerbPhrase -> Subjunction -> Sentence -> VerbPhrase = + \V, if, A -> + adVerbPhrase V (advPost (if.s ++ A.s ! Sub)) ; + +--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 "." (defaultNounPhrase john) ; + useCommonNounPhrase : Number -> CommNounPhrase -> Utterance = \n,car -> + useNounPhrase (indefNounPhrase n car) ; + +-- Here are some default forms. + + defaultNounPhrase : NounPhrase -> SS = \john -> + ss (john.s ! PNom) ; + + defaultQuestion : Question -> SS = \whoareyou -> + ss (whoareyou.s ! DirQ) ; + + defaultSentence : Sentence -> Utterance = \x -> ss (x.s ! Main) ; +} ; diff --git a/lib/resource/swedish/TestResourceSwe.gf b/lib/resource/swedish/TestResourceSwe.gf new file mode 100644 index 000000000..9d8ec6acb --- /dev/null +++ b/lib/resource/swedish/TestResourceSwe.gf @@ -0,0 +1,51 @@ +--# -path=.:../abstract:../../prelude + +concrete TestResourceSwe of TestResource = RulesSwe, StructuralSwe ** open MorphoSwe, SyntaxSwe in { + +flags startcat=Phr ; lexer=text ; unlexer=text ; + +-- a random sample from the lexicon + +lin + Big = stor_25 ; + Small = liten_1146 ; + Old = gammal_16 ; + Young = ung_29 ; + American = extAdjective (aFin "amerikansk") ; + Finnish = extAdjective (aFin "finsk") ; + Happy = aFin "lycklig" ; + Married = extAdjective (aAbstrakt "gift") ** {s2 = "med"} ; + Man = extCommNoun Masc man_1144 ; + Bar = extCommNoun NoMasc (sSak "bar") ; + Bottle = extCommNoun NoMasc (sApa "flask") ; + Woman = extCommNoun NoMasc (sApa "kvinn") ; + Car = extCommNoun NoMasc (sBil "bil") ; + House = extCommNoun NoMasc (sHus "hus") ; + Light = extCommNoun NoMasc (sHus "ljus") ; + Wine = extCommNoun NoMasc (sParti "vin") ; + Walk = vNopart gå_1174 ; + Run = vNopart (vFinna "spring" "sprang" "sprung") ; + Drink = extTransVerb (vFinna "drick" "drack" "druck") [] ; + Love = extTransVerb (vNopart (vTala "älsk")) [] ; + Send = extTransVerb (vNopart (vTala "skick")) [] ; + Wait = extTransVerb (vNopart (vTala "vänt")) "på" ; + Give = extTransVerb (vNopart (vFinna "giv" "gav" "giv")) [] ** {s3 = "till"} ; --- ge + Prefer = extTransVerb (vNopart (vFinna "föredrag" "föredrog" "föredrag")) [] ** + {s3 = "framför"} ; --- föredra + + Say = vNopart (vLeka "säg") ; --- works in present tense... + Prove = vNopart (vTala "bevis") ; + SwitchOn = mkDirectVerb (vFinna "sätt" "satte" "satt" ** {s1 = "på"}) ; + SwitchOff = mkDirectVerb (vLeka "stäng" ** {s1 = "av"}) ; + + Mother = mkFun (extCommNoun NoMasc mor_1) "till" ; + Uncle = mkFun (extCommNoun Masc farbror_8) "till" ; + Connection = mkFun (extCommNoun NoMasc (sVarelse "förbindelse")) "från" ** + {s3 = "till"} ; + + Always = advPre "alltid" ; + Well = advPost "bra" ; + + John = mkProperName "Johan" Utr Masc ; + Mary = mkProperName "Maria" Utr NoMasc ; +} ; diff --git a/lib/resource/swedish/TypesSwe.gf b/lib/resource/swedish/TypesSwe.gf new file mode 100644 index 000000000..d47049b4b --- /dev/null +++ b/lib/resource/swedish/TypesSwe.gf @@ -0,0 +1,165 @@ +--1 Swedish Word Classes and Morphological Parameters +-- +-- This is a resource module for Swedish morphology, defining the +-- morphological parameters and word classes of Swedish. It is aimed +-- to be complete w.r.t. the description of word forms. +-- However, it does not include those parameters that are not needed for +-- analysing individual words: such parameters are defined in syntax modules. +-- +-- This GF grammar was obtained from the functional morphology file TypesSw.hs +-- semi-automatically. The GF inflection engine obtained was obtained automatically. + +resource TypesSwe = open Prelude in { + +-- + +--2 Enumerated parameter types +-- +-- These types are the ones found in school grammars. +-- Their parameter values are atomic. + +param + Gender = Utr | Neutr ; + Number = Sg | Pl ; + Species = Indef | Def ; + Case = Nom | Gen ; + Sex = NoMasc | Masc ; + Mode = Ind | Cnj ; + Voice = Act | Pass ; + Degree = Pos | Comp | Sup ; + Person = P1 | P2 | P3 ; + +--2 Word classes and hierarchical parameter types +-- +-- Real parameter types (i.e. ones on which words and phrases depend) +-- are mostly hierarchical. The alternative would be cross-products of +-- simple parameters, but this would usually overgenerate. +-- + +--3 Substantives +-- +-- Substantives (= common nouns) have a parameter of type SubstForm. + +param SubstForm = SF Number Species Case ; + +-- Substantives moreover have an inherent gender. + +oper Subst : Type = {s : SubstForm => Str ; h1 : Gender} ; + +--3 Adjectives +-- +-- Adjectives are a very complex class, and the full table has as many as +-- 18 different forms. The major division is between the comparison degrees; +-- the comparative has only the 2 case forms, whereas the positive has 12 forms. + +param + AdjForm = AF AdjFormGrad Case ; + +-- The positive strong forms depend on gender: "en stor bil" - "ett stort hus". +-- But the weak forms depend on sex: "den stora bilen" - "den store mannen". +-- The plural never makes a gender-sex distinction. + + GenNum = ASg Gender | APl ; + SexNum = AxSg Sex | AxPl ; + + AdjFormPos = Strong GenNum | Weak SexNum ; + AdjFormSup = SupStrong | SupWeak ; + + AdjFormGrad = + Posit AdjFormPos + | Compar + | Super AdjFormSup ; + +oper + Adj : Type = {s : AdjForm => Str} ; + + adverbForm : AdjFormPos = Strong (ASg Neutr) ; + +--3 Verbs +-- +-- Verbs have 9 finite forms and as many as 18 infinite forms; the large number +-- of the latter comes from adjectives. + +oper Verbum : Type = {s : VerbForm => Str} ; + +param + VFin = + Pres Mode Voice + | Pret Mode Voice + | Imper ; --- no passive + + VInf = + Inf Voice + | Supin Voice + | PtPres Case + | PtPret AdjFormPos Case ; + + VerbForm = + VF VFin + | VI VInf ; + +-- However, the syntax only needs a simplified verb category, with +-- present tense only. Such a verb can be extracted from the full verb, +-- and a choice can be made between an active and a passive (deponent) verb. +-- Active verbs continue to have passive forms. But we add an extra field $s1$ +-- for a verb particle, as e.g. in "se upp". + +param + VMode = Infinit | Indicat | Imperat ; + VForm = VPres VMode Voice ; + +oper + Verb : Type = {s : VerbForm => Str ; s1 : Str} ; + + vNopart : Verbum -> Verb = \v -> v ** {s1 = []} ; + +{- deprecated + extVerbPart : Voice -> Verbum -> Str -> Verb = \v,verb,upp -> {s = table { + VPres Infinit v => verb.s ! VI (Inf v) ; + VPres Indicat v => verb.s ! VF (Pres Ind v) ; + VPres Imperat Act => verb.s ! VF Imper ; + VPres Imperat Pass => verb.s ! VF (Pres Ind Pass) --- no passive in Verbum + } ; + s1 = upp + } ; + + extVerb : Voice -> Verbum -> Verb = \v,verb -> + extVerbPart v verb [] ; +-} + +--3 Other open classes +-- +-- Proper names, adverbs (Adv having comparison forms and AdvIn not having them), +-- and interjections are the remaining open classes. + +oper + PNm : Type = {s : Case => Str ; h1 : Gender} ; + Adv : Type = {s : Degree => Str} ; + AdvInv : Type = {s : Str} ; + Interj : Type = {s : Str} ; + +--3 Closed classes +-- +-- The rest of the Swedish word classes are closed, i.e. not extensible by new +-- lexical entries. Thus we don't have to know how to build them, but only +-- how to use them, i.e. which parameters they have. +-- +-- The most important distinction is between proper-name-like pronouns and +-- adjective-like pronouns, which are inflected in completely different parameters. + +param + NPForm = PNom | PAcc | PGen GenNum ; + AdjPronForm = APron GenNum Case ; + AuxVerbForm = AuxInf | AuxPres | AuxPret | AuxSup ; + +oper + ProPN : Type = {s : NPForm => Str ; h1 : Gender ; h2 : Number ; h3 : Person} ; + ProAdj : Type = {s : AdjPronForm => Str} ; + Prep : Type = {s : Str} ; + Conjunct : Type = {s : Str} ; + Subjunct : Type = {s : Str} ; + Art : Type = {s : GenNum => Str} ; + Part : Type = {s : Str} ; + Infin : Type = {s : Str} ; + VAux : Type = {s : AuxVerbForm => Str} ; +}