mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
morpho in tutorial
This commit is contained in:
33
doc/tutorial/MorphoEng.gf
Normal file
33
doc/tutorial/MorphoEng.gf
Normal file
@@ -0,0 +1,33 @@
|
||||
--# -path=.:prelude
|
||||
|
||||
resource MorphoEng = open Prelude in {
|
||||
|
||||
param
|
||||
Number = Sg | Pl ;
|
||||
|
||||
oper
|
||||
Noun, Verb : Type = {s : Number => Str} ;
|
||||
|
||||
mkNoun : Str -> Str -> Noun = \x,y -> {
|
||||
s = table {
|
||||
Sg => x ;
|
||||
Pl => y
|
||||
}
|
||||
} ;
|
||||
|
||||
regNoun : Str -> Noun = \s -> case last s of {
|
||||
"s" | "z" => mkNoun s (s + "es") ;
|
||||
"y" => mkNoun s (init s + "ies") ;
|
||||
_ => mkNoun s (s + "s")
|
||||
} ;
|
||||
|
||||
mkVerb : Str -> Str -> Verb = \x,y -> mkNoun y x ;
|
||||
|
||||
regVerb : Str -> Verb = \s -> case last s of {
|
||||
"s" | "z" => mkVerb s (s + "es") ;
|
||||
"y" => mkVerb s (init s + "ies") ;
|
||||
"o" => mkVerb s (s + "es") ;
|
||||
_ => mkVerb s (s + "s")
|
||||
} ;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user