forked from GitHub/comp-syntax-gu-mlt
lecture 3 material and README
This commit is contained in:
@@ -1 +1,34 @@
|
||||
resource MorphologyEng = {}
|
||||
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" ;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
38
lectures/lecture-03/MorphologySwe.gf
Normal file
38
lectures/lecture-03/MorphologySwe.gf
Normal file
@@ -0,0 +1,38 @@
|
||||
resource MorphologySwe = {
|
||||
|
||||
param
|
||||
Case = Nom | Gen ;
|
||||
Definite = Ind | Def ;
|
||||
Gender = Com | Neut ;
|
||||
Number = Sg | Pl ;
|
||||
|
||||
NForm = NF Number Definite Case ; -- NF is a constructor
|
||||
|
||||
oper
|
||||
-- Noun = {s : Number => Definite => Case => Str ; g : Gender} ;
|
||||
Noun = {s : NForm => Str ; g : Gender} ;
|
||||
|
||||
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
|
||||
} ;
|
||||
|
||||
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
|
||||
} ;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user