initial state for lecture 05

This commit is contained in:
Arianna Masciolini
2025-04-13 18:34:38 +02:00
parent 5cdba875ef
commit df36af3ed8
4 changed files with 130 additions and 0 deletions

View 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" ;
}