mirror of
https://github.com/GrammaticalFramework/comp-syntax-gu-mlt.git
synced 2026-02-08 22:41:05 -07:00
final state for lecture 5
This commit is contained in:
20
lectures/lecture-05/AgreementEng.gf
Normal file
20
lectures/lecture-05/AgreementEng.gf
Normal file
@@ -0,0 +1,20 @@
|
||||
concrete AgreementEng of Agreement = open MorphologyEng in {
|
||||
lincat
|
||||
NP = {s: Str; n: Number} ;
|
||||
CN = Noun ;
|
||||
N = Noun ;
|
||||
A = {s: Str} ;
|
||||
Det = {s: Str; n : Number} ;
|
||||
|
||||
lin
|
||||
DetCN d cn = {
|
||||
s = d.s ++ (cn.s ! d.n) ;
|
||||
n = d.n } ;
|
||||
AdjCN a cn = {s = \\n => a.s ++ (cn.s ! n) } ;
|
||||
UseN n = n ;
|
||||
|
||||
cat_N = regNoun "cat" ;
|
||||
black_A = {s = "black"} ;
|
||||
the_Sg = {s = "the"; n = Sg} ;
|
||||
the_Pl = {s = "the"; n = Pl} ;
|
||||
}
|
||||
29
lectures/lecture-05/AgreementSwe.gf
Normal file
29
lectures/lecture-05/AgreementSwe.gf
Normal file
@@ -0,0 +1,29 @@
|
||||
concrete AgreementSwe of Agreement = open MorphologySwe in {
|
||||
lincat
|
||||
NP = {s: Case => Str; a: NPAgreement} ;
|
||||
CN = Noun ;
|
||||
N = Noun ;
|
||||
A = Adjective ;
|
||||
Det = {s: Gender => Str; n : Number} ;
|
||||
|
||||
lin
|
||||
DetCN d cn = {
|
||||
s = \\c => (d.s ! cn.g) ++ (cn.s ! (NF d.n Def Nom)) ;
|
||||
a = NPAgr d.n cn.g Def
|
||||
} ;
|
||||
AdjCN a cn = {
|
||||
s = \\f =>
|
||||
let agr = NPAgr (nform2number f) cn.g (nform2definite f)
|
||||
in (a.s ! agr) ++ (cn.s ! f) ;
|
||||
g = cn.g } ;
|
||||
UseN n = n ;
|
||||
|
||||
cat_N = mk4Noun "katt" "katten" "katter" "katterna" ;
|
||||
black_A = mkAdjective "svart" "svart" "svarta" ;
|
||||
the_Sg = {
|
||||
s = table {Com => "den" ; Neut => "det"} ;
|
||||
n = Sg} ;
|
||||
the_Pl = {
|
||||
s = table {Com => "de" ; Neut => "de"} ;
|
||||
n = Pl} ;
|
||||
}
|
||||
@@ -7,11 +7,22 @@ param
|
||||
Number = Sg | Pl ;
|
||||
|
||||
NForm = NF Number Definite Case ; -- NF is a constructor
|
||||
NPAgreement = NPAgr Number Gender Definite ;
|
||||
|
||||
oper
|
||||
nform2number : NForm -> Number = \f -> case f of {
|
||||
(NF n _ _) => n
|
||||
} ;
|
||||
|
||||
nform2definite : NForm -> Definite = \f -> case f of {
|
||||
(NF _ d _) => d
|
||||
} ;
|
||||
|
||||
-- Noun = {s : Number => Definite => Case => Str ; g : Gender} ;
|
||||
Noun = {s : NForm => Str ; g : Gender} ;
|
||||
|
||||
Adjective = {s : NPAgreement => Str};
|
||||
|
||||
mkNoun : (sin, sig, sdn, sdg, pin, pig, pdn, pdg : Str) -> Gender -> Noun =
|
||||
\sin, sig, sdn, sdg, pin, pig, pdn, pdg, g -> {
|
||||
s = table {
|
||||
@@ -27,6 +38,20 @@ oper
|
||||
g = g
|
||||
} ;
|
||||
|
||||
mkAdjective : (stor, stort, stora : Str) -> Adjective =
|
||||
\stor, stort, stora -> {
|
||||
s = table {
|
||||
NPAgr Sg Com Ind => stor ;
|
||||
NPAgr Sg Com Def => stora ;
|
||||
NPAgr Sg Neut Ind => stort ;
|
||||
NPAgr Sg Neut Def => stora ;
|
||||
NPAgr Pl Com Ind => stora ;
|
||||
NPAgr Pl Com Def => stora ;
|
||||
NPAgr Pl Neut Ind => stora ;
|
||||
NPAgr Pl Neut Def => stora
|
||||
}
|
||||
} ;
|
||||
|
||||
addS : Str -> Str = \s -> case s of {
|
||||
_ + ("s" | "x" | "z") => s ;
|
||||
_ => s + "s"
|
||||
|
||||
Reference in New Issue
Block a user