mirror of
https://github.com/GrammaticalFramework/comp-syntax-gu-mlt.git
synced 2026-02-09 23:01:06 -07:00
divide between lab 1 and 2
This commit is contained in:
62
lab1/grammar/italian/MicroResIta.gf
Normal file
62
lab1/grammar/italian/MicroResIta.gf
Normal file
@@ -0,0 +1,62 @@
|
||||
resource MicroResIta = {
|
||||
|
||||
param
|
||||
-- define types of morphological parameters
|
||||
Number = Sg | Pl ;
|
||||
Gender = Masc | Fem ;
|
||||
|
||||
oper
|
||||
-- define types for parts of speech
|
||||
-- they are recourd types with tables and inherent features
|
||||
Noun : Type = {s : Number => Str ; g : Gender} ;
|
||||
Adjective : Type = {s : Gender => Number => Str} ;
|
||||
|
||||
-- here is an example that is type-correct as a Noun
|
||||
donna_N : Noun = {
|
||||
s = table {Sg => "donna" ; Pl => "donne"} ;
|
||||
g = Fem
|
||||
} ;
|
||||
|
||||
-- define constructor function for Noun
|
||||
mkNoun : Str -> Str -> Gender -> Noun = \sg, pl, g -> {
|
||||
s = table {Sg => sg ; Pl => pl} ;
|
||||
g = g
|
||||
} ;
|
||||
|
||||
-- define a noun using this constructor
|
||||
uomo_N : Noun = mkNoun "uomo" "uomini" Masc ;
|
||||
|
||||
-- define a smart paradigm
|
||||
smartNoun : Str -> Noun = \s -> case s of {
|
||||
x + "o" => mkNoun s (x + "i") Masc ;
|
||||
x + "a" => mkNoun s (x + "e") Fem ;
|
||||
x + "e" => mkNoun s (x + "i") Masc ;
|
||||
_ => mkNoun s s Masc
|
||||
} ;
|
||||
|
||||
-- the overloaded paradigm is what the lexicon will use
|
||||
mkN = overload {
|
||||
mkN : Str -> Noun = smartNoun ;
|
||||
mkN : Str -> Str -> Gender -> Noun = mkNoun ;
|
||||
mkN : Gender -> Noun -> Noun = \g, n -> n ** {g = g} ;
|
||||
} ;
|
||||
|
||||
-- adjectives:
|
||||
mkAdjective : (msg,fsg,mpl,fpl : Str) -> Adjective = \msg,fsg,mpl,fpl -> {
|
||||
s = table {
|
||||
Masc => table {Sg => msg ; Pl => mpl} ;
|
||||
Fem => table {Sg => fsg ; Pl => fpl}
|
||||
}
|
||||
} ;
|
||||
smartAdjective : Str -> Adjective = \s -> case s of {
|
||||
x + "o" => mkAdjective s (x + "a") (x + "i") (x + "e") ;
|
||||
x + "e" => mkAdjective s s (x + "i") (x + "i") ;
|
||||
_ => mkAdjective s s s s
|
||||
} ;
|
||||
|
||||
mkA = overload {
|
||||
mkA : Str -> Adjective = smartAdjective ;
|
||||
mkA : (msg,fsg,mpl,fpl : Str) -> Adjective = mkAdjective ;
|
||||
} ;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user