mirror of
https://github.com/GrammaticalFramework/comp-syntax-gu-mlt.git
synced 2026-05-06 00:02:51 -06:00
last year's lecture material moved to directory 2025
This commit is contained in:
21
lectures/2025/lecture-05/Agreement.gf
Normal file
21
lectures/2025/lecture-05/Agreement.gf
Normal file
@@ -0,0 +1,21 @@
|
||||
abstract Agreement = {
|
||||
cat
|
||||
NP ;
|
||||
CN ;
|
||||
N ;
|
||||
A ;
|
||||
Det ;
|
||||
|
||||
fun
|
||||
DetCN : Det -> CN -> NP ; -- this black cat
|
||||
AdjCN : A -> N -> CN ; -- black cat
|
||||
UseN : N -> CN ; -- cat
|
||||
|
||||
cat_N : N ;
|
||||
house_N : N ;
|
||||
black_A : A ;
|
||||
big_A : A ;
|
||||
-- simplification of pronouns just to make English interesting
|
||||
this_Det : Det ;
|
||||
these_Det : Det ;
|
||||
}
|
||||
32
lectures/2025/lecture-05/AgreementEng.gf
Normal file
32
lectures/2025/lecture-05/AgreementEng.gf
Normal file
@@ -0,0 +1,32 @@
|
||||
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" ;
|
||||
house_N = regNoun "house" ;
|
||||
black_A = {s = "black"} ;
|
||||
big_A = {s = "big"} ;
|
||||
this_Det = {
|
||||
s = "this";
|
||||
n = Sg ;
|
||||
} ;
|
||||
these_Det = {
|
||||
s = "these";
|
||||
n = Pl ;
|
||||
} ;
|
||||
|
||||
}
|
||||
42
lectures/2025/lecture-05/AgreementSwe.gf
Normal file
42
lectures/2025/lecture-05/AgreementSwe.gf
Normal file
@@ -0,0 +1,42 @@
|
||||
concrete AgreementSwe of Agreement = open MorphologySwe in {
|
||||
lincat
|
||||
NP = {s: Str; a: NPAgreement} ;
|
||||
CN = Noun ;
|
||||
N = Noun ;
|
||||
A = Adjective ;
|
||||
Det = {s : Gender => Str; n: Number; d: Definite} ; -- and possible Definiteness
|
||||
|
||||
lin
|
||||
DetCN d cn = {
|
||||
s = (d.s ! cn.g) ++ (cn.s ! (NF d.n d.d Nom)) ;
|
||||
a = NPAgr d.n d.d cn.g ;
|
||||
} ;
|
||||
AdjCN a n = {
|
||||
s = \\nf => let agr = NPAgr (nform2number nf) (nform2definite nf) n.g
|
||||
in (a.s ! agr) ++ (n.s ! nf) ;
|
||||
g = n.g
|
||||
} ;
|
||||
UseN n = n ;
|
||||
|
||||
cat_N = mk4Noun "katt" "katten" "katter" "katterna" ;
|
||||
house_N = mk4Noun "hus" "huset" "hus" "husen" ;
|
||||
black_A = mk3Adjective "svart" "svart" "svarta" ;
|
||||
big_A = mk3Adjective "stor" "stort" "stora" ;
|
||||
this_Det = {
|
||||
s = table {
|
||||
Com => "den här" ;
|
||||
Neut => "det här"
|
||||
} ;
|
||||
n = Sg ;
|
||||
d = Def ;
|
||||
} ;
|
||||
these_Det = {
|
||||
s = table {
|
||||
Com => "de här" ;
|
||||
Neut => "de här"
|
||||
};
|
||||
n = Pl ;
|
||||
d = Def ;
|
||||
} ;
|
||||
|
||||
}
|
||||
34
lectures/2025/lecture-05/MorphologyEng.gf
Normal file
34
lectures/2025/lecture-05/MorphologyEng.gf
Normal file
@@ -0,0 +1,34 @@
|
||||
resource MorphologyEng = {
|
||||
|
||||
param
|
||||
Number = Sg | Pl ;
|
||||
|
||||
oper
|
||||
Noun : Type = {s : Number => Str} ;
|
||||
|
||||
mkNoun : Str -> Str -> Noun = \sg, pl ->
|
||||
{s = table {Sg => sg ; Pl => pl}} ;
|
||||
|
||||
regNoun : Str -> Noun = \sg -> mkNoun sg (sg + "s") ;
|
||||
|
||||
smartNoun : Str -> Noun = \sg -> case sg of {
|
||||
_ + ("s" | "ch" | "sh") => mkNoun sg (sg + "es") ;
|
||||
_ + ("ay" | "ey" | "oy" | "uy") => regNoun sg ;
|
||||
x + "y" => mkNoun sg (x + "ies") ;
|
||||
_ => regNoun sg
|
||||
} ;
|
||||
|
||||
-- to test
|
||||
teacher_N : Noun = {s = table {Sg => "teacher" ; Pl => "teachers"}} ;
|
||||
|
||||
cat_N : Noun = mkNoun "cat" "cats" ;
|
||||
|
||||
dog_N : Noun = regNoun "dog" ;
|
||||
|
||||
bus_N : Noun = smartNoun "bus" ;
|
||||
baby_N : Noun = smartNoun "baby" ;
|
||||
fly_N : Noun = smartNoun "fly" ;
|
||||
|
||||
|
||||
}
|
||||
|
||||
85
lectures/2025/lecture-05/MorphologySwe.gf
Normal file
85
lectures/2025/lecture-05/MorphologySwe.gf
Normal file
@@ -0,0 +1,85 @@
|
||||
resource MorphologySwe = {
|
||||
|
||||
param
|
||||
Case = Nom | Gen ;
|
||||
Definite = Ind | Def ;
|
||||
Gender = Com | Neut ;
|
||||
Number = Sg | Pl ;
|
||||
|
||||
NForm = NF Number Definite Case ; -- NF is a constructor
|
||||
NPAgreement = NPAgr Number Definite Gender ;
|
||||
|
||||
oper
|
||||
nform2number : NForm -> Number = \nf -> case nf of {
|
||||
(NF n _ _) => n
|
||||
} ;
|
||||
|
||||
nform2definite : NForm -> Definite = \nf -> case nf 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 {
|
||||
NF Sg Ind Nom => sin ;
|
||||
NF Sg Ind Gen => sig ;
|
||||
NF Sg Def Nom => sdn ;
|
||||
NF Sg Def Gen => sdg ;
|
||||
NF Pl Ind Nom => pin ;
|
||||
NF Pl Ind Gen => pig ;
|
||||
NF Pl Def Nom => pdn ;
|
||||
NF Pl Def Gen => pdg
|
||||
} ;
|
||||
g = g
|
||||
} ;
|
||||
|
||||
addS : Str -> Str = \s -> case s of {
|
||||
_ + ("s" | "x" | "z") => s ;
|
||||
_ => s + "s"
|
||||
} ;
|
||||
|
||||
mk3Adjective : (stor, stort, stora : Str) -> Adjective = \stor, stort, stora -> {
|
||||
s = table {
|
||||
NPAgr Sg Ind Com => stor ;
|
||||
NPAgr Sg Ind Neut => stort ;
|
||||
NPAgr Sg Def Com => stora ;
|
||||
NPAgr Sg Def Neut => stora ;
|
||||
NPAgr Pl Ind Com => stora ;
|
||||
NPAgr Pl Ind Neut => stora ;
|
||||
NPAgr Pl Def Com => stora ;
|
||||
NPAgr Pl Def Neut => stora
|
||||
}
|
||||
} ;
|
||||
|
||||
mk4Noun : (sin, sdn, pin, pdn : Str) -> Noun =
|
||||
\sin, sdn, pin, pdn -> {
|
||||
s = table {
|
||||
NF Sg Ind Nom => sin ;
|
||||
NF Sg Ind Gen => addS sin ;
|
||||
NF Sg Def Nom => sdn ;
|
||||
NF Sg Def Gen => addS sdn ;
|
||||
NF Pl Ind Nom => pin ;
|
||||
NF Pl Ind Gen => addS pin ;
|
||||
NF Pl Def Nom => pdn ;
|
||||
NF Pl Def Gen => addS pdn
|
||||
} ;
|
||||
g = case sdn of {
|
||||
_ + "n" => Com ;
|
||||
_ => Neut
|
||||
}
|
||||
} ;
|
||||
|
||||
smartNoun : Str -> Noun = \mamma -> case mamma of {
|
||||
mamm + "a" => mkNoun mamma (mamma + "s") (mamma + "n") (mamma + "ns")
|
||||
(mamm + "or") (mamm + "ors") (mamm + "orna") (mamm + "ornas")
|
||||
Com ;
|
||||
bil => mkNoun bil (bil + "s") (bil + "en") (bil + "ens")
|
||||
(bil + "ar") (bil + "ars") (bil + "arna") (bil + "arnas") Com
|
||||
} ;
|
||||
|
||||
}
|
||||
33
lectures/2025/lecture-05/examples.md
Normal file
33
lectures/2025/lecture-05/examples.md
Normal file
@@ -0,0 +1,33 @@
|
||||
## Number agreement in NPs
|
||||
|
||||
| Singular | Plural |
|
||||
| --- | --- |
|
||||
| black cat | black cats |
|
||||
| musta kissa | __mustat__ kissat |
|
||||
| gatto nero | gatti __neri__ |
|
||||
| schwarze Katze | schwarze Katzen |
|
||||
| chat noir | chats __noirs__ |
|
||||
| μαύρη γάτα | __μαύρες__ γάτες |
|
||||
| czarny kot | __czarne__ koty |
|
||||
| gato negro | gatos __negros__ |
|
||||
| pisică neagră | pisici __negre__ |
|
||||
| svart katt | __svarta__ katter |
|
||||
| zwarte kat | zwarte katten |
|
||||
| gato preto | gatos __pretos__ |
|
||||
| черная кошка | __черные__ кошки |
|
||||
|
||||
- these black cats - de här svarta katterna
|
||||
- these black houses - de här svarta husen
|
||||
- these cats - de här katterna
|
||||
- these houses - de här husen
|
||||
- this black cat - den här svarta katten
|
||||
- this black house - det här svarta huset
|
||||
- this cat - den här katten
|
||||
- this house - det här huset
|
||||
|
||||
- big cat(s) - stor katt / stora katten / stora katter / stora katterna
|
||||
- black cat(s) - svart katt / svarta katten / svarta katter / svarta katterna
|
||||
- big house(s) - stort hus / stora huset / stora hus / stora husen
|
||||
- black house(s) - svart hus / svarta huset / svarta hus / svarta husen
|
||||
- cat - katt
|
||||
- house - hus
|
||||
Reference in New Issue
Block a user