summaryrefslogtreecommitdiff
path: root/grammars
diff options
context:
space:
mode:
authoraarne <unknown>2003-09-22 13:16:55 +0000
committeraarne <unknown>2003-09-22 13:16:55 +0000
commitb1402e8bd6a68a891b00a214d6cf184d66defe19 (patch)
tree90372ac4e53dce91cf949dbf8e93be06f1d9e8bd /grammars
Founding the newly structured GF2.0 cvs archive.
Diffstat (limited to 'grammars')
-rw-r--r--grammars/logic/Arithm.gf63
-rw-r--r--grammars/logic/ArithmEng.gf40
-rw-r--r--grammars/logic/Logic.gf82
-rw-r--r--grammars/logic/LogicEng.gf59
-rw-r--r--grammars/logic/LogicResEng.gf27
-rw-r--r--grammars/prelude/Coordination.gf105
-rw-r--r--grammars/prelude/Predef.gf25
-rw-r--r--grammars/prelude/Prelude.gf83
-rw-r--r--grammars/resource/abstract/Database.gf36
-rw-r--r--grammars/resource/abstract/PredefAbs.gf4
-rw-r--r--grammars/resource/abstract/ResAbs.gf266
-rw-r--r--grammars/resource/abstract/Restaurant.gf15
-rw-r--r--grammars/resource/abstract/TestAbs.gf15
-rw-r--r--grammars/resource/english/DatabaseEng.gf51
-rw-r--r--grammars/resource/english/DatabaseEngRes.gf11
-rw-r--r--grammars/resource/english/English.gf1
-rw-r--r--grammars/resource/english/Morpho.gf150
-rw-r--r--grammars/resource/english/Paradigms.gf229
-rw-r--r--grammars/resource/english/Predication.gf83
-rw-r--r--grammars/resource/english/ResEng.gf195
-rw-r--r--grammars/resource/english/RestaurantEng.gf25
-rw-r--r--grammars/resource/english/Syntax.gf848
-rw-r--r--grammars/resource/english/TestEng.gf36
-rw-r--r--grammars/resource/english/Types.gf101
-rw-r--r--grammars/resource/german/DatabaseDeu.gf52
-rw-r--r--grammars/resource/german/DatabaseRes.gf11
-rw-r--r--grammars/resource/german/Deutsch.gf1
-rw-r--r--grammars/resource/german/Logical.gf23
-rw-r--r--grammars/resource/german/Morpho.gf399
-rw-r--r--grammars/resource/german/Paradigms.gf300
-rw-r--r--grammars/resource/german/Predication.gf87
-rw-r--r--grammars/resource/german/ResDeu.gf217
-rw-r--r--grammars/resource/german/RestaurantDeu.gf24
-rw-r--r--grammars/resource/german/Syntax.gf891
-rw-r--r--grammars/resource/german/TestDeu.gf39
-rw-r--r--grammars/resource/german/Types.gf98
-rw-r--r--grammars/resource/swedish/Morpho.gf1039
-rw-r--r--grammars/resource/swedish/ResSwe.gf196
-rw-r--r--grammars/resource/swedish/Svenska.gf1
-rw-r--r--grammars/resource/swedish/Syntax.gf1000
-rw-r--r--grammars/resource/swedish/TestSwe.gf35
-rw-r--r--grammars/resource/swedish/Types.gf150
42 files changed, 7113 insertions, 0 deletions
diff --git a/grammars/logic/Arithm.gf b/grammars/logic/Arithm.gf
new file mode 100644
index 000000000..e3ae706a4
--- /dev/null
+++ b/grammars/logic/Arithm.gf
@@ -0,0 +1,63 @@
+abstract Arithm = Logic ** {
+
+-- arithmetic
+fun
+ Nat, Real : Dom ;
+ zero : Elem Nat ;
+ succ : Elem Nat -> Elem Nat ;
+
+ trunc : Elem Real -> Elem Nat ;
+
+ EqNat : (m,n : Elem Nat) -> Prop ;
+ LtNat : (m,n : Elem Nat) -> Prop ;
+ Div : (m,n : Elem Nat) -> Prop ;
+ Even : Elem Nat -> Prop ;
+ Odd : Elem Nat -> Prop ;
+ Prime : Elem Nat -> Prop ;
+
+ one : Elem Nat ;
+ two : Elem Nat ;
+ sum : (m,n : Elem Nat) -> Elem Nat ;
+ prod : (m,n : Elem Nat) -> Elem Nat ;
+
+ evax1 : Proof (Even zero) ;
+ evax2 : (n : Elem Nat) -> Proof (Even n) -> Proof (Odd (succ n)) ;
+ evax3 : (n : Elem Nat) -> Proof (Odd n) -> Proof (Even (succ n)) ;
+ eqax1 : Proof (EqNat zero zero) ;
+ eqax2 : (m,n : Elem Nat) -> Proof (EqNat m n) -> Proof (EqNat (succ m) (succ n)) ;
+
+ IndNat : (C : Elem Nat -> Prop) ->
+ Proof (C zero) ->
+ ((x : Elem Nat) -> Proof (C x) -> Proof (C (succ x))) ->
+ Proof (Univ Nat C) ;
+
+def
+ one = succ zero ;
+ two = succ one ;
+ sum m zero = m ;
+ sum m (succ n) = succ (sum m n) ;
+ prod m zero = zero ;
+ prod m (succ n) = sum (prod m n) m ;
+ LtNat m n = Exist Nat (\x -> EqNat n (sum m (succ x))) ;
+ Div m n = Exist Nat (\x -> EqNat m (prod x n)) ;
+ Prime n = Conj
+ (LtNat one n)
+ (Univ Nat (\x -> Impl (Conj (LtNat one x) (Div n x)) (EqNat x n))) ;
+
+fun ex1 : Text ;
+def ex1 =
+ ThmWithProof
+ (Univ Nat (\x -> Disj (Even x) (Odd x)))
+ (IndNat
+ (\x -> Disj (Even x) (Odd x))
+ (DisjIl (Even zero) (Odd zero) evax1)
+ (\x -> \h -> DisjE (Even x) (Odd x) (Disj (Even (succ x)) (Odd (succ x)))
+ (Hypo (Disj (Even x) (Odd x)) h)
+ (\a -> DisjIr (Even (succ x)) (Odd (succ x))
+ (evax2 x (Hypo (Even x) a)))
+ (\b -> DisjIl (Even (succ x)) (Odd (succ x))
+ (evax3 x (Hypo (Odd x) b))
+ )
+ )
+ ) ;
+} ;
diff --git a/grammars/logic/ArithmEng.gf b/grammars/logic/ArithmEng.gf
new file mode 100644
index 000000000..8c78132ea
--- /dev/null
+++ b/grammars/logic/ArithmEng.gf
@@ -0,0 +1,40 @@
+concrete ArithmEng of Arithm = LogicEng ** open LogicResEng in {
+
+lin
+ Nat = {s = nomReg "number"} ;
+ zero = ss "zero" ;
+ succ = fun1 "successor" ;
+
+ EqNat = adj2 ["equal to"] ;
+ LtNat = adj2 ["smaller than"] ;
+ Div = adj2 ["divisible by"] ;
+ Even = adj1 "even" ;
+ Odd = adj1 "odd" ;
+ Prime = adj1 "prime" ;
+
+ one = ss "one" ;
+ two = ss "two" ;
+ sum = fun2 "sum" ;
+ prod = fun2 "product" ;
+
+ evax1 = ss ["by the first axiom of evenness , zero is even"] ;
+ evax2 n c = {s =
+ c.s ++ [". By the second axiom of evenness , the successor of"] ++
+ n.s ++ ["is odd"]} ;
+ evax3 n c = {s =
+ c.s ++ [". By the third axiom of evenness , the successor of"] ++
+ n.s ++ ["is even"]} ;
+ eqax1 = ss ["by the first axiom of equality , zero is equal to zero"] ;
+ eqax2 m n c = {s =
+ c.s ++ [". By the second axiom of equality , the successor of"] ++ m.s ++
+ ["is equal to the successor of"] ++ n.s} ;
+ IndNat C d e = {s =
+ ["we proceed by induction . For the basis ,"] ++ d.s ++
+ [". For the induction step, consider a number"] ++ C.$0 ++
+ ["and assume"] ++ C.s ++ "(" ++ e.$1 ++ ")" ++ "." ++ e.s ++
+ ["Hence, for all numbers"] ++ C.$0 ++ "," ++ C.s} ;
+
+ ex1 = ss ["The first theorem and its proof ."] ;
+
+} ;
+
diff --git a/grammars/logic/Logic.gf b/grammars/logic/Logic.gf
new file mode 100644
index 000000000..334592946
--- /dev/null
+++ b/grammars/logic/Logic.gf
@@ -0,0 +1,82 @@
+-- many-sorted predicate calculus
+-- AR 1999, revised 2001
+
+abstract Logic = {
+
+flags startcat=Prop ; -- this is what you want to parse
+
+cat
+ Prop ; -- proposition
+ Dom ; -- domain of quantification
+ Elem Dom ; -- individual element of a domain
+ Proof Prop ; -- proof of a proposition
+ Text ; -- theorem with proof etc.
+
+fun
+ -- texts
+ Statement : Prop -> Text ;
+ ThmWithProof : (A : Prop) -> Proof A -> Text ;
+ ThmWithTrivialProof : (A : Prop) -> Proof A -> Text ;
+
+ -- logically complex propositions
+ Disj : (A,B : Prop) -> Prop ;
+ Conj : (A,B : Prop) -> Prop ;
+ Impl : (A,B : Prop) -> Prop ;
+ Abs : Prop ;
+ Neg : Prop -> Prop ;
+
+ Univ : (A : Dom) -> (Elem A -> Prop) -> Prop ;
+ Exist : (A : Dom) -> (Elem A -> Prop) -> Prop ;
+
+ -- progressive implication ā la type theory
+ ImplP : (A : Prop) -> (Proof A -> Prop) -> Prop ;
+
+ -- inference rules
+ ConjI : (A,B : Prop) -> Proof A -> Proof B -> Proof (Conj A B) ;
+ ConjEl : (A,B : Prop) -> Proof (Conj A B) -> Proof A ;
+ ConjEr : (A,B : Prop) -> Proof (Conj A B) -> Proof B ;
+ DisjIl : (A,B : Prop) -> Proof A -> Proof (Disj A B) ;
+ DisjIr : (A,B : Prop) -> Proof B -> Proof (Disj A B) ;
+ DisjE : (A,B,C : Prop) -> Proof (Disj A B) ->
+ (Proof A -> Proof C) -> (Proof B -> Proof C) -> Proof C ;
+ ImplI : (A,B : Prop) -> (Proof A -> Proof B) -> Proof (Impl A B) ;
+ ImplE : (A,B : Prop) -> Proof (Impl A B) -> Proof A -> Proof B ;
+ NegI : (A : Prop) -> (Proof A -> Proof Abs) -> Proof (Neg A) ;
+ NegE : (A : Prop) -> Proof (Neg A) -> Proof A -> Proof Abs ;
+ AbsE : (C : Prop) -> Proof Abs -> Proof C ;
+
+ UnivI : (A : Dom) -> (B : Elem A -> Prop) ->
+ ((x : Elem A) -> Proof (B x)) -> Proof (Univ A B) ;
+ UnivE : (A : Dom) -> (B : Elem A -> Prop) ->
+ Proof (Univ A B) -> (a : Elem A) -> Proof (B a) ;
+ ExistI : (A : Dom) -> (B : Elem A -> Prop) ->
+ (a : Elem A) -> Proof (B a) -> Proof (Exist A B) ;
+ ExistE : (A : Dom) -> (B : Elem A -> Prop) -> (C : Prop) ->
+ Proof (Exist A B) -> ((x : Elem A) -> Proof (B x) -> Proof C) ->
+ Proof C ;
+
+ -- use a hypothesis
+ Hypo : (A : Prop) -> Proof A -> Proof A ;
+
+ -- pronoun
+ Pron : (A : Dom) -> Elem A -> Elem A ;
+
+data
+ Proof = ConjI | DisjIl | DisjIr ;
+
+def
+ -- proof normalization
+ ConjEl _ _ (ConjI _ _ a _) = a ;
+ ConjEr _ _ (ConjI _ _ _ b) = b ;
+ DisjE _ _ _ (DisjIl _ _ a) d _ = d a ;
+ DisjE _ _ _ (DisjIr _ _ b) _ e = e b ;
+ ImplE _ _ (ImplI _ _ b) a = b a ;
+ NegE _ (NegI _ b) a = b a ;
+ UnivE _ _ (UnivI _ _ b) a = b a ;
+ ExistE _ _ _ (ExistI _ _ a b) d = d a b ;
+
+ -- Hypo and Pron are identities
+ Hypo _ a = a ;
+ Pron _ a = a ;
+
+} ;
diff --git a/grammars/logic/LogicEng.gf b/grammars/logic/LogicEng.gf
new file mode 100644
index 000000000..3b823fcb0
--- /dev/null
+++ b/grammars/logic/LogicEng.gf
@@ -0,0 +1,59 @@
+concrete LogicEng of Logic = open LogicResEng in {
+
+flags lexer=vars ; unlexer=text ;
+
+lincat
+ Dom = {s : Num => Str} ;
+ Prop, Elem = {s : Str} ;
+
+lin
+Statement A = {s = A.s ++ "."} ;
+ThmWithProof A a = {s = ["Theorem ."] ++ A.s ++ [". <p> Proof ."] ++ a.s ++ "."} ;
+ThmWithTrivialProof A a =
+ {s = "Theorem" ++ "." ++ A.s ++ [". <p> Proof . Trivial ."]} ;
+Disj A B = {s = A.s ++ "or" ++ B.s} ;
+Conj A B = {s = A.s ++ "and" ++ B.s} ;
+Impl A B = {s = "if" ++ A.s ++ "then" ++ B.s} ;
+Univ A B = {s = ["for all"] ++ A.s ! pl ++ B.$0 ++ "," ++ B.s} ;
+Exist A B =
+ {s = ["there exists"] ++ indef ++ A.s ! sg ++ B.$0 ++ ["such that"] ++ B.s} ;
+Abs = {s = ["we have a contradiction"]} ;
+Neg A = {s = ["it is not the case that"] ++ A.s} ;
+ImplP A B = {s = "if" ++ A.s ++ "then" ++ B.s} ;
+ConjI A B a b = {s = a.s ++ "." ++ b.s ++ [". Hence"] ++ A.s ++ "and" ++ B.s} ;
+ConjEl A B c = {s = c.s ++ [". A fortiori ,"] ++ A.s} ;
+ConjEr A B c = {s = c.s ++ [". A fortiori ,"] ++ B.s} ;
+DisjIl A B a = {s = a.s ++ [". A fortiori ,"] ++ A.s ++ "or" ++ B.s} ;
+DisjIr A B b = {s = b.s ++ [". A fortiori ,"] ++ A.s ++ "or" ++ B.s} ;
+DisjE A B C c d e = {s =
+ c.s ++
+ [". There are two possibilities . First , assume"] ++
+ A.s ++ "(" ++ d.$0 ++ ")" ++ "." ++ d.s ++
+ [". Second , assume"] ++ B.s ++ "(" ++ e.$0 ++ ")" ++ "." ++ e.s ++
+ [". Thus"] ++ C.s ++ ["in both cases"]} ;
+ImplI A B b = {s =
+ "assume" ++ A.s ++ "(" ++ b.$0 ++ ")" ++ "." ++
+ b.s ++ [". Hence , if"] ++ A.s ++ "then" ++ B.s} ;
+ImplE A B c a = {s = a.s ++ [". But"] ++ c.s ++ [". Hence"] ++ B.s} ;
+NegI A b = {s =
+ "assume" ++ A.s ++ "(" ++ b.$0 ++ ")" ++ "." ++ b.s ++
+ [". Hence, it is not the case that"] ++ A.s} ;
+NegE A c a =
+ {s = a.s ++ [". But"] ++ c.s ++ [". We have a contradiction"]} ;
+UnivI A B b = {s =
+ ["consider an arbitrary"] ++ A.s ! sg ++ b.$0 ++ "." ++ b.s ++
+ [". Hence, for all"] ++ A.s ! pl ++ B.$0 ++ "," ++ B.s} ;
+UnivE A B c a =
+ {s = c.s ++ [". Hence"] ++ B.s ++ "for" ++ B.$0 ++ ["set to"] ++ a.s} ;
+ExistI A B a b = {s =
+ b.s ++ [". Hence, there exists"] ++ indef ++
+ A.s ! sg ++ B.$0 ++ ["such that"] ++ B.s} ;
+ExistE A B C c d = {s =
+ c.s ++ [". Consider an arbitrary"] ++ d.$0 ++
+ ["and assume that"] ++ B.s ++ "(" ++ d.$1 ++ ")" ++ "." ++ d.s ++
+ [". Hence"] ++ C.s ++ ["independently of"] ++ d.$0} ;
+AbsE C c = {s = c.s ++ [". We may conclude"] ++ C.s} ;
+Hypo A a = {s = ["by the hypothesis"] ++ a.s ++ "," ++ A.s} ;
+Pron _ _ = {s = "it"} ;
+
+} ;
diff --git a/grammars/logic/LogicResEng.gf b/grammars/logic/LogicResEng.gf
new file mode 100644
index 000000000..94866bf05
--- /dev/null
+++ b/grammars/logic/LogicResEng.gf
@@ -0,0 +1,27 @@
+resource LogicResEng = {
+
+param Num = sg | pl ;
+
+oper
+
+ ss : Str -> {s : Str} = \s -> {s = s} ;
+
+ nomReg : Str -> Num => Str = \s -> table {sg => s ; pl => s + "s"} ;
+
+ indef : Str = pre {"a" ; "an" / strs {"a" ; "e" ; "i" ; "o"}} ;
+
+ LinElem : Type = {s : Str} ;
+ LinProp : Type = {s : Str} ;
+
+ adj1 : Str -> LinElem -> LinProp =
+ \adj,x -> ss (x.s ++ "is" ++ adj) ;
+ adj2 : Str -> LinElem -> LinElem -> LinProp =
+ \adj,x,y -> ss (x.s ++ "is" ++ adj ++ y.s) ;
+
+ fun1 : Str -> LinElem -> LinElem =
+ \f,x -> ss ("the" ++ f ++ "of" ++ x.s) ;
+ fun2 : Str -> LinElem -> LinElem -> LinElem =
+ \f,x,y -> ss ("the" ++ f ++ "of" ++ x.s ++ "and" ++ y.s) ;
+
+
+} ;
diff --git a/grammars/prelude/Coordination.gf b/grammars/prelude/Coordination.gf
new file mode 100644
index 000000000..d8265e3c2
--- /dev/null
+++ b/grammars/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} =
+ \_,_,or,xs ->
+ {s =
+ table {p => table {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/grammars/prelude/Predef.gf b/grammars/prelude/Predef.gf
new file mode 100644
index 000000000..a91681af6
--- /dev/null
+++ b/grammars/prelude/Predef.gf
@@ -0,0 +1,25 @@
+-- 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 definitions in AppPredefined.hs
+ oper Int : Type = variants {} ; ----
+
+ oper length : Tok -> Int = variants {} ;
+ oper drop : Int -> Tok -> Tok = variants {} ;
+ oper take : Int -> Tok -> Tok = variants {} ;
+ oper tk : Int -> Tok -> Tok = variants {} ;
+ oper dp : Int -> Tok -> Tok = variants {} ;
+ oper eqInt : Int -> Int -> PBool = variants {} ;
+ oper plus : Int -> Int -> Int = variants {} ;
+
+ oper eqStr : Tok -> Tok -> PBool = variants {} ;
+ oper eqTok : (P : Type) -> P -> P -> PBool = variants {} ;
+ oper show : (P : Type) -> P -> Tok = variants {} ;
+ oper read : (P : Type) -> Tok -> P = variants {} ;
+
+ } ;
+
diff --git a/grammars/prelude/Prelude.gf b/grammars/prelude/Prelude.gf
new file mode 100644
index 000000000..f5903d7ec
--- /dev/null
+++ b/grammars/prelude/Prelude.gf
@@ -0,0 +1,83 @@
+-- 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) ;
+
+-- 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_else 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 ;
+
+
+-- 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
+ oper isNil : Tok -> Bool = \b -> pbool2bool (Predef.eqStr [] b) ;
+
+ oper 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
+ oper pbool2bool : Predef.PBool -> Bool = \b -> case b of {
+ Predef.PFalse => False ; Predef.PTrue => True
+ } ;
+
+} ;
diff --git a/grammars/resource/abstract/Database.gf b/grammars/resource/abstract/Database.gf
new file mode 100644
index 000000000..d261e3e11
--- /dev/null
+++ b/grammars/resource/abstract/Database.gf
@@ -0,0 +1,36 @@
+abstract Database = {
+
+flags startcat=Query ;
+
+cat
+ Query ; Phras ; Statement ; Question ;
+ Noun ; Subject ; Value ; Property ; Relation ; Comparison ; Name ;
+ Feature ;
+
+fun
+ LongForm : Phras -> Query ;
+ ShortForm : Phras -> Query ;
+
+ WhichAre : Noun -> Property -> Phras ;
+ IsThere : Noun -> Phras ;
+ AreThere : Noun -> Phras ;
+ IsIt : Subject -> Property -> Phras ;
+ WhatIs : Value -> Phras ;
+
+ MoreThan : Comparison -> Subject -> Property ;
+ TheMost : Comparison -> Noun -> Value ;
+ Relatively : Comparison -> Noun -> Property ;
+
+ RelatedTo : Relation -> Subject -> Property ;
+
+ Individual : Name -> Subject ;
+ AllN : Noun -> Subject ;
+ Any : Noun -> Subject ;
+ MostN : Noun -> Subject ;
+ EveryN : Noun -> Subject ;
+
+ FeatureOf : Feature -> Subject -> Subject ;
+ ValueOf : Feature -> Name -> Value ;
+
+ WithProperty : Noun -> Property -> Noun ;
+} ;
diff --git a/grammars/resource/abstract/PredefAbs.gf b/grammars/resource/abstract/PredefAbs.gf
new file mode 100644
index 000000000..ccd214fd4
--- /dev/null
+++ b/grammars/resource/abstract/PredefAbs.gf
@@ -0,0 +1,4 @@
+abstract PredefAbs = {
+ cat String ; Int ;
+} ;
+
diff --git a/grammars/resource/abstract/ResAbs.gf b/grammars/resource/abstract/ResAbs.gf
new file mode 100644
index 000000000..aba5ca216
--- /dev/null
+++ b/grammars/resource/abstract/ResAbs.gf
@@ -0,0 +1,266 @@
+--1 Abstract Syntax for Multilingual Resource Grammar
+--
+-- Aarne Ranta 2002 -- 2003
+--
+-- Although concrete syntax differs a lot between different languages,
+-- many structures can be found that are common, on a certain level
+-- of abstraction. What we will present in the following is an abstract
+-- syntax that has been successfully defined for English, French, German,
+-- Italian, Russian, and Swedish. It 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.
+--
+-- 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. There is
+-- a GF command for making this translation automatically.
+
+--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 it the business
+-- of applications grammars.
+--
+-- Categories that may look special are $Adj2$, $Fun$, and $TV$. 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. This, together
+-- with the category $Adv$, removes the need of a category of
+-- 'prepositional phrases', which is too language-dependent to make sense
+-- on this level of abstraction.
+--
+
+abstract ResAbs = {
+
+--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"
+ NP ; -- noun phrase, e.g. "John", "all cars", "you"
+ PN ; -- proper name, e.g. "John", "New York"
+ Det ; -- determiner, e.g. "every", "all"
+ Fun ; -- function word, e.g. "mother (of)"
+ Fun2 ; -- two-place function, e.g. "flight (from) (to)"
+
+--3 Adjectives and adjectival phrases
+--
+
+ Adj1 ; -- one-place adjective, e.g. "even"
+ Adj2 ; -- two-place adjective, e.g. "divisible (by)"
+ AdjDeg ; -- degree adjective, e.g. "big/bigger/biggest"
+ AP ; -- adjective phrase, e.g. "divisible by two", "bigger than John"
+
+--3 Verbs and verb phrases
+--
+
+ V ; -- one-place verb, e.g. "walk"
+ TV ; -- two-place verb, e.g. "love", "wait (for)", "switch on"
+ VS ; -- sentence-compl. verb e.g. "say", "prove"
+ VP ; -- verb phrase, e.g. "switch the light on"
+
+--3 Adverbials
+--
+
+ AdV ; -- adverbial e.g. "now", "in the house"
+ AdA ; -- ad-adjective e.g. "very"
+ AdS ; -- sentence adverbial e.g. "therefore", "otherwise"
+
+--3 Sentences and relative clauses
+--
+
+ S ; -- sentence, e.g. "John walks"
+ 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
+--
+
+ 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
+--
+
+ 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."
+
+--2 Rules
+--
+-- This set of rules is minimal, in the sense defining the simplest combinations
+-- of categories and of 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
+-- combinations of the ones below.
+
+--3 Nouns and noun phrases
+--
+
+fun
+ UseN : N -> CN ; -- "car"
+ ModAdj : AP -> CN -> CN ; -- "red car"
+ DetNP : Det -> CN -> NP ; -- "every car"
+ IndefOneNP, IndefManyNP : CN -> NP ; -- "a car", "cars"
+ DefOneNP, DefManyNP : CN -> NP ; -- "the car", "the cars"
+ ModGenOne, ModGenMany : NP -> CN -> NP ; -- "John's car", "John's cars"
+ UsePN : PN -> NP ; -- "John"
+ UseFun : Fun -> CN ; -- "successor"
+ AppFun : Fun -> NP -> CN ; -- "successor of zero"
+ AppFun2 : Fun2 -> NP -> Fun ; -- "flight from Paris"
+ CNthatS : CN -> S -> CN ; -- "idea that the Earth is flat"
+
+--3 Adjectives and adjectival phrases
+--
+
+ AdjP1 : Adj1 -> AP ; -- "red"
+ ComplAdj : Adj2 -> NP -> AP ; -- "divisible by two"
+ PositAdjP : AdjDeg -> AP ; -- "old"
+ ComparAdjP : AdjDeg -> NP -> AP ; -- "older than John"
+ SuperlNP : AdjDeg -> CN -> NP ; -- "the oldest man"
+
+--3 Verbs and verb phrases
+--
+
+ PosV, NegV : V -> VP ; -- "walk", "doesn't walk"
+ PosA, NegA : AP -> VP ; -- "is old", "isn't old"
+ PosCN, NegCN : CN -> VP ; -- "is a man", "isn't a man"
+ PosTV, NegTV : TV -> NP -> VP ; -- "sees John", "doesn't see John"
+ PosPassV, NegPassV : V -> VP ; -- "is seen", "is not seen"
+ PosNP, NegNP : NP -> VP ; -- "is John", "is not John"
+ PosVS, NegVS : VS -> S -> VP ; -- "says that I run", "doesn't say..."
+
+--3 Adverbials
+--
+
+ AdvVP : VP -> AdV -> VP ; -- "always walks", "walks in the park"
+ LocNP : NP -> AdV ; -- "in London"
+ AdvCN : CN -> AdV -> CN ; -- "house in London", "house today"
+
+ AdvAP : AdA -> AP -> AP ; -- "very good"
+
+
+--3 Sentences and relative clauses
+--
+
+ PredVP : NP -> VP -> S ; -- "John walks"
+ PosSlashTV, NegSlashTV : NP -> TV -> Slash ; -- "John sees", "John doesn's see"
+ OneVP : VP -> S ; -- "one walks"
+
+ IdRP : RP ; -- "which"
+ FunRP : Fun -> RP -> RP ; -- "the successor of which"
+ RelVP : RP -> VP -> RC ; -- "who walks"
+ 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 : Fun -> IP -> IP ; -- "the mother of whom"
+ NounIPOne, NounIPMany : CN -> IP ; -- "which car", "which cars"
+
+ QuestVP : NP -> VP -> Qu ; -- "does 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"
+
+ 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!"
+
+ 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?"
+
+--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 ;
+
+--2 Examples of structural words
+--
+-- 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.
+
+ EveryDet, AllDet, WhichDet, MostDet : Det ; -- every, all, which, most
+ INP, ThouNP, HeNP, SheNP, ItNP : NP ; -- personal pronouns in singular
+ WeNP, YeNP, TheyNP : NP ; -- personal pronouns in plural
+ YouNP : NP ; -- the polite you
+ WhenIAdv,WhereIAdv,WhyIAdv,HowIAdv : IAdv ; -- when, where, why, how
+ AndConj, OrConj : Conj ; -- and, or
+ BothAnd, EitherOr, NeitherNor : ConjD ; -- both-and, either-or, neither-nor
+ IfSubj, WhenSubj : Subj ; -- if, when
+ PhrYes, PhrNo : Phr ; -- yes, no
+ VeryAdv, TooAdv : AdA ; -- very, too
+ OtherwiseAdv, ThereforeAdv : AdS ; -- therefore, otherwise
+} ;
+
diff --git a/grammars/resource/abstract/Restaurant.gf b/grammars/resource/abstract/Restaurant.gf
new file mode 100644
index 000000000..5c4ae4681
--- /dev/null
+++ b/grammars/resource/abstract/Restaurant.gf
@@ -0,0 +1,15 @@
+abstract Restaurant = Database ** {
+
+fun
+ Restaurant, Bar : Noun ;
+ French, Italian, Indian, Japanese : Property ;
+ address, phone, priceLevel : Feature ;
+ Cheap, Expensive : Comparison ;
+
+ WhoRecommend : Name -> Phras ;
+ WhoHellRecommend : Name -> Phras ;
+
+
+-- examples of restaurant names
+ LucasCarton : Name ;
+} ;
diff --git a/grammars/resource/abstract/TestAbs.gf b/grammars/resource/abstract/TestAbs.gf
new file mode 100644
index 000000000..c07ac4968
--- /dev/null
+++ b/grammars/resource/abstract/TestAbs.gf
@@ -0,0 +1,15 @@
+abstract TestAbs = ResAbs ** {
+
+-- a random sample of lexicon to test resource grammar with
+
+fun
+ Big, Small, Old, Young : AdjDeg ;
+ Man, Woman, Car, House, Light : N ;
+ Walk, Run : V ;
+ Send, Wait, Love, SwitchOn, SwitchOff : TV ;
+ Say, Prove : VS ;
+ Mother, Uncle : Fun ;
+ Connection : Fun2 ;
+ Well, Always : AdV ;
+ John, Mary : PN ;
+} ;
diff --git a/grammars/resource/english/DatabaseEng.gf b/grammars/resource/english/DatabaseEng.gf
new file mode 100644
index 000000000..9d94e69ed
--- /dev/null
+++ b/grammars/resource/english/DatabaseEng.gf
@@ -0,0 +1,51 @@
+concrete DatabaseEng of Database = open Prelude,Syntax,English,Predication,Paradigms,DatabaseRes in {
+
+flags lexer=text ; unlexer=text ;
+
+lincat
+ Phras = SS1 Bool ; -- long or short form
+ Subject = NP ;
+ Noun = CN ;
+ Property = AP ;
+ Comparison = AdjDeg ;
+ Relation = Adj2 ;
+ Feature = Fun ;
+ Value = NP ;
+ Name = ProperName ;
+
+lin
+ LongForm sent = ss (sent.s ! True ++ "?") ;
+ ShortForm sent = ss (sent.s ! False ++ "?") ;
+
+ WhichAre A B = mkSent (defaultQuestion (IntVP (NounIPMany A) (PosA B)))
+ (defaultNounPhrase (IndefManyNP (ModAdj B A))) ;
+
+ IsIt Q A = mkSentSame (defaultQuestion (QuestVP Q (PosA A))) ;
+
+ MoreThan = ComparAdjP ;
+ TheMost = SuperlNP ;
+ Relatively C _ = PositAdjP C ;
+
+ RelatedTo = ComplAdj ;
+
+ FeatureOf = appFun1 ;
+ ValueOf F V = appFun1 F (UsePN V) ;
+
+ WithProperty A B = ModAdj B A ;
+
+ Individual = UsePN ;
+
+ AllN = DetNP AllDet ;
+ MostN = DetNP MostDet ;
+ EveryN = DetNP EveryDet ;
+
+-- only these are language-dependent
+
+ Any = detNounPhrase anyPlDet ; ---
+
+ IsThere A = mkSentPrel ["is there"] (defaultNounPhrase (IndefOneNP A)) ;
+ AreThere A = mkSentPrel ["are there"] (defaultNounPhrase (IndefManyNP A)) ;
+
+ WhatIs V = mkSentPrel ["what is"] (defaultNounPhrase V) ;
+
+} ;
diff --git a/grammars/resource/english/DatabaseEngRes.gf b/grammars/resource/english/DatabaseEngRes.gf
new file mode 100644
index 000000000..e00501a47
--- /dev/null
+++ b/grammars/resource/english/DatabaseEngRes.gf
@@ -0,0 +1,11 @@
+resource DatabaseEngRes = open Prelude in {
+oper
+ mkSent : SS -> SS -> SS1 Bool = \long, short ->
+ {s = table {b => if_then_else Str b long.s short.s}} ;
+
+ mkSentPrel : Str -> SS -> SS1 Bool = \prel, matter ->
+ mkSent (ss (prel ++ matter.s)) matter ;
+
+ mkSentSame : SS -> SS1 Bool = \s ->
+ mkSent s s ;
+} ;
diff --git a/grammars/resource/english/English.gf b/grammars/resource/english/English.gf
new file mode 100644
index 000000000..45b64d72f
--- /dev/null
+++ b/grammars/resource/english/English.gf
@@ -0,0 +1 @@
+resource English = reuse ResEng ;
diff --git a/grammars/resource/english/Morpho.gf b/grammars/resource/english/Morpho.gf
new file mode 100644
index 000000000..52779cd11
--- /dev/null
+++ b/grammars/resource/english/Morpho.gf
@@ -0,0 +1,150 @@
+--1 A Simple English Resource Morphology
+--
+-- Aarne Ranta 2002
+--
+-- This resource morphology contains definitions needed in the resource
+-- syntax. It moreover contains the most usual inflectional patterns.
+--
+-- We use the parameter types and word classes defined in $types.Eng.gf$.
+
+resource Morpho = Types ** open Prelude in {
+
+--2 Nouns
+--
+-- For conciseness and abstraction, we define a worst-case macro for
+-- noun inflection. It is used for defining special case that
+-- only need one string as argument.
+
+oper
+ mkNoun : (_,_,_,_ : Str) -> CommonNoun =
+ \man,men, mans, mens -> {s = table {
+ Sg => table {Nom => man ; Gen => mans} ;
+ Pl => table {Nom => men ; Gen => mens}
+ }} ;
+
+ nounReg : Str -> CommonNoun = \dog ->
+ mkNoun dog (dog + "s") (dog + "'s") (dog + "s'");
+
+ nounS : Str -> CommonNoun = \kiss ->
+ mkNoun kiss (kiss + "es") (kiss + "'s") (kiss + "es'") ;
+
+ nounY : Str -> CommonNoun = \fl ->
+ mkNoun (fl + "y") (fl + "ies") (fl + "y's") (fl + "ies'") ;
+
+--3 Proper names
+--
+-- Regular proper names are inflected with "'s" in the genitive.
+
+ nameReg : Str -> ProperName = \john ->
+ {s = table {Nom => john ; Gen => john + "'s"}} ;
+
+
+--2 Pronouns
+--
+-- Here we define personal and relative pronouns.
+
+ mkPronoun : (_,_,_,_ : Str) -> Number -> Person -> Pronoun = \I,me,my,mine,n,p ->
+ {s = table {NomP => I ; AccP => me ; GenP => my ; GenSP => mine} ;
+ n = n ; p = p} ;
+
+ pronI = mkPronoun "I" "me" "my" "mine" Sg P1 ;
+ pronYouSg = mkPronoun "you" "you" "your" "yours" Sg P2 ; -- verb form still OK
+ pronHe = mkPronoun "he" "him" "his" "his" Sg P3 ;
+ pronShe = mkPronoun "she" "her" "her" "hers" Sg P3 ;
+
+ pronWe = mkPronoun "we" "us" "our" "ours" Pl P1 ;
+ pronYouPl = mkPronoun "you" "you" "your" "yours" Pl P2 ;
+ pronThey = mkPronoun "they" "them" "their" "theirs" Pl P3 ;
+
+-- Relative pronouns in the accusative have the 'no pronoun' variant.
+-- The simple pronouns do not really depend on number.
+
+ relPron : RelPron = {s = table {
+ NoHum => \\_ => table {
+ NomP => variants {"that" ; "which"} ;
+ AccP => variants {"that" ; "which" ; []} ;
+ GenP => variants {"whose"} ;
+ GenSP => variants {"which"}
+ } ;
+ Hum => \\_ => table {
+ NomP => variants {"that" ; "who"} ;
+ AccP => variants {"that" ; "who" ; "whom" ; []} ;
+ GenP => variants {"whose"} ;
+ GenSP => variants {"whom"}
+ }
+ }
+ } ;
+
+
+--3 Determiners
+--
+-- We have just a heuristic definition of the indefinite article.
+-- There are lots of exceptions: consonantic "e" ("euphemism"), consonantic
+-- "o" ("one-sided"), vocalic "u" ("umbrella").
+
+ artIndef = pre {"a" ;
+ "an" / strs {"a" ; "e" ; "i" ; "o" ; "A" ; "E" ; "I" ; "O" }} ;
+
+ artDef = "the" ;
+
+--2 Adjectives
+--
+-- For the comparison of adjectives, three forms are needed in the worst case.
+
+ mkAdjDegr : (_,_,_ : Str) -> AdjDegr = \good,better,best ->
+ {s = table {Pos => good ; Comp => better ; Sup => best}} ;
+
+ adjDegrReg : Str -> AdjDegr = \long ->
+ mkAdjDegr long (long + "er") (long + "est") ;
+
+ adjDegrY : Str -> AdjDegr = \lovel ->
+ mkAdjDegr (lovel + "y") (lovel + "ier") (lovel + "iest") ;
+
+-- Many adjectives are 'inflected' by adding a comparison word.
+
+ adjDegrLong : Str -> AdjDegr = \ridiculous ->
+ mkAdjDegr ridiculous ("more" ++ ridiculous) ("most" ++ ridiculous) ;
+
+-- simple adjectives are just strings
+
+ simpleAdj : Str -> Adjective = ss ;
+
+--3 Verbs
+--
+-- Except for "be", the worst case needs two forms.
+
+ mkVerbP3 : (_,_: Str) -> VerbP3 = \goes,go ->
+ {s = table {InfImp => go ; Indic P3 => goes ; Indic _ => go}} ;
+
+ regVerbP3 : Str -> VerbP3 = \walk ->
+ mkVerbP3 (walk + "s") walk ;
+
+ verbP3s : Str -> VerbP3 = \kiss ->
+ mkVerbP3 (kiss + "es") kiss ;
+
+ verbP3y : Str -> VerbP3 = \fl ->
+ mkVerbP3 (fl + "ies") (fl + "y") ;
+
+ verbP3Have = mkVerbP3 "has" "have" ;
+
+ verbP3Do = verbP3s "do" ;
+
+ verbBe : VerbP3 = {s = table {
+ InfImp => "be" ;
+ Indic P1 => "am" ;
+ Indic P2 => "are" ;
+ Indic P3 => "is"
+ }} ;
+
+ verbPart : VerbP3 -> Particle -> Verb = \v,p ->
+ v ** {s1 = p} ;
+
+ verbNoPart : VerbP3 -> Verb = \v -> verbPart v [] ;
+
+-- The optional negation contraction is a useful macro e.g. for "do".
+
+ contractNot : Str -> Str = \is -> variants {is ++ "not" ; is + "n't"} ;
+
+ dont = contractNot (verbP3Do.s ! InfImp) ;
+} ;
+
diff --git a/grammars/resource/english/Paradigms.gf b/grammars/resource/english/Paradigms.gf
new file mode 100644
index 000000000..65e5c1297
--- /dev/null
+++ b/grammars/resource/english/Paradigms.gf
@@ -0,0 +1,229 @@
+--1 English Lexical Paradigms
+--
+-- Aarne Ranta 2003
+--
+-- This is an API to the user of the resource grammar
+-- for adding lexical items. It give shortcuts for forming
+-- expressions of basic categories: nouns, adjectives, verbs.
+--
+-- Closed categories (determiners, pronouns, conjunctions) are
+-- accessed through the resource syntax API, $resource.Abs.gf$.
+--
+-- The main difference with $morpho.Eng.gf$ is that the types
+-- referred to are compiled resource grammar types. We have moreover
+-- had the design principle of always having existing forms as string
+-- arguments of the paradigms, not stems.
+--
+-- The following modules are presupposed:
+
+resource Paradigms = open (Predef=Predef), Prelude, Syntax, English in {
+
+--2 Parameters
+--
+-- To abstract over gender names, we define the following identifiers.
+
+oper
+ human : Gender ;
+ nonhuman : Gender ;
+
+-- To abstract over number names, we define the following.
+
+ singular : Number ;
+ plural : Number ;
+
+
+--2 Nouns
+
+-- Worst case: give all four forms and the semantic gender.
+-- In practice the worst case is just: give singular and plural nominative.
+
+oper
+ mkN : (man,men,man's,men's : Str) -> Gender -> N ;
+ nMan : (man,men : Str) -> Gender -> N ;
+
+-- Regular nouns, nouns ending with "s", "y", or "o", and nouns with the same
+-- plural form as the singular.
+
+ nReg : Str -> Gender -> N ; -- dog, dogs
+ nKiss : Str -> Gender -> N ; -- kiss, kisses
+ nFly : Str -> Gender -> N ; -- fly, flies
+ nHero : Str -> Gender -> N ; -- hero, heroes (= nKiss !)
+ nSheep : Str -> Gender -> N ; -- sheep, sheep
+
+-- These use general heuristics, that recognizes the last letter. *N.B* it
+-- does not get right with "boy", "rush", since it only looks at one letter.
+
+ nHuman : Str -> N ; -- gambler/actress/nanny
+ nNonhuman : Str -> N ; -- dog/kiss/fly
+
+-- Nouns used as functions need a preposition. The most common is "of".
+
+ mkFun : N -> Preposition -> Fun ;
+
+ funHuman : Str -> Fun ; -- the father/mistress/daddy of
+ funNonhuman : Str -> Fun ; -- the successor/address/copy of
+
+-- Proper names, with their regular genitive.
+
+ pnReg : (John : Str) -> PN ; -- John, John's
+
+-- The most common cases on the top level havee shortcuts.
+-- The regular "y"/"s" variation is taken into account in $CN$.
+
+ cnNonhuman : Str -> CN ;
+ cnHuman : Str -> CN ;
+ npReg : Str -> NP ;
+
+
+--2 Adjectives
+
+-- Non-comparison one-place adjectives just have one form.
+
+ mkAdj1 : (even : Str) -> Adj1 ;
+
+-- Two-place adjectives need a preposition as second argument.
+
+ mkAdj2 : (divisible, by : Str) -> Adj2 ;
+
+-- Comparison adjectives have three forms. The common irregular
+-- cases are ones ending with "y" and a consonant that is duplicated.
+
+ mkAdjDeg : (good,better,best : Str) -> AdjDeg ;
+
+ aReg : (long : Str) -> AdjDeg ; -- long, longer, longest
+ aHappy : (happy : Str) -> AdjDeg ; -- happy, happier, happiest
+ aFat : (fat : Str) -> AdjDeg ; -- fat, fatter, fattest
+ aRidiculous : (ridiculous : Str) -> AdjDeg ; -- -/more/most ridiculous
+
+-- On top level, there are adjectival phrases. The most common case is
+-- just to use a one-place adjective.
+
+ apReg : Str -> AP ;
+
+
+--2 Verbs
+--
+-- The fragment only has present tense so far, but in all persons.
+-- Except for "be", the worst case needs two forms: the infinitive and
+-- the third person singular.
+
+ mkV : (go, goes : Str) -> V ;
+
+ vReg : (walk : Str) -> V ; -- walk, walks
+ vKiss : (kiss : Str) -> V ; -- kiss, kisses
+ vFly : (fly : Str) -> V ; -- fly, flies
+ vGo : (go : Str) -> V ; -- go, goes (= vKiss !)
+
+-- This generic function recognizes the special cases where the last
+-- character is "y", "s", or "z". It is not right for "finish" and "convey".
+
+ vGen : Str -> V ; -- walk/kiss/fly
+
+-- The verbs "be" and "have" are special.
+
+ vBe : V ;
+ vHave : V ;
+
+-- Verbs with a particle.
+
+ vPart : (go, goes, up : Str) -> V ;
+ vPartReg : (get, up : Str) -> V ;
+
+-- Two-place verbs, and the special case with direct object.
+-- Notice that a particle can already be included in $V$.
+
+ mkTV : V -> Str -> TV ; -- look for, kill
+
+ tvGen : (look, for : Str) -> TV ; -- look for, talk about
+ tvDir : V -> TV ; -- switch off
+ tvGenDir : (kill : Str) -> TV ; -- kill
+
+-- Regular two-place verbs with a particle.
+
+ tvPartReg : Str -> Str -> Str -> TV ; -- get, along, with
+
+-- The definitions should not bother the user of the API. So they are
+-- hidden from the document.
+--.
+
+ human = Hum ;
+ nonhuman = NoHum ;
+ -- singular defined in types.Eng
+ -- plural defined in types.Eng
+
+ nominative = Nom ;
+
+ mkN = \man,men,man's,men's,g -> mkNoun man men man's men's ** {g = g} ;
+ nReg = addGenN nounReg ;
+ nKiss = addGenN nounS ;
+ nFly = \fly -> addGenN nounY (Predef.tk 1 fly) ;
+ nMan = \man,men -> mkN man men (man + "'s") (men + "'s") ;
+ nHero = nKiss ;
+ nSheep = \sheep -> nMan sheep sheep ;
+
+ nHuman = \s -> nGen s Hum ;
+ nNonhuman = \s -> nGen s NoHum ;
+
+ nGen : Str -> Gender -> N = \fly,g -> let {
+ fl = Predef.tk 1 fly ;
+ y = Predef.dp 1 fly ;
+ eqy = ifTok (Str -> Gender -> N) y
+ } in
+ eqy "y" nFly (
+ eqy "s" nKiss (
+ eqy "z" nKiss (
+ nReg))) fly g ;
+
+ mkFun = \n,p -> n ** {s2 = p} ;
+ funNonhuman = \s -> mkFun (nNonhuman s) "of" ;
+ funHuman = \s -> mkFun (nHuman s) "of" ;
+
+ pnReg = nameReg ;
+
+ cnNonhuman = \s -> UseN (nGen s nonhuman) ;
+ cnHuman = \s -> UseN (nGen s human) ;
+ npReg = \s -> UsePN (pnReg s) ;
+
+ addGenN : (Str -> CommonNoun) -> Str -> Gender -> N = \f ->
+ \s,g -> f s ** {g = g} ;
+
+ mkAdj1 = simpleAdj ;
+ mkAdj2 = \s,p -> simpleAdj s ** {s2 = p} ;
+ mkAdjDeg = mkAdjDegr ;
+ aReg = adjDegrReg ;
+ aHappy = \happy -> adjDegrY (Predef.tk 1 happy) ;
+ aFat = \fat -> let {fatt = fat + Predef.dp 1 fat} in
+ mkAdjDeg fat (fatt + "er") (fatt + "est") ;
+ aRidiculous = adjDegrLong ;
+ apReg = \s -> AdjP1 (mkAdj1 s) ;
+
+ mkV = \go,goes -> verbNoPart (mkVerbP3 goes go) ;
+ vReg = \run -> mkV run (run + "s") ;
+ vKiss = \kiss -> mkV kiss (kiss + "es") ;
+ vFly = \fly -> mkV fly (Predef.tk 1 fly + "ies") ;
+ vGo = vKiss ;
+
+ vGen = \fly -> let {
+ fl = Predef.tk 1 fly ;
+ y = Predef.dp 1 fly ;
+ eqy = ifTok (Str -> V) y
+ } in
+ eqy "y" vFly (
+ eqy "s" vKiss (
+ eqy "z" vKiss (
+ vReg))) fly ;
+
+ vPart = \go, goes, up -> verbPart (mkVerbP3 goes go) up ;
+ vPartReg = \get, up -> verbPart (regVerbP3 get) up ;
+
+ mkTV = \v,p -> v ** {s3 = p} ;
+ tvPartReg = \get, along, with -> mkTV (vPartReg get along) with ;
+
+ vBe = verbBe ;
+ vHave = mkV "have" "has" ;
+
+ tvGen = \s,p -> mkTV (vGen s) p ;
+ tvDir = \v -> mkTV v [] ;
+ tvGenDir = \s -> tvDir (vGen s) ;
+
+} ;
diff --git a/grammars/resource/english/Predication.gf b/grammars/resource/english/Predication.gf
new file mode 100644
index 000000000..cc92c465f
--- /dev/null
+++ b/grammars/resource/english/Predication.gf
@@ -0,0 +1,83 @@
+
+--1 A Small Predication Library
+--
+-- (c) Aarne Ranta 2003 under Gnu GPL.
+--
+-- This library is built on a language-independent API of
+-- resource grammars. It has a common part, the type signatures
+-- (defined here), and language-dependent parts. The user of
+-- the library should only have to look at the type signatures.
+
+resource Predication = open English in {
+
+-- We first define a set of predication patterns.
+
+oper
+ predV1 : V -> NP -> S ; -- one-place verb: "John walks"
+ predV2 : TV -> NP -> NP -> S ; -- two-place verb: "John loves Mary"
+ predVColl : V -> NP -> NP -> S ; -- collective verb: "John and Mary fight"
+ predA1 : Adj1 -> NP -> S ; -- one-place adjective: "John is old"
+ predA2 : Adj2 -> NP -> NP -> S ; -- two-place adj: "John is married to Mary"
+ predAComp : AdjDeg -> NP -> NP -> S ; -- compar adj: "John is older than Mary"
+ predAColl : Adj1 -> NP -> NP -> S ; -- collective adj: "John and Mary are married"
+ predN1 : N -> NP -> S ; -- one-place noun: "John is a man"
+ predN2 : Fun -> NP -> NP -> S ; -- two-place noun: "John is a lover of Mary"
+ predNColl : N -> NP -> NP -> S ; -- collective noun: "John and Mary are lovers"
+
+-- Individual-valued function applications.
+
+ appFun1 : Fun -> NP -> NP ; -- one-place function: "the successor of x"
+ appFunColl : Fun -> NP -> NP -> NP ; -- collective function: "the sum of x and y"
+
+-- Families of types, expressed by common nouns depending on arguments.
+
+ appFam1 : Fun -> NP -> CN ; -- one-place family: "divisor of x"
+ appFamColl : Fun -> NP -> NP -> CN ; -- collective family: "path between x and y"
+
+-- Type constructor, similar to a family except that the argument is a type.
+
+ constrTyp1 : Fun -> CN -> CN ;
+
+-- Logical connectives on two sentences.
+
+ conjS : S -> S -> S ;
+ disjS : S -> S -> S ;
+ implS : S -> S -> S ;
+
+-- As an auxiliary, we need two-place conjunction of names ("John and Mary"),
+-- used in collective predication.
+
+ conjNP : NP -> NP -> NP ;
+
+
+-----------------------------
+
+---- what follows should be an implementation of the preceding
+
+oper
+ predV1 = \F, x -> PredVP x (PosV F) ;
+ predV2 = \F, x, y -> PredVP x (PosTV F y) ;
+ predVColl = \F, x, y -> PredVP (conjNP x y) (PosV F) ;
+ predA1 = \F, x -> PredVP x (PosA F) ;
+ predA2 = \F, x, y -> PredVP x (PosA (ComplAdj F y)) ;
+ predAComp = \F, x, y -> PredVP x (PosA (ComparAdjP F y)) ;
+ predAColl = \F, x, y -> PredVP (conjNP x y) (PosA F) ;
+ predN1 = \F, x -> PredVP x (PosCN (UseN F)) ;
+ predN2 = \F, x, y -> PredVP x (PosCN (AppFun F y)) ;
+ predNColl = \F, x, y -> PredVP (conjNP x y) (PosCN (UseN F)) ;
+
+ appFun1 = \f, x -> DefOneNP (AppFun f x) ;
+ appFunColl = \f, x, y -> DefOneNP (AppFun f (conjNP x y)) ;
+
+ appFam1 = \F, x -> AppFun F x ;
+ appFamColl = \F, x, y -> AppFun F (conjNP x y) ;
+
+ conjS = \A, B -> ConjS AndConj (TwoS A B) ;
+ disjS = \A, B -> ConjS OrConj (TwoS A B) ;
+ implS = \A, B -> SubjS IfSubj A B ;
+
+ constrTyp1 = \F, A -> AppFun F (IndefManyNP A) ;
+
+ conjNP = \x, y -> ConjNP AndConj (TwoNP x y) ;
+
+} ;
diff --git a/grammars/resource/english/ResEng.gf b/grammars/resource/english/ResEng.gf
new file mode 100644
index 000000000..412bcfae7
--- /dev/null
+++ b/grammars/resource/english/ResEng.gf
@@ -0,0 +1,195 @@
+--1 The Top-Level English Resource Grammar
+--
+-- Aarne Ranta 2002 -- 2003
+--
+-- This is the English concrete syntax of the multilingual resource
+-- grammar. Most of the work is done in the file $syntax.Eng.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 $types.Eng.gf$.
+
+concrete ResEng of ResAbs = open Prelude, Syntax in {
+
+flags
+ startcat=Phr ;
+ parser=chart ;
+
+lincat
+ N = CommNoun ;
+ -- = {s : Number => Case => Str}
+ CN = CommNounPhrase ;
+ -- = CommNoun ** {g : Gender}
+ NP = {s : NPForm => Str ; n : Number ; p : Person} ;
+ PN = {s : Case => Str} ;
+ Det = {s : Str ; n : Number} ;
+ Fun = CommNounPhrase ** {s2 : Preposition} ;
+
+ Adj1 = Adjective ;
+ -- = {s : Str}
+ Adj2 = Adjective ** {s2 : Preposition} ;
+ AdjDeg = {s : Degree => Str} ;
+ AP = Adjective ** {p : Bool} ;
+
+ V = Verb ;
+ -- = {s : VForm => Str ; s1 : Particle}
+ VP = {s : VForm => Str ; s2 : Number => Str ; isAux : Bool} ;
+ TV = Verb ** {s3 : Preposition} ;
+ VS = Verb ;
+
+ AdV = {s : Str ; isPost : Bool} ;
+
+ S = {s : Str} ;
+ Slash = {s : Bool => Str ; s2 : Preposition} ;
+ RP = {s : Gender => Number => NPForm => Str} ;
+ RC = {s : Gender => Number => Str} ;
+
+ IP = {s : NPForm => Str ; n : Number} ;
+ 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 : Str ; s2 : Str} ;
+ ListAP = {s1 : Str ; s2 : Str ; p : Bool} ;
+ ListNP = {s1,s2 : NPForm => Str ; n : Number ; p : Person} ;
+
+--.
+
+lin
+ UseN = noun2CommNounPhrase ;
+ ModAdj = modCommNounPhrase ;
+ ModGenOne = npGenDet singular ;
+ ModGenMany = npGenDet plural ;
+ UsePN = nameNounPhrase ;
+ UseFun = funAsCommNounPhrase ;
+ AppFun = appFunComm ;
+ AdjP1 = adj2adjPhrase ;
+ ComplAdj = complAdj ;
+ PositAdjP = positAdjPhrase ;
+ ComparAdjP = comparAdjPhrase ;
+ SuperlNP = superlNounPhrase ;
+
+ DetNP = detNounPhrase ;
+ IndefOneNP = indefNounPhrase singular ;
+ IndefManyNP = indefNounPhrase plural ;
+ DefOneNP = defNounPhrase singular ;
+ DefManyNP = defNounPhrase plural ;
+
+ PredVP = predVerbPhrase ;
+ PosV = predVerb True ;
+ NegV = predVerb False ;
+ PosA = predAdjective True ;
+ NegA = predAdjective False ;
+ PosCN = predCommNoun True ;
+ NegCN = predCommNoun False ;
+ PosTV = complTransVerb True ;
+ NegTV = complTransVerb False ;
+ PosNP = predNounPhrase True ;
+ NegNP = predNounPhrase False ;
+ PosVS = complSentVerb True ;
+ NegVS = complSentVerb False ;
+
+
+ AdvVP = adVerbPhrase ;
+ LocNP = locativeNounPhrase ;
+ AdvCN = advCommNounPhrase ;
+
+ PosSlashTV = slashTransVerb True ;
+ NegSlashTV = slashTransVerb False ;
+
+ 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 ;
+
+ ImperVP = imperVerbPhrase ;
+
+ IndicPhrase = indicUtt ;
+ QuestPhrase = interrogUtt ;
+ ImperOne = imperUtterance singular ;
+ ImperMany = imperUtterance plural ;
+
+lin
+ 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 ;
+
+ PhrNP = useNounPhrase ;
+ PhrOneCN = useCommonNounPhrase singular ;
+ PhrManyCN = useCommonNounPhrase plural ;
+ PhrIP ip = ip ;
+ PhrIAdv ia = ia ;
+
+
+lin
+ INP = pronI ;
+ ThouNP = pronYouSg ;
+ HeNP = pronHe ;
+ SheNP = pronShe ;
+ WeNP = pronWe ;
+ YeNP = pronYouPl ;
+ YouNP = pronYouSg ;
+ TheyNP = pronThey ;
+
+ EveryDet = everyDet ;
+ AllDet = allDet ;
+ WhichDet = whichDet ;
+ MostDet = mostDet ;
+
+ HowIAdv = ss "how" ;
+ WhenIAdv = ss "when" ;
+ WhereIAdv = ss "where" ;
+ WhyIAdv = ss "why" ;
+
+ AndConj = ss "and" ** {n = Pl} ;
+ OrConj = ss "or" ** {n = Sg} ;
+ BothAnd = sd2 "both" "and" ** {n = Pl} ;
+ EitherOr = sd2 "either" "or" ** {n = Sg} ;
+ NeitherNor = sd2 "neither" "nor" ** {n = Sg} ;
+ IfSubj = ss "if" ;
+ WhenSubj = ss "when" ;
+
+ PhrYes = ss "Yes." ;
+ PhrNo = ss "No." ;
+} ;
diff --git a/grammars/resource/english/RestaurantEng.gf b/grammars/resource/english/RestaurantEng.gf
new file mode 100644
index 000000000..00a9392f0
--- /dev/null
+++ b/grammars/resource/english/RestaurantEng.gf
@@ -0,0 +1,25 @@
+concrete RestaurantEng of Restaurant =
+ DatabaseEng ** open Prelude,Paradigms,DatabaseRes in {
+
+lin
+ Restaurant = cnNonhuman "restaurant" ;
+ Bar = cnNonhuman "bar" ;
+ French = apReg "French" ;
+ Italian = apReg "Italian" ;
+ Indian = apReg "Indian" ;
+ Japanese = apReg "Japanese" ;
+
+ address = funNonhuman "address" ;
+ phone = funNonhuman ["number"] ; --- phone
+ priceLevel = funNonhuman ["level"] ; --- price
+
+ Cheap = aReg "cheap" ;
+ Expensive = aRidiculous "expensive" ;
+
+ WhoRecommend rest = mkSentSame (ss (["who recommended"] ++ rest.s ! nominative)) ;
+ WhoHellRecommend rest =
+ mkSentSame (ss (["who the hell recommended"] ++ rest.s ! nominative)) ;
+
+ LucasCarton = pnReg ["Lucas Carton"] ;
+
+} ;
diff --git a/grammars/resource/english/Syntax.gf b/grammars/resource/english/Syntax.gf
new file mode 100644
index 000000000..994b8722b
--- /dev/null
+++ b/grammars/resource/english/Syntax.gf
@@ -0,0 +1,848 @@
+--1 A Small English Resource Syntax
+--
+-- Aarne Ranta 2002
+--
+-- This resource grammar contains definitions needed to construct
+-- indicative, interrogative, and imperative sentences in English.
+--
+-- The following files are presupposed:
+
+resource Syntax = Morpho ** open Prelude, (CO = Coordination) in {
+
+--2 Common Nouns
+--
+-- Simple common nouns are defined as the type $CommNoun$ in $morpho.Deu.gf$.
+
+--3 Common noun phrases
+
+-- To the common nouns of morphology,
+-- we add natural gender (human/nonhuman) which is needed in syntactic
+-- combinations (e.g. "man who runs" - "program which runs").
+
+oper
+ CommNoun = CommonNoun ** {g : Gender} ;
+
+ CommNounPhrase = CommNoun ;
+
+ noun2CommNounPhrase : CommNoun -> CommNounPhrase = \man ->
+ man ;
+
+ cnGen : CommonNoun -> Gender -> CommNoun = \cn,g ->
+ cn ** {g = g} ;
+
+ cnHum : CommonNoun -> CommNoun = \cn ->
+ cnGen cn Hum ;
+ cnNoHum : CommonNoun -> CommNoun = \cn ->
+ cnGen cn NoHum ;
+
+--2 Noun phrases
+--
+-- The worst case is pronouns, which have inflection in the possessive forms.
+-- Proper names are a special case.
+
+ NounPhrase : Type = Pronoun ;
+
+ nameNounPhrase : ProperName -> NounPhrase = \john ->
+ {s = \\c => john.s ! toCase c ; n = Sg ; p = P3} ;
+
+--2 Determiners
+--
+-- Determiners are inflected according to the nouns they determine.
+-- The determiner is not inflected.
+ Determiner : Type = {s : Str ; n : Number} ;
+
+ detNounPhrase : Determiner -> CommNounPhrase -> NounPhrase = \every, man ->
+ {s = \\c => every.s ++ man.s ! every.n ! toCase c ;
+ n = every.n ;
+ p = P3
+ } ;
+
+ mkDeterminer : Number -> Str -> Determiner = \n,det ->
+ {s = det ;
+ n = n
+ } ;
+
+ everyDet = mkDeterminer Sg "every" ;
+ allDet = mkDeterminer Pl "all" ;
+ mostDet = mkDeterminer Pl "most" ;
+ aDet = mkDeterminer Sg artIndef ;
+ plDet = mkDeterminer Pl [] ;
+ theSgDet = mkDeterminer Sg "the" ;
+ thePlDet = mkDeterminer Pl "the" ;
+ anySgDet = mkDeterminer Sg "any" ;
+ anyPlDet = mkDeterminer Pl "any" ;
+
+ whichSgDet = mkDeterminer Sg "which" ;
+ whichPlDet = mkDeterminer Pl "which" ;
+
+ whichDet = whichSgDet ; --- API
+
+ indefNoun : Number -> CommNoun -> Str = \n,man ->
+ (indefNounPhrase n man).s ! NomP ;
+
+ indefNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n,man ->
+ {s = \\c => case n of {
+ Sg => artIndef ++ man.s ! n ! toCase c ;
+ Pl => man.s ! n ! toCase c
+ } ;
+ n = n ; p = P3
+ } ;
+
+ defNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n,car ->
+ {s = \\c => artDef ++ car.s ! n ! toCase c ; n = n ; p = P3} ;
+
+-- Genitives of noun phrases can be used like determiners, to build noun phrases.
+-- The number argument makes the difference between "my house" - "my houses".
+--
+-- We have the variation "the car of John / the car of John's / John's car"
+
+ npGenDet : Number -> NounPhrase -> CommNounPhrase -> NounPhrase =
+ \n,john,car ->
+ {s = \\c => variants {
+ artDef ++ car.s ! n ! Nom ++ "of" ++ john.s ! GenSP ;
+ john.s ! GenP ++ car.s ! n ! toCase c
+ } ;
+ n = n ;
+ p = P3
+ } ;
+
+-- *Bare plural noun phrases* like "men", "good cars", are built without a
+-- determiner word.
+
+ plurDet : CommNounPhrase -> NounPhrase = \cn ->
+ {s = \\c => cn.s ! plural ! toCase c ;
+ p = P3 ;
+ n = Pl
+ } ;
+
+
+--2 Adjectives
+--
+-- Adjectival phrases have a parameter $p$ telling if they are prefixed ($True$) or
+-- postfixed (complex APs).
+
+ AdjPhrase : Type = Adjective ** {p : Bool} ;
+
+ adj2adjPhrase : Adjective -> AdjPhrase = \new -> new ** {p = True} ;
+
+ simpleAdjPhrase : Str -> AdjPhrase = \French ->
+ adj2adjPhrase (simpleAdj French) ;
+
+--3 Comparison adjectives
+--
+-- Each of the comparison forms has a characteristic use:
+--
+-- Positive forms are used alone, as adjectival phrases ("big").
+
+ positAdjPhrase : AdjDegr -> AdjPhrase = \big ->
+ adj2adjPhrase (ss (big.s ! Pos)) ;
+
+-- Comparative forms are used with an object of comparison, as
+-- adjectival phrases ("bigger then you").
+
+ comparAdjPhrase : AdjDegr -> NounPhrase -> AdjPhrase = \big, you ->
+ {s = big.s ! Comp ++ "than" ++ you.s ! NomP ;
+ p = False
+ } ;
+
+-- Superlative forms are used with a modified noun, picking out the
+-- maximal representative of a domain ("the biggest house").
+
+ superlNounPhrase : AdjDegr -> CommNoun -> NounPhrase = \big, house ->
+ {s = \\c => "the" ++ big.s ! Sup ++ house.s ! Sg ! toCase c ;
+ n = Sg ;
+ p = P3
+ } ;
+
+
+--3 Two-place adjectives
+--
+-- A two-place adjective is an adjective with a preposition used before
+-- the complement.
+
+ Preposition = Str ;
+
+ AdjCompl = Adjective ** {s2 : Preposition} ;
+
+ complAdj : AdjCompl -> NounPhrase -> AdjPhrase = \related,john ->
+ {s = related.s ++ related.s2 ++ john.s ! AccP ;
+ p = False
+ } ;
+
+
+--3 Modification of common nouns
+--
+-- The two main functions of adjective are in predication ("John is old")
+-- and in modification ("an old man"). Predication will be defined
+-- later, in the chapter on verbs.
+--
+-- Modification must pay attention to pre- and post-noun
+-- adjectives: "big car"/"car bigger than X"
+
+ modCommNounPhrase : AdjPhrase -> CommNounPhrase -> CommNounPhrase = \big, car ->
+ {s = \\n => if_then_else (Case => Str) big.p
+ (\\c => big.s ++ car.s ! n ! c)
+ (table {Nom => car.s ! n ! Nom ++ big.s ; Gen => variants {}}) ;
+ g = car.g
+ } ;
+
+
+--2 Function expressions
+
+-- A function expression is a common noun together with the
+-- preposition prefixed to its argument ("mother of x").
+-- The type is analogous to two-place adjectives and transitive verbs.
+
+ Function = CommNounPhrase ** {s2 : Preposition} ;
+
+-- The application of a function gives, in the first place, a common noun:
+-- "mother/mothers of John". From this, other rules of the resource grammar
+-- give noun phrases, such as "the mother of John", "the mothers of John",
+-- "the mothers of John and Mary", and "the mother of John and Mary" (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 = \mother,john ->
+ {s = \\n => table {
+ Gen => nonExist ;
+ _ => mother.s ! n ! Nom ++ mother.s2 ++ john.s ! GenSP
+ } ;
+ g = mother.g
+ } ;
+
+-- 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 "John's mother" and "the mother of John". It does not appear in the
+-- resource grammar API any longer.
+
+ appFun : Bool -> Function -> NounPhrase -> NounPhrase = \coll, mother,john ->
+ let {n = john.n ; nf = if_then_else Number coll Sg n} in
+ variants {
+ defNounPhrase nf (appFunComm mother john) ;
+ npGenDet nf john mother
+ } ;
+
+-- The commonest case is functions with the preposition "of".
+
+ funOf : CommNoun -> Function = \mother ->
+ mother ** {s2 = "of"} ;
+
+ funOfReg : Str -> Gender -> Function = \mother,g ->
+ funOf (nounReg mother ** {g = g}) ;
+
+
+
+--2 Verbs
+--
+--3 Verb phrases
+--
+-- 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"
+-- There's also a parameter telling if the verb is an auxiliary:
+-- this is needed in question.
+
+ VerbPhrase = VerbP3 ** {s2 : Number => Str ; isAux : Bool} ;
+
+-- From the inflection table, we selecting the finite form as function
+-- of person and number:
+
+ indicVerb : VerbP3 -> Person -> Number -> Str = \v,p,n -> case n of {
+ Sg => v.s ! Indic p ;
+ Pl => v.s ! Indic P2
+ } ;
+
+-- 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 "don't" are not grammatical.
+
+ predVerb : Bool -> Verb -> VerbPhrase = \b,walk ->
+ if_then_else VerbPhrase b
+ {s = \\v => walk.s ! v ++ walk.s1 ;
+ s2 = \\_ => [] ;
+ isAux = False
+ }
+ {s = \\v => contractNot (verbP3Do.s ! v) ;
+ s2 = \\_ => walk.s ! InfImp ++ walk.s1 ;
+ isAux = True
+ } ;
+
+-- Sometimes we want to extract the verb part of a verb phrase.
+
+ verbOfPhrase : VerbPhrase -> VerbP3 = \v -> {s = v.s} ;
+
+-- Verb phrases can also be formed from adjectives ("is old"),
+-- common nouns ("is a man"), and noun phrases ("ist John").
+-- The third rule is overgenerating: "is every man" has to be ruled out
+-- on semantic grounds.
+
+ predAdjective : Bool -> Adjective -> VerbPhrase = \b,old ->
+ {s = beOrNotBe b ;
+ s2 = \\_ => old.s ;
+ isAux = True
+ } ;
+
+ predCommNoun : Bool -> CommNoun -> VerbPhrase = \b,man ->
+ {s = beOrNotBe b ;
+ s2 = \\n => indefNoun n man ;
+ isAux = True
+ } ;
+
+ predNounPhrase : Bool -> NounPhrase -> VerbPhrase = \b,john ->
+ {s = beOrNotBe b ;
+ s2 = \\_ => john.s ! NomP ;
+ isAux = True
+ } ;
+
+-- We use an auxiliary giving all forms of "be".
+
+ beOrNotBe : Bool -> (VForm => Str) = \b ->
+ if_then_else (VForm => Str) b
+ verbBe.s
+ (table {
+ InfImp => contractNot "do" ++ "be" ;
+ Indic P1 => "am" ++ "not" ;
+ v => contractNot (verbBe.s ! v)
+ }) ;
+
+--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 ** {s3 : Preposition} ;
+
+-- The rule for using transitive verbs is the complementization rule.
+-- Particles produce free variation: before or after the complement
+-- ("I switch on the TV" / "I switch the TV on").
+
+ complTransVerb : Bool -> TransVerb -> NounPhrase -> VerbPhrase =
+ \b,lookat,john ->
+ let {lookatjohn = bothWays lookat.s1 (lookat.s3 ++ john.s ! AccP)} in
+ if_then_else VerbPhrase b
+ {s = lookat.s ;
+ s2 = \\_ => lookatjohn ;
+ isAux = False}
+ {s = \\v => contractNot (verbP3Do.s ! v) ;
+ s2 = \\_ => lookat.s ! InfImp ++ lookatjohn ;
+ isAux = True} ;
+
+
+-- Verbs that take direct object and a particle:
+ mkTransVerbPart : VerbP3 -> Str -> TransVerb = \turn,off ->
+ {s = turn.s ; s1 = off ; s3 = []} ;
+
+-- Verbs that take prepositional object, no particle:
+ mkTransVerb : VerbP3 -> Str -> TransVerb = \wait,for ->
+ {s = wait.s ; s1 = [] ; s3 = for} ;
+
+-- Verbs that take direct object, no particle:
+ mkTransVerbDir : VerbP3 -> TransVerb = \love ->
+ mkTransVerbPart love [] ;
+
+
+--2 Adverbials
+--
+-- Adverbials are not inflected (we ignore comparison, and treat
+-- compared adverbials as separate expressions; this could be done another way).
+-- We distinguish between post- and pre-verbal adverbs.
+
+ Adverb : Type = SS ** {isPost : Bool} ;
+
+ advPre : Str -> Adverb = \seldom -> ss seldom ** {isPost = False} ;
+ advPost : Str -> Adverb = \well -> ss well ** {isPost = True} ;
+
+-- N.B. this rule generates the cyclic parsing rule $VP#2 ::= VP#2$
+-- and cannot thus be parsed.
+
+ adVerbPhrase : VerbPhrase -> Adverb -> VerbPhrase = \sings, well ->
+ let {postp = orB well.isPost sings.isAux} in
+ {
+ s = \\v => (if_then_else Str postp [] well.s) ++ sings.s ! v ;
+ s2 = \\n => sings.s2 ! n ++ (if_then_else Str postp well.s []) ;
+ isAux = sings.isAux
+ } ;
+
+-- Adverbials are typically generated by prefixing prepositions.
+-- The rule for creating locative noun phrases by the preposition "in"
+-- is a little shaky, since other prepositions may be preferred ("on", "at").
+
+ prepPhrase : Preposition -> NounPhrase -> Adverb = \on, it ->
+ advPost (on ++ it.s ! AccP) ;
+
+ locativeNounPhrase : NounPhrase -> Adverb =
+ prepPhrase "in" ;
+
+-- This is a source of the "mann with a telescope" ambiguity, and may produce
+-- strange things, like "cars always" (while "cars today" is OK).
+-- Semantics will have to make finer distinctions among adverbials.
+--
+-- N.B. the genitive case created in this way would not make sense.
+
+ advCommNounPhrase : CommNounPhrase -> Adverb -> CommNounPhrase = \car,today ->
+ {s = \\n => table {
+ Nom => car.s ! n ! Nom ++ today.s ;
+ Gen => nonExist
+ } ;
+ g = car.g
+ } ;
+
+
+--2 Sentences
+--
+-- Sentences are not inflected in this fragment of English without tense.
+
+ Sentence : Type = SS ;
+
+-- This is the traditional $S -> NP VP$ rule. It takes care of
+-- agreement between subject and verb. Recall that the VP may already
+-- contain negation.
+
+ predVerbPhrase : NounPhrase -> VerbPhrase -> Sentence = \john,walks ->
+ ss (john.s ! NomP ++ indicVerb (verbOfPhrase walks) john.p john.n ++
+ walks.s2 ! john.n) ;
+
+
+-- This is a macro for simultaneous predication and complementization.
+
+ predTransVerb : Bool -> NounPhrase -> TransVerb -> NounPhrase -> Sentence =
+ \b,you,see,john ->
+ predVerbPhrase you (complTransVerb b see john) ;
+
+
+--3 Sentence-complement verbs
+--
+-- Sentence-complement verbs take sentences as complements.
+
+ SentenceVerb : Type = Verb ;
+
+-- To generate "says that John walks" / "doesn't say that John walks":
+
+ complSentVerb : Bool -> SentenceVerb -> Sentence -> VerbPhrase =
+ \b,say,johnruns ->
+ let {thatjohnruns = optStr "that" ++ johnruns.s} in
+ if_then_else VerbPhrase b
+ {s = say.s ;
+ s2 = \\_ => thatjohnruns ;
+ isAux = False}
+ {s = \\v => contractNot (verbP3Do.s ! v) ;
+ s2 = \\_ => say.s ! InfImp ++ thatjohnruns ;
+ isAux = True} ;
+
+
+--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 a similar relation to sentences as
+-- transitive verbs have to verbs: it's like a *sentence taking a complement*.
+-- However, we need something more to distinguish its use in direct questions:
+-- not just "you see" but ("whom") "do you see".
+--
+-- The particle always follows the verb, but the preposition can fly:
+-- "whom you make it up with" / "with whom you make it up".
+
+ SentenceSlashNounPhrase = {s : Bool => Str ; s2 : Preposition} ;
+
+ slashTransVerb : Bool -> NounPhrase -> TransVerb -> SentenceSlashNounPhrase =
+ \b,You,lookat ->
+ let {you = You.s ! NomP ;
+ looks = indicVerb {s = lookat.s} You.p You.n ;
+ look = lookat.s ! InfImp ;
+ do = indicVerb verbP3Do You.p You.n ;
+ dont = contractNot do ;
+ up = lookat.s1
+ } in
+ {s = table {
+ True => if_then_else Str b do dont ++ you ++ look ++ up ;
+ False => you ++ if_then_else Str b looks (dont ++ look) ++ up
+ } ;
+ s2 = lookat.s3
+ } ;
+
+
+--2 Relative pronouns and relative clauses
+--
+-- As described in $types.Eng.gf$, relative pronouns are inflected in
+-- gender (human/nonhuman), number, and case.
+--
+-- We get the simple relative pronoun ("who"/"which"/"whom"/"whose"/"that"/$""$)
+-- from $morpho.Eng.gf$.
+
+ identRelPron : RelPron = relPron ;
+
+ funRelPron : Function -> RelPron -> RelPron = \mother,which ->
+ {s = \\g,n,c => "the" ++ mother.s ! n ! Nom ++
+ mother.s2 ++ which.s ! g ! n ! GenSP
+ } ;
+
+-- Relative clauses can be formed from both verb phrases ("who walks") and
+-- slash expressions ("whom you see", "on which you sit" / "that you sit on").
+
+ RelClause : Type = {s : Gender => Number => Str} ;
+
+ relVerbPhrase : RelPron -> VerbPhrase -> RelClause = \who,walks ->
+ {s = \\g, n => who.s ! g ! n ! NomP ++
+ indicVerb (verbOfPhrase walks) P3 n ++ walks.s2 ! n
+ } ;
+
+ relSlash : RelPron -> SentenceSlashNounPhrase -> RelClause = \who,yousee ->
+ {s = \\g,n =>
+ let {youSee = yousee.s ! False} in
+ variants {
+ who.s ! g ! n ! AccP ++ youSee ++ yousee.s2 ;
+ yousee.s2 ++ who.s ! g ! n ! GenSP ++ youSee
+ }
+ } ;
+
+-- A 'degenerate' relative clause is the one often used in mathematics, e.g.
+-- "number x such that x is even".
+
+ relSuch : Sentence -> RelClause = \A ->
+ {s = \\_,_ => "such" ++ "that" ++ A.s} ;
+
+-- 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. No comma is used before these relative clause.
+
+ modRelClause : CommNounPhrase -> RelClause -> CommNounPhrase = \man,whoruns ->
+ {s = \\n,c => man.s ! n ! c ++ whoruns.s ! man.g ! n ;
+ g = man.g
+ } ;
+
+
+--2 Interrogative pronouns
+--
+-- If relative pronouns are adjective-like, interrogative pronouns are
+-- noun-phrase-like.
+
+ IntPron : Type = {s : NPForm => Str ; n : Number} ;
+
+-- In analogy with relative pronouns, we have a rule for applying a function
+-- to a relative pronoun to create a new one.
+
+ funIntPron : Function -> IntPron -> IntPron = \mother,which ->
+ {s = \\c => "the" ++ mother.s ! which.n ! Nom ++ mother.s2 ++ which.s ! GenSP ;
+ n = which.n
+ } ;
+
+-- There is a variety of simple interrogative pronouns:
+-- "which house", "who", "what".
+
+ nounIntPron : Number -> CommNounPhrase -> IntPron = \n, car ->
+ {s = \\c => "which" ++ car.s ! n ! toCase c ;
+ n = n
+ } ;
+
+ intPronWho : Number -> IntPron = \num -> {
+ s = table {
+ NomP => "who" ;
+ AccP => variants {"who" ; "whom"} ;
+ GenP => "whose" ;
+ GenSP => "whom"
+ } ;
+ n = num
+ } ;
+
+ intPronWhat : Number -> IntPron = \num -> {
+ s = table {
+ GenP => "what's" ;
+ _ => "what"
+ } ;
+ n = num
+ } ;
+
+
+--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 -> ss (x.s ++ ".") ;
+ interrogUtt : Question -> Utterance = \x -> ss (x.s ! DirQ ++ "?") ;
+
+
+--2 Questions
+--
+-- Questions are either direct ("are you happy") or indirect
+-- ("if/whether you are happy").
+
+param
+ QuestForm = DirQ | IndirQ ;
+
+oper
+ Question = SS1 QuestForm ;
+
+--3 Yes-no questions
+--
+-- Yes-no questions are used both independently
+-- ("does John walk" / "if John walks")
+-- and after interrogative adverbials
+-- ("why does John walk" / "why John walks").
+--
+-- It is economical to handle with all these cases by the one
+-- rule, $questVerbPhrase'$. The word ("ob" / "whether") never appears
+-- if there is an adverbial.
+
+ questVerbPhrase : NounPhrase -> VerbPhrase -> Question =
+ questVerbPhrase' False ;
+
+ questVerbPhrase' : Bool -> NounPhrase -> VerbPhrase -> Question =
+ \adv,john,walk ->
+ {s = table {
+ DirQ => if_then_else Str walk.isAux
+ (indicVerb (verbOfPhrase walk) john.p john.n ++
+ john.s ! NomP ++ walk.s2 ! john.n)
+ (indicVerb verbP3Do john.p john.n ++
+ john.s ! NomP ++ walk.s ! InfImp ++ walk.s2 ! john.n) ;
+ IndirQ => if_then_else Str adv [] (variants {"if" ; "whether"}) ++
+ (predVerbPhrase john walk).s
+ }
+ } ;
+
+
+
+--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 = \who,walk ->
+ {s = \\_ => who.s ! NomP ++ indicVerb (verbOfPhrase walk) P3 who.n ++
+ walk.s2 ! who.n
+ } ;
+
+ intSlash : IntPron -> SentenceSlashNounPhrase -> Question = \who,yousee ->
+ {s = \\q =>
+ let {youSee = case q of {
+ DirQ => yousee.s ! True ;
+ IndirQ => yousee.s ! False
+ }
+ } in
+ variants {
+ who.s ! AccP ++ youSee ++ yousee.s2 ;
+ yousee.s2 ++ who.s ! GenSP ++ youSee
+ }
+ } ;
+
+--3 Interrogative adverbials
+--
+-- These adverbials will be defined in the lexicon: they include
+-- "when", "where", "how", "why", 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.
+
+ IntAdverb = SS ;
+
+ prepIntAdverb : Preposition -> IntPron -> IntAdverb = \at, whom ->
+ ss (at ++ whom.s ! AccP) ;
+
+-- A question adverbial can be applied to anything, and whether this makes
+-- sense is a semantic question.
+
+ questAdverbial : IntAdverb -> NounPhrase -> VerbPhrase -> Question =
+ \why, you, walk ->
+ {s = \\q => why.s ++ (questVerbPhrase' True you walk).s ! q} ;
+
+
+--2 Imperatives
+--
+-- We only consider second-person imperatives.
+
+ Imperative = SS1 Number ;
+
+ imperVerbPhrase : VerbPhrase -> Imperative = \walk ->
+ {s = \\n => walk.s ! InfImp ++ walk.s2 ! n} ;
+
+ imperUtterance : Number -> Imperative -> Utterance = \n,I ->
+ ss (I.s ! n ++ "!") ;
+
+
+--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 ("and", "or") or distributed ("both - and", "either - or").
+--
+-- The conjunction has an inherent number, which is used when conjoining
+-- noun phrases: "John and Mary are..." vs. "John or Mary is..."; in the
+-- case of "or", 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 = SD2 ;
+
+ twoSentence : (_,_ : Sentence) -> ListSentence = CO.twoSS ;
+
+ consSentence : ListSentence -> Sentence -> ListSentence =
+ CO.consSS 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. "du rauchst, er trinkt und ich esse".
+
+ conjunctSentence : Conjunction -> ListSentence -> Sentence = \c,xs ->
+ ss (CO.conjunctX c xs) ;
+
+-- To coordinate a list of sentences by a distributed conjunction, we place
+-- the first part (e.g. "either") in front of the first element, the second
+-- part ("or") between the last two elements, and commas in the other slots.
+-- For sentences this is really not used.
+
+ conjunctDistrSentence : ConjunctionDistr -> ListSentence -> Sentence =
+ \c,xs ->
+ ss (CO.conjunctDistrX c xs) ;
+
+--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 = SD2 ** {p : Bool} ;
+
+ twoAdjPhrase : (_,_ : AdjPhrase) -> ListAdjPhrase = \x,y ->
+ CO.twoStr x.s y.s ** {p = andB x.p y.p} ;
+
+ consAdjPhrase : ListAdjPhrase -> AdjPhrase -> ListAdjPhrase = \xs,x ->
+ CO.consStr CO.comma xs x.s ** {p = andB xs.p x.p} ;
+
+ conjunctAdjPhrase : Conjunction -> ListAdjPhrase -> AdjPhrase = \c,xs ->
+ ss (CO.conjunctX c xs) ** {p = xs.p} ;
+
+ conjunctDistrAdjPhrase : ConjunctionDistr -> ListAdjPhrase -> AdjPhrase =
+ \c,xs ->
+ ss (CO.conjunctDistrX 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.
+
+ ListNounPhrase : Type = {s1,s2 : NPForm => Str ; n : Number ; p : Person} ;
+
+ twoNounPhrase : (_,_ : NounPhrase) -> ListNounPhrase = \x,y ->
+ CO.twoTable NPForm x y ** {n = conjNumber x.n y.n ; p = conjPerson x.p y.p} ;
+
+ consNounPhrase : ListNounPhrase -> NounPhrase -> ListNounPhrase = \xs,x ->
+ CO.consTable NPForm CO.comma xs x **
+ {n = conjNumber xs.n x.n ; p = conjPerson xs.p x.p} ;
+
+ conjunctNounPhrase : Conjunction -> ListNounPhrase -> NounPhrase = \c,xs ->
+ CO.conjunctTable NPForm c xs ** {n = conjNumber c.n xs.n ; p = xs.p} ;
+
+ conjunctDistrNounPhrase : ConjunctionDistr -> ListNounPhrase -> NounPhrase =
+ \c,xs ->
+ CO.conjunctDistrTable NPForm c xs ** {n = conjNumber c.n xs.n ; p = xs.p} ;
+
+-- We have to define a calculus of numbers of persons. For numbers,
+-- it is like the conjunction with $Pl$ corresponding to $False$.
+
+ conjNumber : Number -> Number -> Number = \m,n -> case <m,n> of {
+ <Sg,Sg> => Sg ;
+ _ => Pl
+ } ;
+
+-- For persons, we let the latter argument win ("either you or I am absent"
+-- but "either I or you are absent"). This is not quite clear.
+
+ conjPerson : Person -> Person -> Person = \_,p ->
+ p ;
+
+
+
+--2 Subjunction
+--
+-- Subjunctions ("when", "if", 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.
+-- "if you smoke I get angry"
+-- and "I get angry if you smoke".
+
+ Subjunction = SS ;
+
+ subjunctSentence : Subjunction -> Sentence -> Sentence -> Sentence =
+ \if, A, B ->
+ ss (subjunctVariants if A.s B.s) ;
+
+ subjunctImperative : Subjunction -> Sentence -> Imperative -> Imperative =
+ \if, A, B ->
+ {s = \\n => subjunctVariants if A.s (B.s ! n)} ;
+
+ subjunctQuestion : Subjunction -> Sentence -> Question -> Question =
+ \if, A, B ->
+ {s = \\q => subjunctVariants if A.s (B.s ! q)} ;
+
+ subjunctVariants : Subjunction -> Str -> Str -> Str = \if,A,B ->
+ variants {if.s ++ A ++ "," ++ B ; B ++ "," ++ if.s ++ A} ;
+
+
+--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) ;
+
+ useRegularName : SS -> NounPhrase = \john ->
+ nameNounPhrase (nameReg john.s) ;
+
+-- Here are some default forms.
+
+ defaultNounPhrase : NounPhrase -> SS = \john ->
+ ss (john.s ! NomP) ;
+
+ defaultQuestion : Question -> SS = \whoareyou ->
+ ss (whoareyou.s ! DirQ) ;
+
+ defaultSentence : Sentence -> Utterance = \x ->
+ x ;
+
+} ;
diff --git a/grammars/resource/english/TestEng.gf b/grammars/resource/english/TestEng.gf
new file mode 100644
index 000000000..57d81d173
--- /dev/null
+++ b/grammars/resource/english/TestEng.gf
@@ -0,0 +1,36 @@
+concrete TestEng of TestAbs = ResEng ** open Syntax in {
+
+flags startcat=Phr ; lexer=text ; parser=chart ; unlexer=text ;
+
+-- a random sample from the lexicon
+
+lin
+ Big = mkAdjDegr "big" "bigger" "biggest";
+ Small = adjDegrReg "small" ;
+ Old = adjDegrReg "old" ;
+ Young = adjDegrReg "young" ;
+ Man = cnHum (mkNoun "man" "men" "man's" "men's") ;
+ Woman = cnHum (mkNoun "woman" "women" "woman's" "women's") ;
+ Car = cnNoHum (nounReg "car") ;
+ House = cnNoHum (nounReg "house") ;
+ Light = cnNoHum (nounReg "light") ;
+ Walk = verbNoPart (regVerbP3 "walk") ;
+ Run = verbNoPart (regVerbP3 "run") ;
+ Say = verbNoPart (regVerbP3 "say") ;
+ Prove = verbNoPart (regVerbP3 "prove") ;
+ Send = mkTransVerbDir (regVerbP3 "send") ;
+ Love = mkTransVerbDir (regVerbP3 "love") ;
+ Wait = mkTransVerb (regVerbP3 "wait") "for" ;
+ Mother = funOfReg "mother" Hum ;
+ Uncle = funOfReg "uncle" Hum ;
+
+ Always = advPre "always" ;
+ Well = advPost "well" ;
+
+ SwitchOn = mkTransVerbPart (verbP3s "switch") "on" ;
+ SwitchOff = mkTransVerbPart (verbP3s "switch") "off" ;
+
+ John = nameReg "John" ;
+ Mary = nameReg "Mary" ;
+
+} ;
diff --git a/grammars/resource/english/Types.gf b/grammars/resource/english/Types.gf
new file mode 100644
index 000000000..a43ffd81b
--- /dev/null
+++ b/grammars/resource/english/Types.gf
@@ -0,0 +1,101 @@
+--1 English Word Classes and Morphological Parameters
+--
+-- This is a resource module for English morphology, defining the
+-- morphological parameters and word classes of English. It is aimed
+-- to be complete w.r.t. the description of word forms.
+-- However, it only includes those parameters that are needed for
+-- analysing individual words: such parameters are defined in syntax modules.
+--
+-- we use the language-independent prelude.
+
+resource Types = open Prelude in {
+
+--
+--2 Enumerated parameter types
+--
+-- These types are the ones found in school grammars.
+-- Their parameter values are atomic.
+
+param
+ Number = Sg | Pl ;
+ Gender = NoHum | Hum ;
+ Case = Nom | Gen ;
+ Person = P1 | P2 | P3 ;
+ Degree = Pos | Comp | Sup ;
+
+-- For data abstraction, we define
+
+oper
+ singular = Sg ;
+ plural = Pl ;
+
+--2 Word classes and hierarchical parameter types
+--
+-- Real parameter types (i.e. ones on which words and phrases depend)
+-- are often hierarchical. The alternative would be cross-products of
+-- simple parameters, but this would usually overgenerate.
+--
+
+--3 Common nouns
+--
+-- Common nouns are inflected in number and case.
+
+ CommonNoun : Type = {s : Number => Case => Str} ;
+
+
+--
+--3 Adjectives
+--
+-- The major division is between the comparison degrees, but it
+-- is also good to leave room for adjectives that cannon be compared.
+-- Such adjectives are simply strings.
+
+ Adjective : Type = SS ;
+ AdjDegr = SS1 Degree ;
+
+--3 Verbs
+--
+-- We limit the grammar so far to verbs in infinitive-imperative or present tense.
+-- The present tense is made to depend on person, which correspond to forms
+-- in the singular; plural forms are uniformly equal to the 2nd person singular.
+
+param
+ VForm = InfImp | Indic Person ;
+
+oper
+ VerbP3 : Type = SS1 VForm ;
+
+-- A full verb can moreover have a particle.
+
+ Particle : Type = Str ;
+ Verb = VerbP3 ** {s1 : Particle} ;
+
+--
+--3 Pronouns
+--
+-- For pronouns, we need four case forms: "I" - "me" - "my" - "mine".
+
+param
+ NPForm = NomP | AccP | GenP | GenSP ;
+
+oper
+ Pronoun : Type = {s : NPForm => Str ; n : Number ; p : Person} ;
+
+-- Coercions between pronoun cases and ordinaty cases.
+
+ toCase : NPForm -> Case = \c -> case c of {GenP => Gen ; _ => Nom} ;
+ toNPForm : Case -> NPForm = \c -> case c of {Gen => GenP ; _ => NomP} ; ---
+
+--3 Proper names
+--
+-- Proper names only need two cases.
+
+ ProperName : Type = SS1 Case ;
+
+--3 Relative pronouns
+--
+-- Relative pronouns are inflected in gender (human/nonhuman), number, and case.
+
+ RelPron : Type = {s : Gender => Number => NPForm => Str} ;
+} ;
+
diff --git a/grammars/resource/german/DatabaseDeu.gf b/grammars/resource/german/DatabaseDeu.gf
new file mode 100644
index 000000000..a7a8f278e
--- /dev/null
+++ b/grammars/resource/german/DatabaseDeu.gf
@@ -0,0 +1,52 @@
+concrete DatabaseDeu of Database =
+ open Prelude,Syntax,Deutsch,Predication,Paradigms,DatabaseRes in {
+
+flags lexer=text ; unlexer=text ;
+
+lincat
+ Phras = SS1 Bool ; -- long or short form
+ Subject = NP ;
+ Noun = CN ;
+ Property = AP ;
+ Comparison = AdjDeg ;
+ Relation = Adj2 ;
+ Feature = Fun ;
+ Value = NP ;
+ Name = ProperName ;
+
+lin
+ LongForm sent = ss (sent.s ! True ++ "?") ;
+ ShortForm sent = ss (sent.s ! False ++ "?") ;
+
+ WhichAre A B = mkSent (defaultQuestion (IntVP (NounIPMany A) (PosA B)))
+ (defaultNounPhrase (IndefManyNP (ModAdj B A))) ;
+
+ IsIt Q A = mkSentSame (defaultQuestion (QuestVP Q (PosA A))) ;
+
+ MoreThan = ComparAdjP ;
+ TheMost = SuperlNP ;
+ Relatively C _ = PositAdjP C ;
+
+ RelatedTo = ComplAdj ;
+
+ FeatureOf = appFun1 ;
+ ValueOf F V = appFun1 F (UsePN V) ;
+
+ WithProperty A B = ModAdj B A ;
+
+ Individual = nameNounPhrase ;
+
+ AllN = DetNP AllDet ;
+ MostN = DetNP MostDet ;
+ EveryN = DetNP EveryDet ;
+
+-- only these are language-dependent
+
+ Any = detNounPhrase einDet ;
+
+ IsThere A = mkSentPrel ["gibt es"] (defaultNounPhrase (IndefOneNP A)) ;
+ AreThere A = mkSentPrel ["gibt es"] (defaultNounPhrase (IndefManyNP A)) ;
+
+ WhatIs V = mkSentPrel ["was ist"] (defaultNounPhrase V) ;
+
+} ;
diff --git a/grammars/resource/german/DatabaseRes.gf b/grammars/resource/german/DatabaseRes.gf
new file mode 100644
index 000000000..57bac16ac
--- /dev/null
+++ b/grammars/resource/german/DatabaseRes.gf
@@ -0,0 +1,11 @@
+resource DatabaseRes = open Prelude in {
+oper
+ mkSent : SS -> SS -> SS1 Bool = \long, short ->
+ {s = table {b => if_then_else Str b long.s short.s}} ;
+
+ mkSentPrel : Str -> SS -> SS1 Bool = \prel, matter ->
+ mkSent (ss (prel ++ matter.s)) matter ;
+
+ mkSentSame : SS -> SS1 Bool = \s ->
+ mkSent s s ;
+} ;
diff --git a/grammars/resource/german/Deutsch.gf b/grammars/resource/german/Deutsch.gf
new file mode 100644
index 000000000..4a91ad219
--- /dev/null
+++ b/grammars/resource/german/Deutsch.gf
@@ -0,0 +1 @@
+resource Deutsch = reuse ResDeu ;
diff --git a/grammars/resource/german/Logical.gf b/grammars/resource/german/Logical.gf
new file mode 100644
index 000000000..3347ae129
--- /dev/null
+++ b/grammars/resource/german/Logical.gf
@@ -0,0 +1,23 @@
+-- Slightly ad hoc and formal negation and connectives.
+
+resource Logical = Predication ** open Deutsch, Paradigms in {
+
+ oper
+ negS : S -> S ; -- es ist nicht der Fall, dass S
+ univS : CN -> S -> S ; -- für alle CNs gilt es, dass S
+ existS : CN -> S -> S ; -- es gibt ein CN derart, dass S
+ existManyS : CN -> S -> S ; -- es gibt CNs derart, dass S
+--.
+
+ negS = \A ->
+ PredVP ItNP (NegNP (DefOneNP (CNthatS (UseN (nRaum "Fall" "Fälle")) A))) ;
+ univS = \A,B ->
+ PredVP ItNP (AdvVP (PosVS (mkV "gelten" "gilt" "gelte" "gegolten") B)
+ (mkPP accusative "für" (DetNP AllDet A))) ;
+ existS = \A,B ->
+ PredVP ItNP (PosTV (tvDir (mkV "geben" "gibt" "gib" "gegeben"))
+ (IndefOneNP (ModRC A (RelSuch B)))) ;
+ existManyS = \A,B ->
+ PredVP ItNP (PosTV (tvDir (mkV "geben" "gibt" "gib" "gegeben"))
+ (IndefManyNP (ModRC A (RelSuch B)))) ;
+} ;
diff --git a/grammars/resource/german/Morpho.gf b/grammars/resource/german/Morpho.gf
new file mode 100644
index 000000000..f286bc3b7
--- /dev/null
+++ b/grammars/resource/german/Morpho.gf
@@ -0,0 +1,399 @@
+--1 A Simple German Resource Morphology
+--
+-- Aarne Ranta 2002
+--
+-- This resource morphology contains definitions needed in the resource
+-- syntax. It moreover contains the most usual inflectional patterns.
+--
+-- We use the parameter types and word classes defined in $types.Deu.gf$.
+
+resource Morpho = Types ** open (Predef=Predef), Prelude in {
+
+--2 Nouns
+--
+-- For conciseness and abstraction, we define a method for
+-- generating a case-dependent table from a list of four forms.
+
+oper
+ caselist : (_,_,_,_ : Str) -> Case => Str = \n,a,d,g -> table {
+ Nom => n ; Acc => a ; Dat => d ; Gen => g} ;
+
+-- The *worst-case macro* for common nouns needs six forms: all plural forms
+-- are always the same except for the dative.
+
+ mkNoun : (_,_,_,_,_,_ : Str) -> Gender -> CommNoun =
+ \mann, mannen, manne, mannes, männer, männern, g -> {s = table {
+ Sg => caselist mann mannen manne mannes ;
+ Pl => caselist männer männer männern männer
+ } ; g = g} ;
+
+-- But we never need all the six forms at the same time. Often
+-- we need just two, three, or four forms.
+
+ mkNoun4 : (_,_,_,_ : Str) -> Gender -> CommNoun = \kuh,kuhes,kühe,kühen ->
+ mkNoun kuh kuh kuh kuhes kühe kühen ;
+
+ mkNoun3 : (_,_,_ : Str) -> Gender -> CommNoun = \kuh,kühe,kühen ->
+ mkNoun kuh kuh kuh kuh kühe kühen ;
+
+ mkNoun2n : (_,_ : Str) -> Gender -> CommNoun = \zahl, zahlen ->
+ mkNoun3 zahl zahlen zahlen ;
+
+ mkNoun2es : (_,_ : Str) -> Gender -> CommNoun = \wort, wörter ->
+ mkNoun wort wort wort (wort + "es") wörter (wörter + "n") ;
+
+ mkNoun2s : (_,_ : Str) -> Gender -> CommNoun = \vater, väter ->
+ mkNoun vater vater vater (vater + "s") väter (väter + "n") ;
+
+ mkNoun2ses : (_,_ : Str) -> Gender -> CommNoun = \wort,wörter ->
+ mkNoun wort wort wort (wort + variants {"es" ; "s"}) wörter (wörter + "n") ;
+
+-- Here are the school grammar declensions with their commonest variations.
+-- Unfortunately we cannot define *Umlaut* in GF, but have to give two forms.
+--
+-- First declension, with plural "en"/"n", including weak masculins:
+
+ declN1 : Str -> CommNoun = \zahl ->
+ mkNoun2n zahl (zahl + "en") Fem ;
+
+ declN1e : Str -> CommNoun = \stufe ->
+ mkNoun2n stufe (stufe + "n") Fem ;
+
+ declN1M : Str -> CommNoun = \junge -> let {jungen = junge + "n"} in
+ mkNoun junge jungen jungen jungen jungen jungen Masc ;
+
+ declN1eM : Str -> CommNoun = \soldat -> let {soldaten = soldat + "en"} in
+ mkNoun soldat soldaten soldaten soldaten soldaten soldaten Masc ;
+
+-- Second declension, with plural "e":
+
+ declN2 : Str -> CommNoun = \punkt ->
+ mkNoun2es punkt (punkt+"e") Masc ;
+
+ declN2i : Str -> CommNoun = \onkel ->
+ mkNoun2s onkel onkel Masc ;
+
+ declN2u : (_,_ : Str) -> CommNoun = \raum,räume ->
+ mkNoun2es raum räume Masc ;
+
+ declN2uF : (_,_ : Str) -> CommNoun = \kuh,kühe ->
+ mkNoun3 kuh kühe (kühe + "n") Fem ;
+
+-- Third declension, with plural "er":
+
+ declN3 : Str -> CommNoun = \punkt ->
+ mkNoun2es punkt (punkt+"er") Neut ;
+
+ declN3u : (_,_ : Str) -> CommNoun = \buch,bücher ->
+ mkNoun2ses buch bücher Neut ;
+
+ declN3uS : (_,_ : Str) -> CommNoun = \haus,häuser ->
+ mkNoun2es haus häuser Neut ;
+
+-- Plural with "s":
+
+ declNs : Str -> CommNoun = \restaurant ->
+ mkNoun3 restaurant (restaurant+"s") (restaurant+"s") Neut ;
+
+
+--2 Pronouns
+--
+-- Here we define personal and relative pronouns.
+-- All personal pronouns, except "ihr", conform to the simple
+-- pattern $mkPronPers$.
+
+ ProPN = {s : NPForm => Str ; n : Number ; p : Person} ;
+
+ mkPronPers : (_,_,_,_,_ : Str) -> Number -> Person -> ProPN =
+ \ich,mich,mir,meines,mein,n,p -> {
+ s = table {
+ NPCase c => caselist ich mich mir meines ! c ;
+ NPPoss gn c => mein + pronEnding ! gn ! c
+ } ;
+ n = n ;
+ p = p
+ } ;
+
+ pronEnding : GenNum => Case => Str = table {
+ GSg Masc => caselist "" "en" "em" "es" ;
+ GSg Fem => caselist "e" "e" "er" "er" ;
+ GSg Neut => caselist "" "" "em" "es" ;
+ GPl => caselist "e" "e" "en" "er"
+ } ;
+
+ pronIch = mkPronPers "ich" "mich" "mir" "meines" "mein" Sg P1 ;
+ pronDu = mkPronPers "du" "dich" "dir" "deines" "dein" Sg P2 ;
+ pronEr = mkPronPers "er" "ihn" "ihm" "seines" "sein" Sg P3 ;
+ pronSie = mkPronPers "sie" "sie" "ihr" "ihres" "ihr" Sg P3 ;
+ pronEs = mkPronPers "es" "es" "ihm" "seines" "sein" Sg P3 ;
+ pronWir = mkPronPers "wir" "uns" "uns" "unser" "unser" Pl P1 ;
+
+ pronSiePl = mkPronPers "sie" "sie" "ihnen" "ihrer" "ihr" Pl P3 ;
+ pronSSie = mkPronPers "Sie" "Sie" "Ihnen" "Ihrer" "Ihr" Pl P3 ; ---
+
+-- We still have wrong agreement with the complement of the polite "Sie":
+-- it is in plural, like the verb, although it should be in singular.
+
+-- The peculiarity with "ihr" is the presence of "e" in forms without an ending.
+
+ pronIhr =
+ {s = table {
+ NPPoss (GSg Masc) Nom => "euer" ;
+ NPPoss (GSg Neut) Nom => "euer" ;
+ NPPoss (GSg Neut) Acc => "euer" ;
+ pf => (mkPronPers "ihr" "euch" "euch" "euer" "eur" Pl P2).s ! pf
+ } ;
+ n = Pl ;
+ p = P2
+ } ;
+
+-- Relative pronouns are like the definite article, except in the genitive and
+-- the plural dative. The function $artDef$ will be defined right below.
+
+ RelPron : Type = {s : GenNum => Case => Str} ;
+
+ relPron : RelPron = {s = \\gn,c =>
+ case <gn,c> of {
+ <GSg Fem,Gen> => "deren" ;
+ <GSg g,Gen> => "dessen" ;
+ <GPl,Dat> => "denen" ;
+ <GPl,Gen> => "deren" ;
+ _ => artDef ! gn ! c
+ }
+ } ;
+
+
+--2 Articles
+--
+-- Here are all forms the indefinite and definite article.
+-- The indefinite article is like a large class of pronouns.
+-- The definite article is more peculiar; we don't try to
+-- subsume it to any general rule.
+
+ artIndef : Gender => Case => Str = \\g,c => "ein" + pronEnding ! GSg g ! c ;
+
+ artDef : GenNum => Case => Str = table {
+ GSg Masc => caselist "der" "den" "dem" "des" ;
+ GSg Fem => caselist "die" "die" "der" "der" ;
+ GSg Neut => caselist "das" "das" "dem" "des" ;
+ GPl => caselist "die" "die" "den" "der"
+ } ;
+
+
+--2 Adjectives
+--
+-- As explained in $types.Deu.gf$, it
+-- would be superfluous to use the cross product of gender and number,
+-- since there is no gender distinction in the plural. But it is handy to have
+-- a function that constructs gender-number complexes.
+
+ gNumber : Gender -> Number -> GenNum = \g,n ->
+ case n of {
+ Sg => GSg g ;
+ Pl => GPl
+ } ;
+
+-- It's also handy to have a function that finds out the number from such a complex.
+
+ numGenNum : GenNum -> Number = \gn ->
+ case gn of {
+ GSg _ => Sg ;
+ GPl => Pl
+ } ;
+
+-- This function costructs parameters in the complex type of adjective forms.
+
+ aMod : Adjf -> Gender -> Number -> Case -> AForm = \a,g,n,c ->
+ AMod a (gNumber g n) c ;
+
+-- The worst-case macro for adjectives (positive degree) only needs
+-- two forms.
+
+ mkAdjective : (_,_ : Str) -> Adjective = \böse,bös -> {s = table {
+ APred => böse ;
+ AMod Strong (GSg Masc) c =>
+ caselist (bös+"er") (bös+"en") (bös+"em") (bös+"es") ! c ;
+ AMod Strong (GSg Fem) c =>
+ caselist (bös+"e") (bös+"e") (bös+"er") (bös+"er") ! c ;
+ AMod Strong (GSg Neut) c =>
+ caselist (bös+"es") (bös+"es") (bös+"em") (bös+"es") ! c ;
+ AMod Strong GPl c =>
+ caselist (bös+"e") (bös+"e") (bös+"en") (bös+"er") ! c ;
+ AMod Weak (GSg g) c => case <g,c> of {
+ <_,Nom> => bös+"e" ;
+ <Masc,Acc> => bös+"en" ;
+ <_,Acc> => bös+"e" ;
+ _ => bös+"en" } ;
+ AMod Weak GPl c => bös+"en"
+ }} ;
+
+-- Here are some classes of adjectives:
+
+ adjReg : Str -> Adjective = \gut -> mkAdjective gut gut ;
+ adjE : Str -> Adjective = \bös -> mkAdjective (bös+"e") bös ;
+ adjEr : Str -> Adjective = \teu -> mkAdjective (teu+"er") (teu+"r") ;
+ adjInvar : Str -> Adjective = \prima -> {s = table {_ => prima}} ;
+
+-- The first three classes can be recognized from the end of the word, depending
+-- on if it is "e", "er", or something else.
+
+ adjGen : Str -> Adjective = \gut -> let {
+ er = Predef.dp 2 gut ;
+ teu = Predef.tk 2 gut ;
+ e = Predef.dp 1 gut ;
+ bös = Predef.tk 1 gut
+ } in
+ ifTok Adjective er "er" (adjEr teu) (
+ ifTok Adjective e "e" (adjE bös) (
+ (adjReg gut))) ;
+
+
+-- The comparison of adjectives needs three adjectives in the worst case.
+
+ mkAdjComp : (_,_,_ : Adjective) -> AdjComp = \gut,besser,best ->
+ {s = table {Pos => gut.s ; Comp => besser.s ; Sup => best.s}} ;
+
+-- It can be done by just three strings, if each of the comparison
+-- forms taken separately is a regular adjective.
+
+ adjCompReg3 : (_,_,_ : Str) -> AdjComp = \gut,besser,best ->
+ mkAdjComp (adjReg gut) (adjReg besser) (adjReg best) ;
+
+-- If also the comparison forms are regular, one string is enough.
+
+ adjCompReg : Str -> AdjComp = \billig ->
+ adjCompReg3 billig (billig+"er") (billig+"st") ;
+
+
+--2 Verbs
+--
+-- We limit ourselves to verbs in present tense infinitive, indicative,
+-- and imperative, and past participle. Other forms will be introduced later.
+--
+-- The worst-case macro needs three forms: the infinitive, the third person
+-- singular indicative, and the second person singular imperative.
+-- We take care of the special cases "ten", "sen", "ln", "rn".
+--
+-- A famous law about Germanic languages says that plural first and third person
+-- are similar.
+
+ mkVerbum : (_,_,_,_ : Str) -> Verbum = \geben, gib, gb, gegeben ->
+ let {
+ en = Predef.dp 2 geben ;
+ geb = ifTok Tok (Predef.tk 1 en) "e" (Predef.tk 2 geben)(Predef.tk 1 geben) ;
+ gebt = ifTok Tok (Predef.dp 1 geb) "t" (geb + "et") (geb + "t") ;
+ gibst = ifTok Tok (Predef.dp 1 gib) "s" (gib + "t") (gib + "st") ;
+ gegebener = (adjReg gegeben).s
+ } in table {
+ VInf => geben ;
+ VInd Sg P1 => geb + "e" ;
+ VInd Sg P2 => gibst ;
+ VInd Sg P3 => gib + "t" ;
+ VInd Pl P2 => gebt ;
+ VInd Pl _ => geben ; -- the famous law
+ VImp Sg => gb ;
+ VImp Pl => gebt ;
+ VPart a => gegebener ! a
+ } ;
+
+-- Regular verbs:
+
+ regVerb : Str -> Verbum = \legen ->
+ let {lege = ifTok Tok (Predef.dp 3 legen) "ten" (Predef.tk 1 legen) (
+ ifTok Tok (Predef.dp 2 legen) "en" (Predef.tk 2 legen) (
+ Predef.tk 1 legen))} in
+ mkVerbum legen lege lege ("ge" + (lege + "t")) ;
+
+-- Verbs ending with "t"; now recognized in $mkVerbum$.
+
+ verbWarten : Str -> Verbum = regVerb ;
+
+-- Verbs with Umlaut in the second and third person singular and imperative:
+
+ verbSehen : Str -> Str -> Str -> Verbum = \sehen, sieht, gesehen ->
+ let {sieh = Predef.tk 1 sieht} in mkVerbum sehen sieh sieh gesehen ;
+
+-- Verbs with Umlaut in the second and third person singular but not imperative:
+
+ verbLaufen : Str -> Str -> Str -> Verbum = \laufen, läuft, gelaufen ->
+ let {läuf = Predef.tk 1 läuft ; laufe = Predef.tk 1 laufen}
+ in mkVerbum laufen läuf laufe gelaufen ;
+
+-- The verb "be":
+
+ verbumSein : Verbum = let {
+ gewesen = (adjReg "gewesen").s
+ } in
+ table {
+ VInf => "sein" ;
+ VInd Sg P1 => "bin" ;
+ VInd Sg P2 => "bist" ;
+ VInd Sg P3 => "ist" ;
+ VInd Pl P2 => "seid" ;
+ VInd Pl _ => "sind" ;
+ VImp Sg => "sei" ;
+ VImp Pl => "seiet" ;
+ VPart a => gewesen ! a
+ } ;
+
+-- The verb "have":
+
+ verbumHaben : Verbum = let {
+ haben = (regVerb "haben")
+ } in
+ table {
+ VInd Sg P2 => "hast" ;
+ VInd Sg P3 => "hat" ;
+ v => haben ! v
+ } ;
+
+-- The verb "become", used as the passive auxiliary:
+
+ verbumWerden : Verbum = let {
+ werden = regVerb "werden" ;
+ geworden = (adjReg "geworden").s
+ } in
+ table {
+ VInd Sg P2 => "wirst" ;
+ VInd Sg P3 => "wird" ;
+ VPart a => geworden ! a ;
+ v => werden ! v
+ } ;
+
+-- A *full verb* ($Verb$) consists of the inflection forms ($Verbum$) and
+-- a *particle* (e.g. "aus-sehen"). Simple verbs are the ones that have no
+-- such particle.
+
+ mkVerb : Verbum -> Particle -> Verb = \v,p -> {s = v ; s2 = p} ;
+
+ mkVerbSimple : Verbum -> Verb = \v -> mkVerb v [] ;
+
+ verbSein = mkVerbSimple verbumSein ;
+ verbHaben = mkVerbSimple verbumHaben ;
+ verbWerden = mkVerbSimple verbumWerden ;
+
+{-
+ -- tests for optimizer
+ verbumSein2 : Verbum =
+ table {
+ VInf => "sein" ;
+ VInd Sg P1 => "bin" ;
+ VInd Sg P2 => "bist" ;
+ VInd Sg P3 => "ist" ;
+ VInd Pl P2 => "seid" ;
+ VInd Pl _ => "sind" ;
+ VImp Sg => "sei" ;
+ VImp Pl => "seiet" ;
+ VPart a => (adjReg "gewesen").s ! a
+ } ;
+
+ verbumHaben2 : Verbum =
+ table {
+ VInd Sg P2 => "hast" ;
+ VInd Sg P3 => "hat" ;
+ v => regVerb "haben" ! v
+ } ;
+-}
+
+} ;
+
diff --git a/grammars/resource/german/Paradigms.gf b/grammars/resource/german/Paradigms.gf
new file mode 100644
index 000000000..d31e3fecd
--- /dev/null
+++ b/grammars/resource/german/Paradigms.gf
@@ -0,0 +1,300 @@
+--1 German Lexical Paradigms
+--
+-- Aarne Ranta 2003
+--
+-- This is an API to the user of the resource grammar
+-- for adding lexical items. It give shortcuts for forming
+-- expressions of basic categories: nouns, adjectives, verbs.
+--
+-- Closed categories (determiners, pronouns, conjunctions) are
+-- accessed through the resource syntax API, $resource.Abs.gf$.
+--
+-- The main difference with $morpho.Deu.gf$ is that the types
+-- referred to are compiled resource grammar types. We have moreover
+-- had the design principle of always having existing forms as string
+-- arguments of the paradigms, not stems.
+--
+-- The following modules are presupposed:
+
+resource Paradigms = open (Predef=Predef), Prelude, (Morpho=Morpho), Syntax, Deutsch in {
+
+
+--2 Parameters
+--
+-- To abstract over gender names, we define the following identifiers.
+
+oper
+ masculine : Gender ;
+ feminine : Gender ;
+ neuter : Gender ;
+
+-- To abstract over case names, we define the following.
+
+ nominative : Case ;
+ accusative : Case ;
+ dative : Case ;
+ genitive : Case ;
+
+-- To abstract over number names, we define the following.
+
+ singular : Number ;
+ plural : Number ;
+
+
+--2 Nouns
+
+-- Worst case: give all four singular forms, two plural forms (others + dative),
+-- and the gender.
+
+ mkN : (_,_,_,_,_,_ : Str) -> Gender -> N ;
+ -- mann, mann, manne, mannes, männer, männern
+
+-- Often it is enough with singular and plural nominatives, and singular
+-- genitive. The plural dative
+-- is computed by the heuristic that it is the same as the nominative this
+-- ends with "n" or "s", otherwise "n" is added.
+
+ nGen : Str -> Str -> Str -> Gender -> N ; -- punkt,punktes,punkt
+
+-- Here are some common patterns. Singular nominative or two nominatives are needed.
+-- Two forms are needed in case of Umlaut, which would be complicated to define.
+-- For the same reason, we have separate patterns for multisyllable stems.
+--
+-- The weak masculine pattern $nSoldat$ avoids duplicating the final "e".
+
+ nRaum : (_,_ : Str) -> N ; -- Raum, (Raumes,) Räume (masc)
+ nTisch : Str -> N ; -- Tisch, (Tisches, Tische) (masc)
+ nVater : (_,_ : Str) -> N ; -- Vater, (Vaters,) Väter (masc)
+ nFehler : Str -> N ; -- Fehler, (fehlers, Fehler) (masc)
+ nSoldat : Str -> N ; -- Soldat (, Soldaten) ; Kunde (, Kunden) (masc)
+
+-- Neuter patterns.
+
+ nBuch : (_,_ : Str) -> N ; -- Buch, (Buches, Bücher) (neut)
+ nMesser : Str -> N ; -- Messer, (Messers, Messer) (neut)
+ nAuto : Str -> N ; -- Auto, (Autos, Autos) (neut)
+
+-- Feminine patterns. Duplicated "e" is avoided in $nFrau$.
+
+ nHand : (_,_ : Str) -> N ; -- Hand, Hände; Mutter, Mütter (fem)
+ nFrau : Str -> N ; -- Frau (, Frauen) ; Wiese (, Wiesen) (fem)
+
+
+-- Nouns used as functions need a preposition. The most common is "von".
+
+ mkFun : N -> Preposition -> Case -> Fun ;
+ funVon : N -> Fun ;
+
+-- Proper names, with their possibly
+-- irregular genitive. The regular genitive is "s", omitted after "s".
+
+ mkPN : (karolus, karoli : Str) -> PN ; -- karolus, karoli
+ pnReg : (Johann : Str) -> PN ; -- Johann, Johanns ; Johannes, Johannes
+
+-- On the top level, it is maybe $CN$ that is used rather than $N$, and
+-- $NP$ rather than $PN$.
+
+ mkCN : N -> CN ;
+ mkNP : (karolus,karoli : Str) -> NP ;
+
+ npReg : Str -> NP ; -- Johann, Johanns
+
+-- In some cases, you may want to make a complex $CN$ into a function.
+
+ mkFunCN : CN -> Preposition -> Case -> Fun ;
+ funVonCN : CN -> Fun ;
+
+
+--2 Adjectives
+
+-- Non-comparison one-place adjectives need two forms in the worst case:
+-- the one in predication and the one before the ending "e".
+
+ mkAdj1 : (teuer,teur : Str) -> Adj1 ;
+
+-- Invariable adjective are a special case.
+
+ adjInvar : Str -> Adj1 ; -- prima
+
+-- The following heuristic recognizes the the end of the word, and builds
+-- the second form depending on if it is "e", "er", or something else.
+-- N.B. a contraction is made with "er", which works for "teuer" but not
+-- for "bitter".
+
+ adjGen : Str -> Adj1 ; -- gut; teuer; böse
+
+-- Two-place adjectives need a preposition and a case as extra arguments.
+
+ mkAdj2 : Adj1 -> Str -> Case -> Adj2 ; -- teilbar, durch, acc
+
+-- Comparison adjectives may need three adjective, corresponding to the
+-- three comparison forms.
+
+ mkAdjDeg : (gut,besser,best : Adj1) -> AdjDeg ;
+
+-- In many cases, each of these adjectives is itself regular. Then we only
+-- need three strings. Notice that contraction with "er" is not performed
+-- ("bessere", not "bessre").
+
+ aDeg3 : (gut,besser,best : Str) -> AdjDeg ;
+
+-- In the completely regular case, the comparison forms are constructed by
+-- the endings "er" and "st".
+
+ aReg : Str -> AdjDeg ; -- billig, billiger, billigst
+
+-- The past participle of a verb can be used as an adjective.
+
+ aPastPart : V -> Adj1 ; -- gefangen
+
+-- On top level, there are adjectival phrases. The most common case is
+-- just to use a one-place adjective. The variation in $adjGen$ is taken
+-- into account.
+
+ apReg : Str -> AP ;
+
+
+--2 Verbs
+--
+-- The fragment only has present tense so far, but in all persons.
+-- It also has the infinitive and the past participles.
+-- The worst case macro needs four forms: : the infinitive and
+-- the third person singular (where Umlaut may occur), the singular imperative,
+-- and the past participle.
+--
+-- The function recognizes if the stem ends with "s" or "t" and performs the
+-- appropriate contractions.
+
+ mkV : (_,_,_,_ : Str) -> V ; -- geben, gibt, gib, gegeben
+
+-- Regular verbs are those where no Umlaut occurs.
+
+ vReg : Str -> V ; -- kommen
+
+-- The verbs 'be' and 'have' are special.
+
+ vSein : V ;
+ vHaben : V ;
+
+-- Verbs with a detachable particle, with regular ones as a special case.
+
+ vPart : (_,_,_,_,_ : Str) -> V ; -- sehen, sieht, sieh, gesehen, aus
+ vPartReg : (_,_ : Str) -> V ; -- bringen, um
+
+-- Two-place verbs, and the special case with direct object. Notice that
+-- a particle can be included in a $V$.
+
+ mkTV : V -> Str -> Case -> TV ; -- hören, zu, dative
+
+ tvReg : Str -> Str -> Case -> TV ; -- hören, zu, dative
+ tvDir : V -> TV ; -- umbringen
+ tvDirReg : Str -> TV ; -- lieben
+
+--2 Adverbials
+--
+-- Adverbials for modifying verbs, adjectives, and sentences can be formed
+-- from strings.
+
+ mkAdV : Str -> AdV ;
+ mkAdA : Str -> AdA ;
+ mkAdS : Str -> AdS ;
+
+-- Prepositional phrases are another productive form of adverbials.
+
+ mkPP : Case -> Str -> NP -> AdV ;
+
+-- The definitions should not bother the user of the API. So they are
+-- hidden from the document.
+--.
+
+
+ masculine = Masc ;
+ feminine = Fem ;
+ neuter = Neut ;
+ nominative = Nom ;
+ accusative = Acc ;
+ dative = Dat ;
+ genitive = Gen ;
+ -- singular defined in Types
+ -- plural defined in Types
+
+ mkN = mkNoun ;
+
+ nGen = \punkt, punktes, punkte, g -> let {
+ e = Predef.dp 1 punkte ;
+ eqy = ifTok (Gender -> N) e ;
+ noN = mkNoun4 punkt punktes punkte punkte
+ } in
+ eqy "n" noN (
+ eqy "s" noN (
+ mkNoun4 punkt punktes punkte (punkte+"n"))) g ;
+
+ nRaum = \raum, räume -> nGen raum (raum + "es") räume masculine ;
+ nTisch = \tisch ->
+ mkNoun4 tisch (tisch + "es") (tisch + "e") (tisch +"en") masculine ;
+ nVater = \vater, väter -> nGen vater (vater + "s") väter masculine ;
+ nFehler = \fehler -> nVater fehler fehler ;
+
+ nSoldat = \soldat -> let {
+ e = Predef.dp 1 soldat ;
+ soldaten = ifTok Tok e "e" (soldat + "n") (soldat + "en")
+ } in
+ mkN soldat soldaten soldaten soldaten soldaten soldaten masculine ;
+
+ nBuch = \buch, bücher -> nGen buch (buch + "es") bücher neuter ;
+ nMesser = \messer -> nGen messer (messer + "s") messer neuter ;
+ nAuto = \auto -> let {autos = auto + "s"} in
+ mkNoun4 auto autos autos autos neuter ;
+
+ nHand = \hand, hände -> nGen hand hand hände feminine ;
+
+ nFrau = \frau -> let {
+ e = Predef.dp 1 frau ;
+ frauen = ifTok Tok e "e" (frau + "n") (frau + "en")
+ } in
+ mkN frau frau frau frau frauen frauen feminine ;
+
+ mkFun = \n -> mkFunCN (n2n n) ;
+ funVon = \n -> funVonCN (n2n n) ;
+
+ mkPN = \karolus, karoli -> {s = table {Gen => karoli ; _ => karolus}} ;
+ pnReg = \horst ->
+ mkPN horst (ifTok Tok (Predef.dp 1 horst) "s" horst (horst + "s")) ;
+
+ mkCN = UseN ;
+ mkNP = \x,y -> UsePN (mkPN x y) ;
+ npReg = \s -> UsePN (pnReg s) ;
+
+ mkFunCN = mkFunC ;
+ funVonCN = funVonC ;
+
+ mkAdj1 = mkAdjective ;
+ adjInvar = Morpho.adjInvar ;
+ adjGen = Morpho.adjGen ;
+ mkAdj2 = \a,p,c -> a ** {s2 = p ; c = c} ;
+
+ mkAdjDeg = mkAdjComp ;
+ aDeg3 = adjCompReg3 ;
+ aReg = adjCompReg ;
+ aPastPart = \v -> {s = table AForm {a => v.s ! VPart a}} ;
+ apReg = \s -> AdjP1 (adjGen s) ;
+
+ mkV = \sehen, sieht, sieh, gesehen ->
+ mkVerbSimple (mkVerbum sehen sieht sieh gesehen) ;
+ vReg = \s -> mkVerbSimple (regVerb s) ;
+ vSein = verbSein ;
+ vHaben = verbHaben ;
+ vPart = \sehen, sieht, sieh, gesehen, aus ->
+ mkVerb (mkVerbum sehen sieht sieh gesehen) aus ;
+ vPartReg = \sehen, aus -> mkVerb (regVerb sehen) aus ;
+
+ mkTV = mkTransVerb ;
+ tvReg = \hören, zu, dat -> mkTV (vReg hören) zu dat ;
+ tvDir = \v -> mkTV v [] accusative ;
+ tvDirReg = \v -> tvReg v [] accusative ;
+
+ mkAdV = ss ;
+ mkPP = prepPhrase ;
+ mkAdA = ss ;
+ mkAdS = ss ;
+} ;
diff --git a/grammars/resource/german/Predication.gf b/grammars/resource/german/Predication.gf
new file mode 100644
index 000000000..9c05cc69b
--- /dev/null
+++ b/grammars/resource/german/Predication.gf
@@ -0,0 +1,87 @@
+
+--1 A Small Predication Library
+--
+-- (c) Aarne Ranta 2003 under Gnu GPL.
+--
+-- This library is built on a language-independent API of
+-- resource grammars. It has a common part, the type signatures
+-- (defined here), and language-dependent parts. The user of
+-- the library should only have to look at the type signatures.
+
+resource Predication = open Deutsch in {
+
+-- We first define a set of predication patterns.
+
+oper
+ predV1 : V -> NP -> S ; -- one-place verb: "John walks"
+ predV2 : TV -> NP -> NP -> S ; -- two-place verb: "John loves Mary"
+ predVColl : V -> NP -> NP -> S ; -- collective verb: "John and Mary fight"
+ predA1 : Adj1 -> NP -> S ; -- one-place adjective: "John is old"
+ predA2 : Adj2 -> NP -> NP -> S ; -- two-place adj: "John is married to Mary"
+ predAComp : AdjDeg -> NP -> NP -> S ; -- compar adj: "John is older than Mary"
+ predAColl : Adj1 -> NP -> NP -> S ; -- collective adj: "John and Mary are married"
+ predN1 : N -> NP -> S ; -- one-place noun: "John is a man"
+ predN2 : Fun -> NP -> NP -> S ; -- two-place noun: "John is a lover of Mary"
+ predNColl : N -> NP -> NP -> S ; -- collective noun: "John and Mary are lovers"
+
+-- Individual-valued function applications.
+
+ appFun1 : Fun -> NP -> NP ; -- one-place function: "the successor of x"
+ appFun2 : Fun -> NP -> NP -> NP ; -- two-place function: "the line from x to y"
+ appFunColl : Fun -> NP -> NP -> NP ; -- collective function: "the sum of x and y"
+
+-- Families of types, expressed by common nouns depending on arguments.
+
+ appFam1 : Fun -> NP -> CN ; -- one-place family: "divisor of x"
+ appFam2 : Fun -> NP -> NP -> CN ; -- two-place family: "line from x to y"
+ appFamColl : Fun -> NP -> NP -> CN ; -- collective family: "path between x and y"
+
+-- Type constructor, similar to a family except that the argument is a type.
+
+ constrTyp1 : Fun -> CN -> CN ;
+
+-- Logical connectives on two sentences.
+
+ conjS : S -> S -> S ;
+ disjS : S -> S -> S ;
+ implS : S -> S -> S ;
+
+-- As an auxiliary, we need two-place conjunction of names ("John and Mary"),
+-- used in collective predication.
+
+ conjNP : NP -> NP -> NP ;
+
+
+-----------------------------
+
+---- what follows should be an implementation of the preceding
+
+oper
+ predV1 = \F, x -> PredVP x (PosV F) ;
+ predV2 = \F, x, y -> PredVP x (PosTV F y) ;
+ predVColl = \F, x, y -> PredVP (conjNP x y) (PosV F) ;
+ predA1 = \F, x -> PredVP x (PosA F) ;
+ predA2 = \F, x, y -> PredVP x (PosA (ComplAdj F y)) ;
+ predAComp = \F, x, y -> PredVP x (PosA (ComparAdjP F y)) ;
+ predAColl = \F, x, y -> PredVP (conjNP x y) (PosA F) ;
+ predN1 = \F, x -> PredVP x (PosCN (UseN F)) ;
+ predN2 = \F, x, y -> PredVP x (PosCN (AppFun F y)) ;
+ predNColl = \F, x, y -> PredVP (conjNP x y) (PosCN (UseN F)) ;
+
+ appFun1 = \f, x -> DefOneNP (AppFun f x) ;
+ appFun2 = \f, x, y -> DefOneNP (AppFun (AppFun2 f x) y) ;
+ appFunColl = \f, x, y -> DefOneNP (AppFun f (conjNP x y)) ;
+
+ appFam1 = \F, x -> AppFun F x ;
+ appFam2 = \F, x, y -> AppFun (AppFun2 F x) y ;
+ appFamColl = \F, x, y -> AppFun F (conjNP x y) ;
+
+ conjS = \A, B -> ConjS AndConj (TwoS A B) ;
+ disjS = \A, B -> ConjS OrConj (TwoS A B) ;
+ implS = \A, B -> SubjS IfSubj A B ;
+
+ constrTyp1 = \F, A -> AppFun F (IndefManyNP A) ;
+
+ conjNP = \x, y -> ConjNP AndConj (TwoNP x y) ;
+
+} ;
diff --git a/grammars/resource/german/ResDeu.gf b/grammars/resource/german/ResDeu.gf
new file mode 100644
index 000000000..dd2b160b3
--- /dev/null
+++ b/grammars/resource/german/ResDeu.gf
@@ -0,0 +1,217 @@
+--1 The Top-Level German Resource Grammar
+--
+-- Aarne Ranta 2002 -- 2003
+--
+-- This is the German concrete syntax of the multilingual resource
+-- grammar. Most of the work is done in the file $syntax.Deu.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 $Types.gf$.
+
+concrete ResDeu of ResAbs = open Prelude, Syntax in {
+
+flags
+ startcat=Phr ;
+ parser=chart ;
+
+lincat
+ CN = CommNounPhrase ;
+ -- = {s : Adjf => Number => Case => Str ; g : Gender} ;
+ N = CommNoun ;
+ -- = {s : Number => Case => Str ; g : Gender} ;
+ NP = NounPhrase ;
+ -- = {s : NPForm => Str ; n : Number ; p : Person ; pro : Bool} ;
+ PN = ProperName ;
+ -- = {s : Case => Str} ;
+ Det = {s : Gender => Case => Str ; n : Number ; a : Adjf} ;
+ Fun = Function ;
+ -- = CommNounPhrase ** {s2 : Preposition ; c : Case} ;
+ Fun2 = Function ** {s3 : Preposition ; c2 : Case} ;
+
+ Adj1 = Adjective ;
+ -- = {s : AForm => Str} ;
+ Adj2 = Adjective ** {s2 : Preposition ; c : Case} ;
+ AdjDeg = {s : Degree => AForm => Str} ;
+ AP = Adjective ** {p : Bool} ;
+
+ V = Verb ;
+ -- = {s : VForm => Str ; s2 : Particle} ;
+ VP = Verb ** {s3 : Number => Str} ;
+ TV = Verb ** {s3 : Preposition ; c : Case} ;
+ VS = Verb ;
+ AdV = {s : Str} ;
+
+ S = Sentence ;
+ -- = {s : Order => Str} ;
+ Slash = Sentence ** {s2 : Preposition ; c : Case} ;
+
+ RP = {s : GenNum => Case => Str} ;
+ RC = {s : GenNum => Str} ;
+
+ IP = ProperName ** {n : Number} ;
+ Qu = {s : QuestForm => Str} ;
+ Imp = {s : Number => Str} ;
+ Phr = {s : Str} ;
+ Text = {s : Str} ;
+
+ Conj = {s : Str ; n : Number} ;
+ ConjD = {s1,s2 : Str ; n : Number} ;
+
+ ListS = {s1,s2 : Order => Str} ;
+ ListAP = {s1,s2 : AForm => Str ; p : Bool} ;
+ ListNP = {s1,s2 : NPForm => Str ; n : Number ; p : Person ; pro : Bool} ;
+
+--.
+
+lin
+ UseN = noun2CommNounPhrase ;
+ ModAdj = modCommNounPhrase ;
+ ModGenOne = npGenDet singular ;
+ ModGenMany = npGenDet plural ;
+ UsePN = nameNounPhrase ;
+ UseFun = funAsCommNounPhrase ;
+ AppFun = appFunComm ;
+ AppFun2 = appFun2 ;
+ AdjP1 = adj2adjPhrase ;
+ ComplAdj = complAdj ;
+ PositAdjP = positAdjPhrase ;
+ ComparAdjP = comparAdjPhrase ;
+ SuperlNP = superlNounPhrase ;
+
+ DetNP = detNounPhrase ;
+ IndefOneNP = indefNounPhrase singular ;
+ IndefManyNP = indefNounPhrase plural ;
+ DefOneNP = defNounPhrase singular ;
+ DefManyNP = defNounPhrase plural ;
+
+ CNthatS = nounThatSentence ;
+
+ PredVP = predVerbPhrase ;
+ PosV = predVerb True ;
+ NegV = predVerb False ;
+ PosA = predAdjective True ;
+ NegA = predAdjective False ;
+ PosCN = predCommNoun True ;
+ NegCN = predCommNoun False ;
+ PosTV = complTransVerb True ;
+ NegTV = complTransVerb False ;
+ PosPassV = passVerb True ;
+ NegPassV = passVerb False ;
+ PosNP = predNounPhrase True ;
+ NegNP = predNounPhrase False ;
+ PosVS = complSentVerb True ;
+ NegVS = complSentVerb False ;
+
+ AdvVP = adVerbPhrase ;
+ LocNP = locativeNounPhrase ;
+ AdvCN = advCommNounPhrase ;
+ AdvAP = advAdjPhrase ;
+
+ PosSlashTV = slashTransVerb True ;
+ NegSlashTV = slashTransVerb False ;
+ OneVP = predVerbPhrase (nameNounPhrase {s = \\_ => "man"}) ;
+
+ 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 ;
+
+ ImperVP = imperVerbPhrase ;
+
+ IndicPhrase = indicUtt ;
+ QuestPhrase = interrogUtt ;
+ ImperOne = imperUtterance singular ;
+ ImperMany = imperUtterance plural ;
+
+ AdvS = advSentence ;
+
+lin
+ 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 ;
+
+ PhrNP = useNounPhrase ;
+ PhrOneCN = useCommonNounPhrase singular ;
+ PhrManyCN = useCommonNounPhrase plural ;
+ PhrIP ip = ip ;
+ PhrIAdv ia = ia ;
+
+ OnePhr p = p ;
+ ConsPhr = cc2 ;
+
+ INP = pronNounPhrase pronIch ;
+ ThouNP = pronNounPhrase pronDu ;
+ HeNP = pronNounPhrase pronEr ;
+ SheNP = pronNounPhrase pronSie ;
+ ItNP = pronNounPhrase pronEs ;
+ WeNP = pronNounPhrase pronWir ;
+ YeNP = pronNounPhrase pronIhr ;
+ TheyNP = pronNounPhrase pronSiePl ;
+
+ YouNP = pronNounPhrase pronSSie ;
+
+ EveryDet = jederDet ;
+ AllDet = alleDet ;
+ WhichDet = welcherDet ;
+ MostDet = meistDet ;
+
+ HowIAdv = ss "wie" ;
+ WhenIAdv = ss "wann" ;
+ WhereIAdv = ss "war" ;
+ WhyIAdv = ss "warum" ;
+
+ AndConj = ss "und" ** {n = Pl} ;
+ OrConj = ss "oder" ** {n = Sg} ;
+ BothAnd = sd2 "sowohl" ["als auch"] ** {n = Pl} ;
+ EitherOr = sd2 "entweder" "oder" ** {n = Sg} ;
+ NeitherNor = sd2 "weder" "noch" ** {n = Sg} ;
+ IfSubj = ss "wenn" ;
+ WhenSubj = ss "wenn" ;
+
+ PhrYes = ss ["Ja ."] ;
+ PhrNo = ss ["Nein ."] ;
+
+ VeryAdv = ss "sehr" ;
+ TooAdv = ss "zu" ;
+ OtherwiseAdv = ss "sonst" ;
+ ThereforeAdv = ss "deshalb" ;
+} ;
diff --git a/grammars/resource/german/RestaurantDeu.gf b/grammars/resource/german/RestaurantDeu.gf
new file mode 100644
index 000000000..3a6d6f8d6
--- /dev/null
+++ b/grammars/resource/german/RestaurantDeu.gf
@@ -0,0 +1,24 @@
+concrete RestaurantDeu of Restaurant =
+ DatabaseDeu ** open Prelude,Paradigms,Deutsch,DatabaseRes in {
+
+lin
+ Restaurant = UseN (nAuto "Restaurant") ;
+ Bar = UseN (nAuto "Bar") ; --- ??
+ French = apReg "Französisch" ;
+ Italian = apReg "Italienisch" ;
+ Indian = apReg "Indisch" ;
+ Japanese = apReg "Japanisch" ;
+
+ address = funVon (nFrau "Adresse") ;
+ phone = funVon (nFrau "Rufnummer") ; ----
+ priceLevel = funVon (nFrau "Preisstufe") ;
+
+ Cheap = aReg "billig" ;
+ Expensive = aDeg3 "teuer" "teurer" "teurest" ;
+
+ WhoRecommend rest = mkSentSame (ss2 ["wer empfiehlt"] (rest.s ! accusative)) ;
+ WhoHellRecommend rest =
+ mkSentSame (ss2 ["wer zum Teufel empfiehlt"] (rest.s ! accusative)) ;
+
+ LucasCarton = mkPN ["Lucas Carton"] ["Lucas Cartons"] ;
+} ;
diff --git a/grammars/resource/german/Syntax.gf b/grammars/resource/german/Syntax.gf
new file mode 100644
index 000000000..904cd1903
--- /dev/null
+++ b/grammars/resource/german/Syntax.gf
@@ -0,0 +1,891 @@
+--1 A Small German Resource Syntax
+--
+-- Aarne Ranta 2002
+--
+-- This resource grammar contains definitions needed to construct
+-- indicative, interrogative, and imperative sentences in German.
+--
+-- The following modules are presupposed:
+
+resource Syntax = Morpho ** open Prelude, (CO = Coordination) in {
+
+--2 Common Nouns
+--
+-- Simple common nouns are defined as the type $CommNoun$ in $morpho.Deu.gf$.
+
+--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.
+-- We use the $Adjf$ parameter for this ($Strong$/$Weak$).
+
+oper
+
+ CommNounPhrase : Type = {s : Adjf => Number => Case => Str ; g : Gender} ;
+
+ noun2CommNounPhrase : CommNoun -> CommNounPhrase = \haus ->
+ {s = \\_ => haus.s ; g = haus.g} ;
+
+ n2n = noun2CommNounPhrase ;
+
+
+
+--2 Noun phrases
+--
+-- The worst case is pronouns, which have inflection in the possessive
+-- forms. Other noun phrases express all possessive forms with the genitive case.
+-- The parameter $pro$ tells if the $NP$ is a pronoun, which is needed in e.g.
+-- genitive constructions.
+
+ NounPhrase : Type = {
+ s : NPForm => Str ;
+ n : Number ;
+ p : Person ;
+ pro : Bool
+ } ;
+
+ pronNounPhrase : ProPN -> NounPhrase = \ich ->
+ ich ** {pro = True} ;
+
+ caseNP : NPForm -> Case = \np -> case np of {
+ NPCase c => c ;
+ NPPoss _ _ => Gen
+ } ;
+
+ normalNounPhrase : (Case => Str) -> Number -> NounPhrase = \cs,n ->
+ {s = \\c => cs ! caseNP c ;
+ n = n ;
+ p = P3 ; -- third person
+ pro = False -- not a pronoun
+ } ;
+
+-- Proper names are a simple kind of noun phrases. They can usually
+-- be constructed from strings in a regular way.
+
+ ProperName : Type = {s : Case => Str} ;
+
+ nameNounPhrase : ProperName -> NounPhrase = \john ->
+ {s = \\np => john.s ! caseNP np ; n = Sg ; p = P3 ; pro = False} ;
+
+ mkProperName : Str -> ProperName = \horst ->
+ {s = table {Gen => horst + "s" ; _ => horst}} ;
+
+--2 Determiners
+--
+-- Determiners are inflected according to the nouns they determine.
+-- The determiner determines the number and adjectival form from the determiner.
+
+ Determiner : Type = {s : Gender => Case => Str ; n : Number ; a : Adjf} ;
+
+ detNounPhrase : Determiner -> CommNounPhrase -> NounPhrase = \ein, mann ->
+ {s = \\c => let {nc = caseNP c} in
+ ein.s ! mann.g ! nc ++ mann.s ! adjfCas ein.a nc ! ein.n ! nc ;
+ p = P3 ;
+ n = ein.n ;
+ pro = False
+ } ;
+
+-- The adjectival form after a determiner depends both on the inferent form
+-- and on the case ("ein alter Mann" but "einem alten Mann").
+
+ adjfCas : Adjf -> Case -> Adjf = \a,c -> case <a,c> of {
+ <Strong,Nom> => Strong ;
+ <Strong,Acc> => Strong ;
+ _ => Weak
+ } ;
+
+-- The following macros are sufficient to define most determiners,
+-- as shown by the examples that follow.
+
+ DetSg = Gender => Case => Str ;
+ DetPl = Case => Str ;
+
+ mkDeterminerSg : DetSg -> Adjf -> Determiner = \ein, a ->
+ {s = ein ; n = Sg ; a = a} ;
+
+ mkDeterminerPl : DetPl -> Adjf -> Determiner = \alle, a ->
+ {s = \\_ => alle ; n = Pl ; a = a} ;
+
+ detLikeAdj : Str -> Determiner = \jed -> mkDeterminerSg
+ (\\g,c => (adjReg jed).s ! AMod Strong (GSg g) c) Weak ;
+
+ jederDet = detLikeAdj "jed" ;
+ alleDet = mkDeterminerPl (caselist "alle" "alle" "allen" "aller") Weak ;
+ einDet = mkDeterminerSg artIndef Strong ;
+ derDet = mkDeterminerSg (table {g => artDef ! GSg g}) Weak ;
+ dieDet = mkDeterminerPl (artDef ! GPl) Weak ;
+
+ meistDet = mkDeterminerPl (table {c => artDef ! GPl ! c ++ "meisten"}) Weak ;
+ welcherDet = detLikeAdj "welch" ;
+ welcheDet = mkDeterminerPl (caselist "welche" "welche" "welchen" "welcher") Weak ;
+
+-- Choose "welcher"/"welche"
+
+ welchDet : Number -> Determiner = \n ->
+ case n of {Sg => welcherDet ; Pl => welcheDet} ;
+
+-- Genitives of noun phrases can be used like determiners, to build noun phrases.
+-- The number argument makes the difference between "mein Haus" - "meine Häuser".
+--
+-- If the 'owner' is a pronoun, only one form is available "mein Haus".
+-- In other cases, two variants are available: "Johanns Haus" / "das Haus Johanns".
+
+ npGenDet : Number -> NounPhrase -> CommNounPhrase -> NounPhrase = \n,haus,Wein ->
+ let {
+ hauses : Case => Str = \\c => haus.s ! NPPoss (gNumber Wein.g n) c ;
+ wein : NPForm => Str = \\c => Wein.s ! Strong ! n ! caseNP c ;
+ derwein : NPForm => Str = (defNounPhrase n Wein).s
+ }
+ in
+ {s = \\c => variants {
+ hauses ! caseNP c ++ wein ! c ;
+ if_then_else Str haus.pro
+ nonExist
+ (derwein ! c ++ hauses ! Nom) -- the case does not matter
+ } ;
+ p = P3 ;
+ n = n ;
+ pro = False
+ } ;
+
+-- *Bare plural noun phrases* like "Männer", "gute Häuser", are built without a
+-- determiner word.
+
+ plurDet : CommNounPhrase -> NounPhrase = \cn ->
+ normalNounPhrase (cn.s ! Strong ! Pl) Pl ;
+
+-- Macros for indef/def Sg/Pl noun phrases are needed in many places even
+-- if they might not be constituents.
+
+ indefNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n,haus -> case n of {
+ Sg => detNounPhrase einDet haus ;
+ Pl => plurDet haus
+ } ;
+
+ defNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n,haus -> case n of {
+ Sg => detNounPhrase derDet haus ;
+ Pl => detNounPhrase dieDet haus
+ } ;
+
+ indefNoun : Number -> CommNounPhrase -> Str = \n, mann -> case n of {
+ Sg => (detNounPhrase einDet mann).s ! NPCase Nom ;
+ Pl => (plurDet mann).s ! NPCase Nom
+ } ;
+
+-- Constructions like "die Idee, dass zwei gerade ist" are formed at the
+-- first place as common nouns, so that one can also have "ein Vorschlag, dass...".
+
+ nounThatSentence : CommNounPhrase -> Sentence -> CommNounPhrase = \idee,x ->
+ {s = \\a,n,c => idee.s ! a! n ! c ++ [", dass"] ++ x.s ! Sub ;
+ g = idee.g
+ } ;
+
+--2 Adjectives
+--
+-- Adjectival phrases have a parameter $p$ telling if postposition is
+-- allowed (complex APs).
+
+ AdjPhrase : Type = Adjective ** {p : Bool} ;
+
+ adj2adjPhrase : Adjective -> AdjPhrase = \ny -> ny ** {p = False} ;
+
+--3 Comparison adjectives
+--
+-- The type is defined in $types.Deu.gf$.
+
+ AdjDegr : Type = AdjComp ;
+
+-- Each of the comparison forms has a characteristic use:
+--
+-- Positive forms are used alone, as adjectival phrases ("jung").
+
+ positAdjPhrase : AdjDegr -> AdjPhrase = \jung ->
+ {s = jung.s ! Pos ; p = False} ;
+
+-- Comparative forms are used with an object of comparison, as
+-- adjectival phrases ("besser als Rolf").
+
+ comparAdjPhrase : AdjDegr -> NounPhrase -> AdjPhrase = \besser,rolf ->
+ {s = \\a => besser.s ! Comp ! a ++ "als" ++ rolf.s ! NPCase Nom ;
+ p = True
+ } ;
+
+-- Superlative forms are used with a common noun, picking out the
+-- maximal representative of a domain ("der Jüngste Mann").
+
+ superlNounPhrase : AdjDegr -> CommNounPhrase -> NounPhrase = \best,mann ->
+ let {gen = mann.g} in
+ {s = \\c => let {nc = caseNP c} in
+ artDef ! gNumber gen Sg ! nc ++
+ best.s ! Sup ! aMod Weak gen Sg nc ++
+ mann.s ! Weak ! Sg ! nc ;
+ p = P3 ;
+ n = Sg ;
+ pro = False
+ } ;
+
+--3 Two-place adjectives
+--
+-- A two-place adjective is an adjective with a preposition used before
+-- the complement, and the complement case.
+
+ AdjCompl = Adjective ** {s2 : Preposition ; c : Case} ;
+
+ complAdj : AdjCompl -> NounPhrase -> AdjPhrase = \verwandt,dich ->
+ {s = \\a =>
+ bothWays (verwandt.s ! a) (verwandt.s2 ++ dich.s ! NPCase verwandt.c) ;
+ p = True
+ } ;
+
+--3 Modification of common nouns
+--
+-- The two main functions of adjective are in predication ("Johann ist jung")
+-- and in modification ("ein junger Mann"). Predication will be defined
+-- later, in the chapter on verbs.
+--
+-- Modification must pay attention to pre- and post-noun
+-- adjectives: "gutes Haus"; "besseres als X haus" / "haus besseres als X"
+
+ modCommNounPhrase : AdjPhrase -> CommNounPhrase -> CommNounPhrase = \gut,haus ->
+ {s = \\a,n,c => let {
+ gutes = gut.s ! aMod a haus.g n c ;
+ Haus = haus.s ! a ! n ! c
+ } in
+ if_then_else Str gut.p (bothWays gutes Haus) (gutes ++ Haus) ;
+ g = haus.g} ;
+
+--2 Function expressions
+
+-- A function expression is a common noun together with the
+-- preposition prefixed to its argument ("Mutter von x").
+-- The type is analogous to two-place adjectives and transitive verbs.
+
+ Function = CommNounPhrase ** {s2 : Preposition ; c : Case} ;
+
+-- The application of a function gives, in the first place, a common noun:
+-- "Mutter/Mütter von Johann". From this, other rules of the resource grammar
+-- give noun phrases, such as "die Mutter von Johann", "die Mütter von Johann",
+-- "die Mütter von Johann und Maria", and "die Mutter von Johann und 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 = \mutter,uwe ->
+ {s = \\a,n,c => mutter.s ! a ! n ! c ++ mutter.s2 ++ uwe.s ! NPCase mutter.c ;
+ g = mutter.g
+ } ;
+
+-- It is possible to use a function word as a common noun; the semantics is
+-- often existential or indexical.
+
+ funAsCommNounPhrase : Function -> CommNounPhrase = \x -> x ;
+
+-- The following is an aggregate corresponding to the original function application
+-- producing "Johanns Mutter" and "die Mutter von Johann". It does not appear in the
+-- resource grammar API any longer.
+
+ appFun : Bool -> Function -> NounPhrase -> NounPhrase = \coll, mutter, uwe ->
+ let {n = uwe.n ; g = mutter.g ; nf = if_then_else Number coll Sg n} in
+ variants {
+ defNounPhrase nf (appFunComm mutter uwe) ;
+ npGenDet nf uwe mutter
+ } ;
+
+-- The commonest cases are functions with "von" and functions with Genitive.
+
+ mkFunC : CommNounPhrase -> Preposition -> Case -> Function = \f,p,c ->
+ f ** {s2 = p ; c = c} ;
+
+ funVonC : CommNounPhrase -> Function = \wert ->
+ mkFunC wert "von" Dat ;
+
+ funGenC : CommNounPhrase -> Function = \wert ->
+ mkFunC wert [] Gen ;
+
+-- Two-place functions add one argument place.
+
+ Function2 = Function ** {s3 : Preposition ; c2 : Case} ;
+
+-- There application starts by filling the first place.
+
+ appFun2 : Function2 -> NounPhrase -> Function = \flug, paris ->
+ {s = \\a,n,c => flug.s ! a ! n ! c ++ flug.s2 ++ paris.s ! NPCase flug.c ;
+ g = flug.g ;
+ s2 = flug.s3 ;
+ c = flug.c2
+ } ;
+
+
+--2 Verbs
+--
+--3 Verb phrases
+--
+-- Verb phrases are discontinuous: the parts of a verb phrase are
+-- (s) an inflected verb, (s2) particle, and
+-- (s3) negation and complement. This discontinuity is needed in sentence formation
+-- to account for word order variations.
+
+ VerbPhrase = Verb ** {s3 : Number => Str} ;
+
+-- 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 "nicht" are not grammatical.
+
+ predVerb : Bool -> Verb -> VerbPhrase = \b,aussehen ->
+ aussehen ** {
+ s3 = \\_ => negation b
+ } ;
+
+ negation : Bool -> Str = \b -> if_then_else Str b [] "nicht" ;
+
+-- Sometimes we want to extract the verb part of a verb phrase.
+
+ verbOfPhrase : VerbPhrase -> Verb = \v -> {s = v.s ; s2 = v.s2} ;
+
+-- Verb phrases can also be formed from adjectives ("ist gut"),
+-- common nouns ("ist ein Mann"), and noun phrases ("ist der jüngste Mann").
+-- The third rule is overgenerating: "ist jeder Mann" has to be ruled out
+-- on semantic grounds.
+
+ predAdjective : Bool -> Adjective -> VerbPhrase = \b,gut ->
+ verbSein ** {
+ s3 = \\_ => negation b ++ gut.s ! APred
+ } ;
+
+ predCommNoun : Bool -> CommNounPhrase -> VerbPhrase = \b,man ->
+ verbSein ** {
+ s3 = \\n => negation b ++ indefNoun n man
+ } ;
+
+ predNounPhrase : Bool -> NounPhrase -> VerbPhrase = \b,dermann ->
+ verbSein ** {
+ s3 = \\n => negation b ++ dermann.s ! NPCase Nom
+ } ;
+
+--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* - which may still be accusative,
+-- dative, or genitive.
+
+ TransVerb = Verb ** {s3 : Preposition ; c : Case} ;
+
+ mkTransVerb : Verb -> Preposition -> Case -> TransVerb =
+ \v,p,c -> v ** {s3 = p ; c = c} ;
+
+-- The rule for using transitive verbs is the complementization rule:
+
+ complTransVerb : Bool -> TransVerb -> NounPhrase -> VerbPhrase =
+ \b,warten,dich ->
+ let {
+ aufdich = warten.s3 ++ dich.s ! NPCase warten.c ;
+ nicht = negation b
+ } in
+ {s = warten.s ;
+ s2 = warten.s2 ;
+ s3 = \\_ => bothWays aufdich nicht
+ } ;
+
+-- 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 "es wird gelaufen", etc.
+
+ passVerb : Bool -> Verb -> VerbPhrase = \b,lieben ->
+ {s = verbumWerden ;
+ s2 = [] ;
+ s3 = \\_ => negation b ++ lieben.s ! VPart APred
+ } ;
+
+
+--2 Adverbials
+--
+-- Adverbials are not inflected (we ignore comparison, and treat
+-- compared adverbials as separate expressions; this could be done another way).
+
+ Adverb : Type = SS ;
+
+ mkAdverb : Str -> Adverb = ss ;
+
+ adVerbPhrase : VerbPhrase -> Adverb -> VerbPhrase = \spielt, gut ->
+ {s = spielt.s ;
+ s2 = spielt.s2 ;
+ s3 = \\n => spielt.s3 ! n ++ gut.s
+ } ;
+
+ advAdjPhrase : Adverb -> AdjPhrase -> AdjPhrase = \sehr, gut ->
+ {s = \\a => sehr.s ++ gut.s ! a ;
+ p = gut.p
+ } ;
+
+-- Adverbials are typically generated by prefixing prepositions.
+-- The rule for creating locative noun phrases by the preposition "in"
+-- is a little shaky, since other prepositions may be preferred ("an", "auf").
+
+ prepPhrase : Case -> Preposition -> NounPhrase -> Adverb = \c,auf,ihm ->
+ ss (auf ++ ihm.s ! NPCase c) ;
+
+ locativeNounPhrase : NounPhrase -> Adverb =
+ prepPhrase Dat "in" ;
+
+-- This is a source of the "Mann mit einem Teleskop" ambiguity, and may produce
+-- strange things, like "Autos immer" (while "Autos heute" is OK).
+-- Semantics will have to make finer distinctions among adverbials.
+
+ advCommNounPhrase : CommNounPhrase -> Adverb -> CommNounPhrase = \haus,heute ->
+ {s = \\a, n, c => haus.s ! a ! n ! c ++ heute.s ;
+ g = haus.g} ;
+
+
+
+--2 Sentences
+--
+-- Sentences depend on a *word order parameter* selecting between main clause,
+-- inverted, and subordinate clause.
+
+ 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 =
+ \Ich,LiebeDichNichtAus ->
+ let {
+ ich = Ich.s ! NPCase Nom ;
+ liebe = LiebeDichNichtAus.s ! VInd Ich.n Ich.p ;
+ aus = LiebeDichNichtAus.s2 ;
+ dichnichtgut = LiebeDichNichtAus.s3 ! Ich.n
+ } in
+ {s = table {
+ Main => ich ++ liebe ++ dichnichtgut ++ aus ;
+ Inv => liebe ++ ich ++ dichnichtgut ++ aus ;
+ Sub => ich ++ dichnichtgut ++ aus ++ liebe
+ }
+ } ;
+
+--3 Sentence-complement verbs
+--
+-- Sentence-complement verbs take sentences as complements.
+
+ SentenceVerb : Type = Verb ;
+
+ complSentVerb : Bool -> SentenceVerb -> Sentence -> VerbPhrase = \b,sage,duisst ->
+ sage **
+ {s3 = \\_ => negation b ++ "," ++ "dass" ++ duisst.s ! Sub} ;
+
+
+--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 ; c : Case} ;
+
+ slashTransVerb : Bool -> NounPhrase -> TransVerb -> SentenceSlashNounPhrase =
+ \b, Ich, sehen ->
+ let {
+ ich = Ich.s ! NPCase Nom ;
+ sehe = sehen.s ! VInd Ich.n P3 ;
+ aus = sehen.s2 ;
+ nicht = negation b
+ } in
+ {s = table {
+ Main => ich ++ sehe ++ nicht ++ aus ;
+ Inv => sehe ++ ich ++ nicht ++ aus ;
+ Sub => ich ++ nicht ++ aus ++ sehe
+ } ;
+ s2 = sehen.s3 ;
+ c = sehen.c
+ } ;
+
+--2 Relative pronouns and relative clauses
+--
+-- Relative pronouns are inflected in
+-- gender, number, and case just like adjectives.
+
+oper
+ identRelPron : RelPron = relPron ;
+
+ funRelPron : Function -> RelPron -> RelPron = \wert, der ->
+ {s = \\gn,c => let {nu = numGenNum gn} in
+ artDef ! gNumber wert.g nu ! c ++ wert.s ! Weak ! nu ! c ++
+ wert.s2 ++ der.s ! gn ! wert.c
+ } ;
+
+-- Relative clauses can be formed from both verb phrases ("der schläft") and
+-- slash expressions ("den ich sehe", "auf dem ich sitze").
+
+ RelClause : Type = {s : GenNum => Str} ;
+
+ relVerbPhrase : RelPron -> VerbPhrase -> RelClause = \der, geht ->
+ {s = \\gn => (predVerbPhrase (normalNounPhrase (der.s ! gn) (numGenNum gn))
+ geht
+ ).s ! Sub
+ } ;
+
+ relSlash : RelPron -> SentenceSlashNounPhrase -> RelClause = \den, ichSehe ->
+ {s = \\gn => ichSehe.s2 ++ den.s ! gn ! ichSehe.c ++ ichSehe.s ! Sub
+ } ;
+
+-- A 'degenerate' relative clause is the one often used in mathematics, e.g.
+-- "Zahl x derart, dass x gerade ist".
+
+ relSuch : Sentence -> RelClause = \A ->
+ {s = \\_ => "derart" ++ "dass" ++ 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. A comma is used before the relative clause.
+
+ modRelClause : CommNounPhrase -> RelClause -> CommNounPhrase = \mann,dergeht ->
+ {s = \\a,n,c => mann.s ! a ! n ! c ++ "," ++ dergeht.s ! gNumber mann.g n ;
+ g = mann.g
+ } ;
+
+
+--2 Interrogative pronouns
+--
+-- If relative pronouns are adjective-like, interrogative pronouns are
+-- noun-phrase-like. We use a simplified type, since we don't need the possessive
+-- forms.
+
+ IntPron : Type = ProperName ** {n : Number} ;
+
+-- In analogy with relative pronouns, we have a rule for applying a function
+-- to a relative pronoun to create a new one.
+
+ funIntPron : Function -> IntPron -> IntPron = \wert, wer ->
+ let {n = wer.n} in
+ {s = \\c =>
+ artDef ! gNumber wert.g n ! c ++ wert.s ! Weak ! n ! c ++
+ wert.s2 ++ wer.s ! wert.c ;
+ n = n
+ } ;
+
+-- There is a variety of simple interrogative pronouns:
+-- "welches Haus", "wer", "was".
+
+ nounIntPron : Number -> CommNounPhrase -> IntPron = \n,cn ->
+ let {np = detNounPhrase (welchDet n) cn} in
+ {s = \\c => np.s ! NPCase c ;
+ n = np.n} ;
+
+ intPronWho : Number -> IntPron = \num -> {
+ s = caselist "wer" "wen" "wem" "weren" ;
+ n = num
+ } ;
+
+ intPronWhat : Number -> IntPron = \num -> {
+ s = caselist "was" "was" nonExist nonExist ; ---
+ n = num
+ } ;
+
+
+
+--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 -> ss (x.s ! Main ++ ".") ;
+ interrogUtt : Question -> Utterance = \x -> ss (x.s ! DirQ ++ "?") ;
+
+
+--2 Questions
+--
+-- Questions are either direct ("bist du müde") or indirect
+-- ("ob du müde bist").
+
+param
+ QuestForm = DirQ | IndirQ ;
+
+oper
+ Question = SS1 QuestForm ;
+
+--3 Yes-no questions
+--
+-- Yes-no questions are used both independently ("bist du müde")
+-- and after interrogative adverbials ("warum bist du müde").
+-- It is economical to handle with these two cases by the one
+-- rule, $questVerbPhrase'$. The only difference is if "ob" appears
+-- in the indirect form.
+
+ questVerbPhrase : NounPhrase -> VerbPhrase -> Question =
+ questVerbPhrase' False ;
+
+ questVerbPhrase' : Bool -> NounPhrase -> VerbPhrase -> Question =
+ \adv, du,gehst ->
+ let {dugehst = (predVerbPhrase du gehst).s} in
+ {s = table {
+ DirQ => dugehst ! Inv ;
+ IndirQ => (if_then_else Str adv [] "ob") ++ dugehst ! 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 = \Wer,geht ->
+ let {wer : NounPhrase = normalNounPhrase Wer.s Wer.n ;
+ wergeht : Sentence = predVerbPhrase wer geht
+ } in
+ {s = table {
+ DirQ => wergeht.s ! Main ;
+ IndirQ => wergeht.s ! Sub
+ }
+ } ;
+
+ intSlash : IntPron -> SentenceSlashNounPhrase -> Question = \wer, ichSehe ->
+ let {zuwen = ichSehe.s2 ++ wer.s ! ichSehe.c} in
+ {s = table {
+ DirQ => zuwen ++ ichSehe.s ! Inv ;
+ IndirQ => zuwen ++ ichSehe.s ! Sub
+ }
+ } ;
+
+
+--3 Interrogative adverbials
+--
+-- These adverbials will be defined in the lexicon: they include
+-- "wann", "war", "wie", "warum", 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.
+
+ IntAdverb = SS ;
+
+ prepIntAdverb : Case -> Preposition -> IntPron -> IntAdverb =\ c,auf,wem ->
+ ss (auf ++ wem.s ! c) ;
+
+-- A question adverbial can be applied to anything, and whether this makes
+-- sense is a semantic question.
+
+ questAdverbial : IntAdverb -> NounPhrase -> VerbPhrase -> Question =
+ \wie, du, tust ->
+ {s = \\q => wie.s ++ (questVerbPhrase du tust).s ! q} ;
+
+
+--2 Imperatives
+--
+-- We only consider second-person imperatives. No polite "Sie" form so far.
+
+ Imperative = SS1 Number ;
+
+ imperVerbPhrase : VerbPhrase -> Imperative = \komm ->
+ {s = \\n => komm.s ! VImp n ++ komm.s3 ! n ++ komm.s2} ;
+
+ imperUtterance : Number -> Imperative -> Utterance = \n,I ->
+ ss (I.s ! n ++ "!") ;
+
+--2 Sentence adverbials
+--
+-- This class covers adverbials such as "sonst", "folgelich", which are prefixed
+-- to a sentence to form a phrase; the sentence gets inverted word order.
+
+ advSentence : Adverb -> Sentence -> Utterance = \sonst,ist1gerade ->
+ ss (sonst.s ++ ist1gerade.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 ("und", "oder") or distributed ("sowohl - als auch", "entweder - oder").
+--
+-- The conjunction has an inherent number, which is used when conjoining
+-- noun phrases: "John und Mary sind..." vs. "John oder Mary ist..."; in the
+-- case of "oder", 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. "du rauchst, er trinkt und ich esse".
+
+ conjunctSentence : Conjunction -> ListSentence -> Sentence =
+ CO.conjunctTable Order ;
+
+-- To coordinate a list of sentences by a distributed conjunction, we place
+-- the first part (e.g. "entweder") in front of the first element, the second
+-- part ("oder") 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 : AForm => Str ; p : Bool} ;
+
+ twoAdjPhrase : (_,_ : AdjPhrase) -> ListAdjPhrase = \x,y ->
+ CO.twoTable AForm x y ** {p = andB x.p y.p} ;
+ consAdjPhrase : ListAdjPhrase -> AdjPhrase -> ListAdjPhrase = \xs,x ->
+ CO.consTable AForm CO.comma xs x ** {p = andB xs.p x.p} ;
+
+ conjunctAdjPhrase : Conjunction -> ListAdjPhrase -> AdjPhrase = \c,xs ->
+ CO.conjunctTable AForm c xs ** {p = xs.p} ;
+
+ conjunctDistrAdjPhrase : ConjunctionDistr -> ListAdjPhrase -> AdjPhrase = \c,xs ->
+ CO.conjunctDistrTable AForm 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 result is a pronoun if all components are.
+
+ ListNounPhrase : Type =
+ {s1,s2 : NPForm => Str ; n : Number ; p : Person ; pro : Bool} ;
+
+ twoNounPhrase : (_,_ : NounPhrase) -> ListNounPhrase = \x,y ->
+ CO.twoTable NPForm x y **
+ {n = conjNumber x.n y.n ; p = conjPerson x.p y.p ; pro = andB x.pro y.pro} ;
+
+ consNounPhrase : ListNounPhrase -> NounPhrase -> ListNounPhrase = \xs,x ->
+ CO.consTable NPForm CO.comma xs x **
+ {n = conjNumber xs.n x.n ; p = conjPerson xs.p x.p ; pro = andB xs.pro x.pro} ;
+
+ conjunctNounPhrase : Conjunction -> ListNounPhrase -> NounPhrase = \c,xs ->
+ CO.conjunctTable NPForm c xs **
+ {n = conjNumber c.n xs.n ; p = xs.p ; pro = xs.pro} ;
+
+ conjunctDistrNounPhrase : ConjunctionDistr -> ListNounPhrase -> NounPhrase =
+ \c,xs ->
+ CO.conjunctDistrTable NPForm c xs **
+ {n = conjNumber c.n xs.n ; p = xs.p ; pro = xs.pro} ;
+
+-- We have to define a calculus of numbers of persons. For numbers,
+-- it is like the conjunction with $Pl$ corresponding to $False$.
+
+ conjNumber : Number -> Number -> Number = \m,n -> case <m,n> of {
+ <Sg,Sg> => Sg ;
+ _ => Pl
+ } ;
+
+-- For persons, we go in the descending order:
+-- "ich und dich sind stark", "er oder du bist stark".
+-- This is not always quite clear.
+
+ conjPerson : Person -> Person -> Person = \p,q -> case <p,q> of {
+ <P3,P3> => P3 ;
+ <P1,_> => P1 ;
+ <_,P1> => P1 ;
+ _ => P2
+ } ;
+
+
+--2 Subjunction
+--
+-- Subjunctions ("wenn", "falls", 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.
+
+ 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)} ;
+
+-- There are uniformly two variant word orders, e.g.
+-- "wenn du rauchst, werde ish böse"
+-- and "ich werde böse, wenn du rauchst".
+
+ subjunctVariants : Subjunction -> Sentence -> Str -> Str = \if,A,B ->
+ let {As = A.s ! Sub} in
+ variants {if.s ++ As ++ "," ++ B ; B ++ "," ++ if.s ++ As} ;
+
+
+--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 ! NPCase Nom) ;
+
+ defaultQuestion : Question -> SS = \whoareyou ->
+ ss (whoareyou.s ! DirQ) ;
+
+ defaultSentence : Sentence -> Utterance = \x -> ss (x.s ! Main) ;
+
+--3 Puzzle
+--
+-- Adding some lexicon, we can generate the sentence
+--
+-- "der grösste alte Mann ist nicht ein Auto auf die Mutter von dem Männer warten"
+--
+-- which looks completely ungrammatical! What you should do to decipher it is
+-- put parentheses around "auf die Mutter von dem".
+
+} ;
diff --git a/grammars/resource/german/TestDeu.gf b/grammars/resource/german/TestDeu.gf
new file mode 100644
index 000000000..e09b60d1f
--- /dev/null
+++ b/grammars/resource/german/TestDeu.gf
@@ -0,0 +1,39 @@
+concrete TestDeu of TestAbs = ResDeu ** open Syntax in {
+
+flags startcat=Phr ; lexer=text ; parser=chart ; unlexer=text ;
+
+-- a random sample from the lexicon
+
+lin
+ Big = adjCompReg3 "gross" "grösser" "grösst";
+ Small = adjCompReg "klein" ;
+ Old = adjCompReg3 "alt" "älter" "ältest";
+ Young = adjCompReg3 "jung" "jünger" "jüngst";
+ Man = declN2u "Mann" "Männer" ;
+ Woman = declN1 "Frau" ;
+ Car = declNs "Auto" ;
+ House = declN3uS "Haus" "Häuser" ;
+ Light = declN3 "Licht" ;
+ Walk = mkVerbSimple (verbLaufen "gehen" "geht" "gegangen") ;
+ Run = mkVerbSimple (verbLaufen "laufen" "läuft" "gelaufen") ;
+ Say = mkVerbSimple (regVerb "sagen") ;
+ Prove = mkVerbSimple (regVerb "beweisen") ;
+ Send = mkTransVerb (mkVerbSimple (verbLaufen "senden" "sendet" "gesandt")) [] Acc;
+ Love = mkTransVerb (mkVerbSimple (regVerb "lieben")) [] Acc ;
+ Wait = mkTransVerb (mkVerbSimple (verbWarten "warten")) "auf" Acc ;
+ Mother = mkFunC (n2n (declN2uF "Mutter" "Mütter")) "von" Dat ;
+ Uncle = mkFunC (n2n (declN2i "Onkel")) "von" Dat ;
+ Connection = mkFunC (n2n (declN1 "Verbindung")) "von" Dat **
+ {s3 = "nach" ; c2 = Dat} ;
+
+ Always = mkAdverb "immer" ;
+ Well = mkAdverb "gut" ;
+
+ SwitchOn = mkTransVerb (mkVerb (verbWarten "schalten") "auf") [] Acc ;
+ SwitchOff = mkTransVerb (mkVerb (verbWarten "schalten") "aus") [] Acc ;
+
+ John = mkProperName "Johann" ;
+ Mary = mkProperName "Maria" ;
+
+} ;
+
diff --git a/grammars/resource/german/Types.gf b/grammars/resource/german/Types.gf
new file mode 100644
index 000000000..d597223cd
--- /dev/null
+++ b/grammars/resource/german/Types.gf
@@ -0,0 +1,98 @@
+--1 German Word Classes and Morphological Parameters
+--
+-- This is a resource module for German morphology, defining the
+-- morphological parameters and word classes of German. It is so far only
+-- complete w.r.t. the syntax part of the resource grammar.
+-- It does not include those parameters that are not needed for
+-- analysing individual words: such parameters are defined in syntax modules.
+--
+
+resource Types = open Prelude in {
+
+--2 Enumerated parameter types
+--
+-- These types are the ones found in school grammars.
+-- Their parameter values are atomic.
+
+param
+ Number = Sg | Pl ;
+ Gender = Masc | Fem | Neut ;
+ Person = P1 | P2 | P3 ;
+ Case = Nom | Acc | Dat | Gen ;
+ Adjf = Strong | Weak ; -- the main division in adjective declension
+ Order = Main | Inv | Sub ; -- word order: direct, indirect, subordinate
+
+-- For abstraction and API compatibility, we define two synonyms:
+
+oper
+ singular = Sg ;
+ plural = Pl ;
+
+--2 Word classes and hierarchical parameter types
+--
+-- Real parameter types (i.e. ones on which words and phrases depend)
+-- are mostly hierarchical. The alternative is cross-products of
+-- simple parameters, but this cannot be always used since it overgenerates.
+--
+
+--3 Common nouns
+--
+-- Common nouns are inflected in number and case and they have an inherent gender.
+
+ CommNoun : Type = {s : Number => Case => Str ; g : Gender} ;
+
+--3 Pronouns
+--
+-- Pronouns are an example - the worst-case one of noun phrases,
+-- which are properly defined in $syntax.Deu.gf$.
+-- Their inflection tables has, in addition to the normal genitive,
+-- the possessive forms, which are inflected like determiners.
+
+param
+ NPForm = NPCase Case | NPPoss GenNum Case ;
+
+--3 Adjectives
+--
+-- Adjectives are a very complex class, and the full table has as many as
+-- 99 different forms. The major division is between the comparison degrees.
+-- There is no gender distinction in the plural,
+-- and the predicative forms ("X ist Adj") are not inflected.
+
+param
+ GenNum = GSg Gender | GPl ;
+ AForm = APred | AMod Adjf GenNum Case ;
+
+oper
+ Adjective : Type = {s : AForm => Str} ;
+ AdjComp : Type = {s : Degree => AForm => Str} ;
+
+-- Comparison of adjectives:
+
+param Degree = Pos | Comp | Sup ;
+
+--3 Verbs
+--
+-- We have a reduced conjugation with only the present tense infinitive,
+-- indicative, and imperative forms, and past participles.
+
+param VForm = VInf | VInd Number Person | VImp Number | VPart AForm ;
+
+oper Verbum : Type = VForm => Str ;
+
+-- On the general level, we have to account for composite verbs as well,
+-- such as "aus" + "sehen" etc.
+
+ Particle = Str ;
+
+ Verb = {s : Verbum ; s2 : Particle} ;
+
+
+--2 Prepositions
+--
+-- We define prepositions simply as strings. Thus we do not capture the
+-- contractions "vom", "ins", etc. To define them in GF grammar we would need
+-- to introduce a parameter system, which we postpone.
+
+ Preposition = Str ;
+
+} ;
diff --git a/grammars/resource/swedish/Morpho.gf b/grammars/resource/swedish/Morpho.gf
new file mode 100644
index 000000000..d7b2c66fa
--- /dev/null
+++ b/grammars/resource/swedish/Morpho.gf
@@ -0,0 +1,1039 @@
+--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 Morpho = Types ** 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.
+oper
+ verbVara = {s = table {Infinit => "vara" ; Indicat => "är" ; Imperat => "var"}} ;
+ verbHava = {s = table {Infinit => "ha" ; Indicat => "har" ; Imperat => "ha"}} ;
+
+-- 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 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 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"
+ }
+ } ;
+}
diff --git a/grammars/resource/swedish/ResSwe.gf b/grammars/resource/swedish/ResSwe.gf
new file mode 100644
index 000000000..747929d59
--- /dev/null
+++ b/grammars/resource/swedish/ResSwe.gf
@@ -0,0 +1,196 @@
+--1 The Top-Level Swedish Resource Grammar
+--
+-- Aarne Ranta 2002 -- 2003
+--
+-- This is the Swedish concrete syntax of the multilingual resource
+-- grammar. Most of the work is done in the file $syntax.Swe.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 $Types.gf$.
+
+concrete ResSwe of ResAbs = open Prelude, Syntax in {
+
+flags
+ startcat=Phr ;
+ parser=chart ;
+
+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} ;
+ Fun = CommNoun ** {s2 : Preposition} ;
+
+ Adj1 = Adjective ;
+ -- = {s : AdjFormPos => Case => Str} ;
+ Adj2 = Adjective ** {s2 : Preposition} ;
+ AdjDeg = {s : AdjForm => Str} ;
+ AP = Adjective ** {p : IsPostfixAdj} ;
+
+ V = Verb ;
+ -- = {s : VForm => Str} ;
+ VP = Verb ** {s2 : Str ; s3 : Gender => Number => Str} ;
+ TV = Verb ** {s2 : Preposition} ;
+ VS = Verb ;
+
+ AdV = {s : Str ; isPost : Bool} ;
+
+ S = Sentence ;
+ -- = {s : 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} ;
+
+--.
+
+lin
+ UseN = noun2CommNounPhrase ;
+ ModAdj = modCommNounPhrase ;
+ ModGenOne = npGenDet singular ;
+ ModGenMany = npGenDet plural ;
+ UsePN = nameNounPhrase ;
+ UseFun = funAsCommNounPhrase ;
+ AppFun = appFunComm ;
+ AdjP1 = adj2adjPhrase ;
+ ComplAdj = complAdj ;
+ PositAdjP = positAdjPhrase ;
+ ComparAdjP = comparAdjPhrase ;
+ SuperlNP = superlNounPhrase ;
+
+ DetNP = detNounPhrase ;
+ IndefOneNP = indefNounPhrase singular ;
+ IndefManyNP = indefNounPhrase plural ;
+ DefOneNP = defNounPhrase singular ;
+ DefManyNP = defNounPhrase plural ;
+
+ PredVP = predVerbPhrase ;
+ PosV = predVerb True ;
+ NegV = predVerb False ;
+ PosA = predAdjective True ;
+ NegA = predAdjective False ;
+ PosCN = predCommNoun True ;
+ NegCN = predCommNoun False ;
+ PosTV = complTransVerb True ;
+ NegTV = complTransVerb False ;
+ PosNP = predNounPhrase True ;
+ NegNP = predNounPhrase False ;
+ PosVS = complSentVerb True ;
+ NegVS = complSentVerb False ;
+
+
+ AdvVP = adVerbPhrase ;
+ LocNP = locativeNounPhrase ;
+ AdvCN = advCommNounPhrase ;
+
+ PosSlashTV = slashTransVerb True ;
+ NegSlashTV = slashTransVerb False ;
+
+ 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 ;
+
+ ImperVP = imperVerbPhrase ;
+
+ IndicPhrase = indicUtt ;
+ QuestPhrase = interrogUtt ;
+ ImperOne = imperUtterance singular ;
+ ImperMany = imperUtterance plural ;
+
+lin
+ 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 ;
+
+ PhrNP = useNounPhrase ;
+ PhrOneCN = useCommonNounPhrase singular ;
+ PhrManyCN = useCommonNounPhrase plural ;
+ PhrIP ip = ip ;
+ PhrIAdv ia = ia ;
+
+ INP = pronNounPhrase jag_32 ;
+ ThouNP = pronNounPhrase du_33 ;
+ HeNP = pronNounPhrase han_34 ;
+ SheNP = pronNounPhrase hon_35 ;
+ WeNP = pronNounPhrase vi_36 ;
+ YeNP = pronNounPhrase ni_37 ;
+ TheyNP = pronNounPhrase de_38 ;
+
+ YouNP = let {ni = pronNounPhrase ni_37 } in {s = ni.s ; g = ni.g ; n = Sg} ;
+
+ EveryDet = varjeDet ;
+ AllDet = allaDet ;
+ WhichDet = vilkenDet ;
+ MostDet = flestaDet ;
+
+ 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 ."] ;
+} ;
diff --git a/grammars/resource/swedish/Svenska.gf b/grammars/resource/swedish/Svenska.gf
new file mode 100644
index 000000000..b86c1bb1d
--- /dev/null
+++ b/grammars/resource/swedish/Svenska.gf
@@ -0,0 +1 @@
+resource Svenska = reuse ResSwe ;
diff --git a/grammars/resource/swedish/Syntax.gf b/grammars/resource/swedish/Syntax.gf
new file mode 100644
index 000000000..dab69b406
--- /dev/null
+++ b/grammars/resource/swedish/Syntax.gf
@@ -0,0 +1,1000 @@
+--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 Syntax = Morpho ** 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} ;
+
+ pronNounPhrase : ProPN -> NounPhrase = \jag ->
+ {s = jag.s ; g = jag.h1 ; n = jag.h2} ;
+
+--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 ->
+ {s = table {_ => table {_ => alla}} ; 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}}) ;
+
+-- 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 -> NounPhrase -> CommNounPhrase -> NounPhrase =
+ \n,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 ++
+ 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.
+
+ plurDet : CommNounPhrase -> NounPhrase = \cn ->
+ {s = \\c => 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 : CommNounPhrase -> NounPhrase = \cn ->
+ detNounPhrase (mkDeterminerPl (artDef ! cn.p ! APl) (DefP Def)) cn ;
+
+-- It is useful to have macros for indefinite and definite, singular and plural
+-- noun-phrase-like syncategorematic expressions.
+
+ indefNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n,hus -> case n of {
+ Sg => detNounPhrase enDet hus ;
+ Pl => plurDet hus
+ } ;
+
+ defNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n,hus -> case n of {
+ Sg => denDet hus ;
+ Pl => deDet 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
+ } ;
+
+--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 <b,n> of {
+ <Indef,Sg> => Strong (ASg g) ;
+ <Indef,Pl> => Strong APl ;
+ <Def, Sg> => Weak (AxSg x) ; ---- add masc!
+ <Def, Pl> => 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 x (noun2CommNounPhrase värde)
+ } ;
+
+
+
+--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
+--
+-- 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.
+
+ VerbPhrase : Type = Verb ** {s2 : Str ; s3 : Gender => Number => Str} ;
+
+-- 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 : Bool -> Verb -> VerbPhrase = \b,se ->
+ se ** {
+ s2 = negation b ;
+ s3 = \\_,_ => []
+ } ;
+
+ negation : Bool -> Str = \b -> if_then_else Str b [] "inte" ;
+
+-- Sometimes we want to extract the verb part of a verb phrase.
+
+ verbOfPhrase : VerbPhrase -> Verb = \v -> {s = v.s} ;
+
+-- 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.
+
+ predAdjective : Bool -> Adjective -> VerbPhrase = \b,arg ->
+ verbVara ** {
+ s2 = negation b ;
+ s3 = \\g,n => arg.s ! mkAdjForm Indef n g NoMasc ! Nom
+ } ;
+
+ predCommNoun : Bool -> CommNounPhrase -> VerbPhrase = \b,man ->
+ verbVara ** {
+ s2 = negation b ;
+ s3 = \\_,n => indefNoun n man
+ } ;
+
+ predNounPhrase : Bool -> NounPhrase -> VerbPhrase = \b,john ->
+ verbVara ** {
+ s2 = negation b ;
+ s3 = \\_,_ => john.s ! PNom
+ } ;
+
+--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 -> mkTransVerb (extVerb Act v) ;
+
+-- The rule for using transitive verbs is the complementization rule:
+
+ complTransVerb : Bool -> TransVerb -> NounPhrase -> VerbPhrase = \b,se,dig ->
+ {s = se.s ; s2 = negation b ; s3 = \\_,_ => se.s2 ++ dig.s ! PAcc} ;
+
+--2 Adverbials
+--
+-- Adverbials that modify verb phrases are either post- or pre-verbal.
+-- As a rule of thumb, simple adverbials ("bra","alltid") are pre-verbal,
+-- but this is not always the case ("här" is post-verbal).
+
+ Adverb : Type = SS ** {isPost : Bool} ;
+
+ 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 = \\g,n => spelar.s3 ! g ! n ++ (if_then_else Str postp bra.s [])
+ } ;
+
+-- 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 -> Adverb -> 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 ;
+ ser = serdiginte.s ! Indicat ;
+ dig = serdiginte.s3 ! 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
+ }
+ } ;
+
+-- This is a macro for simultaneous predication and complementation.
+
+ predTransVerb : Bool -> NounPhrase -> TransVerb -> NounPhrase -> Sentence =
+ \b,jag,ser,dig -> predVerbPhrase jag (complTransVerb b ser dig) ;
+
+--3 Sentence-complement verbs
+--
+-- Sentence-complement verbs take sentences as complements.
+
+ SentenceVerb : Type = Verb ;
+
+ complSentVerb : Bool -> SentenceVerb -> Sentence -> VerbPhrase = \b,se,duler ->
+ {s = se.s ; s2 = negation b ; s3 = \\_,_ => optStr "att" ++ duler.s ! Main} ;
+
+
+
+--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 ! Indicat ;
+ inte = negation b
+ } 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 ! Indicat ++
+ sover.s3 ! 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 ! Imperat ++ titta.s2 ++ titta.s3 ! Utr ! n} ;
+
+ imperUtterance : Number -> Imperative -> Utterance = \n,I ->
+ ss (I.s ! n ++ "!") ;
+
+
+--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 <m,n> of {
+ <Sg,Sg> => Sg ;
+ _ => Pl
+ } ;
+
+ conjGender : Gender -> Gender -> Gender = \m,n -> case <m,n> of {
+ <Utr,Utr> => 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} ;
+
+--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/grammars/resource/swedish/TestSwe.gf b/grammars/resource/swedish/TestSwe.gf
new file mode 100644
index 000000000..063119b56
--- /dev/null
+++ b/grammars/resource/swedish/TestSwe.gf
@@ -0,0 +1,35 @@
+concrete TestSwe of TestAbs = ResSwe ** open Syntax in {
+
+flags startcat=Phr ; lexer=text ; parser=chart ; unlexer=text ;
+
+-- a random sample from the lexicon
+
+lin
+ Big = stor_25 ;
+ Small = liten_1146 ;
+ Old = gammal_16 ;
+ Young = ung_29 ;
+ Man = extCommNoun Masc man_1144 ;
+ Woman = extCommNoun NoMasc (sApa "kvinn") ;
+ Car = extCommNoun NoMasc (sBil "bil") ;
+ House = extCommNoun NoMasc (sHus "hus") ;
+ Light = extCommNoun NoMasc (sHus "ljus") ;
+ Walk = extVerb Act gå_1174 ;
+ Run = extVerb Act (vFinna "spring" "sprang" "sprung") ;
+ Love = extTransVerb (vTala "älsk") [] ;
+ Send = extTransVerb (vTala "skick") [] ;
+ Wait = extTransVerb (vTala "vänt") "på" ;
+ Say = extVerb Act (vLeka "säg") ; --- works in present tense...
+ Prove = extVerb Act (vTala "bevis") ;
+ SwitchOn = extTransVerb (vVända "tän") [] ;
+ SwitchOff = extTransVerb (vLeka "släck") [] ;
+
+ Mother = mkFun (extCommNoun NoMasc mor_1) "till" ;
+ Uncle = mkFun (extCommNoun Masc farbror_8) "till" ;
+
+ Always = advPre "alltid" ;
+ Well = advPost "bra" ;
+
+ John = mkProperName "Johan" Utr Masc ;
+ Mary = mkProperName "Maria" Utr NoMasc ;
+} ;
diff --git a/grammars/resource/swedish/Types.gf b/grammars/resource/swedish/Types.gf
new file mode 100644
index 000000000..21ddfcfc7
--- /dev/null
+++ b/grammars/resource/swedish/Types.gf
@@ -0,0 +1,150 @@
+--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 Types = 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} ;
+
+--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.
+
+param
+ VForm = Infinit | Indicat | Imperat ;
+
+oper
+ Verb : Type = SS1 VForm ;
+
+ extVerb : Voice -> Verbum -> Verb = \v,verb -> {s = table {
+ Infinit => verb.s ! VI (Inf v) ;
+ Indicat => verb.s ! VF (Pres Ind v) ;
+ Imperat => verb.s ! VF Imper --- no passive in Verbum
+ }} ;
+
+--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} ;
+}