mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
newly organized resource with tense in lib
This commit is contained in:
105
lib/prelude/Coordination.gf
Normal file
105
lib/prelude/Coordination.gf
Normal file
@@ -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 = "," ;
|
||||
|
||||
} ;
|
||||
8
lib/prelude/HTML.gf
Normal file
8
lib/prelude/HTML.gf
Normal file
@@ -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 ;
|
||||
}
|
||||
12
lib/prelude/Latex.gf
Normal file
12
lib/prelude/Latex.gf
Normal file
@@ -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 ;
|
||||
}
|
||||
|
||||
|
||||
117
lib/prelude/Precedence.gf
Normal file
117
lib/prelude/Precedence.gf
Normal file
@@ -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 ;
|
||||
} ;
|
||||
27
lib/prelude/Predef.gf
Normal file
27
lib/prelude/Predef.gf
Normal file
@@ -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
|
||||
|
||||
} ;
|
||||
|
||||
4
lib/prelude/PredefAbs.gf
Normal file
4
lib/prelude/PredefAbs.gf
Normal file
@@ -0,0 +1,4 @@
|
||||
abstract PredefAbs = {
|
||||
cat Int ; String ;
|
||||
} ;
|
||||
|
||||
100
lib/prelude/Prelude.gf
Normal file
100
lib/prelude/Prelude.gf
Normal file
@@ -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 = "&-" ;
|
||||
} ;
|
||||
@@ -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"
|
||||
|
||||
154
lib/resource/abstract/Categories.gf
Normal file
154
lib/resource/abstract/Categories.gf
Normal file
@@ -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."
|
||||
}
|
||||
34
lib/resource/abstract/Numerals.gf
Normal file
34
lib/resource/abstract/Numerals.gf
Normal file
@@ -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
|
||||
}
|
||||
195
lib/resource/abstract/Rules.gf
Normal file
195
lib/resource/abstract/Rules.gf
Normal file
@@ -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 ;
|
||||
|
||||
} ;
|
||||
|
||||
91
lib/resource/abstract/Structural.gf
Normal file
91
lib/resource/abstract/Structural.gf
Normal file
@@ -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
|
||||
|
||||
}
|
||||
18
lib/resource/abstract/TestResource.gf
Normal file
18
lib/resource/abstract/TestResource.gf
Normal file
@@ -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 ;
|
||||
} ;
|
||||
83
lib/resource/swedish/CategoriesSwe.gf
Normal file
83
lib/resource/swedish/CategoriesSwe.gf
Normal file
@@ -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} ;
|
||||
}
|
||||
1202
lib/resource/swedish/MorphoSwe.gf
Normal file
1202
lib/resource/swedish/MorphoSwe.gf
Normal file
File diff suppressed because it is too large
Load Diff
34
lib/resource/swedish/NumeralsSwe.gf
Normal file
34
lib/resource/swedish/NumeralsSwe.gf
Normal file
@@ -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) ;
|
||||
|
||||
}
|
||||
134
lib/resource/swedish/RulesSwe.gf
Normal file
134
lib/resource/swedish/RulesSwe.gf
Normal file
@@ -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 ;
|
||||
|
||||
} ;
|
||||
114
lib/resource/swedish/StructuralSwe.gf
Normal file
114
lib/resource/swedish/StructuralSwe.gf
Normal file
@@ -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" ;
|
||||
|
||||
}
|
||||
1229
lib/resource/swedish/SyntaxSwe.gf
Normal file
1229
lib/resource/swedish/SyntaxSwe.gf
Normal file
File diff suppressed because it is too large
Load Diff
51
lib/resource/swedish/TestResourceSwe.gf
Normal file
51
lib/resource/swedish/TestResourceSwe.gf
Normal file
@@ -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 ;
|
||||
} ;
|
||||
165
lib/resource/swedish/TypesSwe.gf
Normal file
165
lib/resource/swedish/TypesSwe.gf
Normal file
@@ -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} ;
|
||||
}
|
||||
Reference in New Issue
Block a user