mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 11:42:49 -06:00
started regulus grammar implementation
This commit is contained in:
18
examples/regulus/Toy0.gf
Normal file
18
examples/regulus/Toy0.gf
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
abstract Toy0 = {
|
||||||
|
|
||||||
|
-- grammar from Chapter 2 of the Regulus book
|
||||||
|
|
||||||
|
flags startcat=MAIN ;
|
||||||
|
|
||||||
|
cat
|
||||||
|
MAIN ; NP ; Noun ; Spec ;
|
||||||
|
|
||||||
|
fun
|
||||||
|
Main : NP -> MAIN ;
|
||||||
|
SpecNoun : Spec -> Noun -> NP ;
|
||||||
|
|
||||||
|
One, Two : Spec ;
|
||||||
|
Felis, Canis : Noun ;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
28
examples/regulus/Toy0Eng.gf
Normal file
28
examples/regulus/Toy0Eng.gf
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
concrete Toy0Eng of Toy0 = {
|
||||||
|
|
||||||
|
param
|
||||||
|
Number = Sg | Pl ;
|
||||||
|
|
||||||
|
lincat
|
||||||
|
Spec = {s : Str ; n : Number} ;
|
||||||
|
Noun = {s : Number => Str} ;
|
||||||
|
MAIN,NP = {s : Str} ;
|
||||||
|
|
||||||
|
lin
|
||||||
|
Main np = np ;
|
||||||
|
SpecNoun spec noun = {s = spec.s ++ noun.s ! spec.n} ;
|
||||||
|
|
||||||
|
One = {s = "one" ; n = Sg} ;
|
||||||
|
Two = {s = "two" ; n = Pl} ;
|
||||||
|
|
||||||
|
Felis = regNoun "cat" ;
|
||||||
|
Canis = regNoun "dog" ;
|
||||||
|
|
||||||
|
oper
|
||||||
|
regNoun : Str -> {s : Number => Str} = \s -> {
|
||||||
|
s = table {
|
||||||
|
Sg => s ;
|
||||||
|
Pl => s + "s"
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
}
|
||||||
5
examples/regulus/Toy0Fin.gf
Normal file
5
examples/regulus/Toy0Fin.gf
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
--# -path=.:present:prelude
|
||||||
|
|
||||||
|
concrete Toy0Fin of Toy0 = Toy0I with
|
||||||
|
(Syntax = SyntaxFin),
|
||||||
|
(Lexicon = LexiconFin) ;
|
||||||
30
examples/regulus/Toy0Fre.gf
Normal file
30
examples/regulus/Toy0Fre.gf
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
concrete Toy0Fre of Toy0 = {
|
||||||
|
|
||||||
|
param
|
||||||
|
Number = Sg | Pl ;
|
||||||
|
Gender = Masc | Fem ;
|
||||||
|
|
||||||
|
lincat
|
||||||
|
Spec = {s : Gender => Str ; n : Number} ;
|
||||||
|
Noun = {s : Number => Str ; g : Gender} ;
|
||||||
|
MAIN,NP = {s : Str} ;
|
||||||
|
|
||||||
|
lin
|
||||||
|
Main np = np ;
|
||||||
|
SpecNoun spec noun = {s = spec.s ! noun.g ++ noun.s ! spec.n} ;
|
||||||
|
|
||||||
|
One = {s = table {Fem => "une" ; _ => "un"} ; n = Sg} ;
|
||||||
|
Two = {s = \\_ => "deux" ; n = Pl} ;
|
||||||
|
|
||||||
|
Felis = mkNoun "chat" Masc ;
|
||||||
|
Canis = mkNoun "chien" Masc ;
|
||||||
|
|
||||||
|
oper
|
||||||
|
mkNoun : Str -> Gender -> {s : Number => Str ; g : Gender} = \s,g -> {
|
||||||
|
s = table {
|
||||||
|
Sg => s ;
|
||||||
|
Pl => s + "s"
|
||||||
|
} ;
|
||||||
|
g = g
|
||||||
|
} ;
|
||||||
|
}
|
||||||
30
examples/regulus/Toy0Ger.gf
Normal file
30
examples/regulus/Toy0Ger.gf
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
concrete Toy0Ger of Toy0 = {
|
||||||
|
|
||||||
|
param
|
||||||
|
Number = Sg | Pl ;
|
||||||
|
Gender = Masc | Fem | Neutr ;
|
||||||
|
|
||||||
|
lincat
|
||||||
|
Spec = {s : Gender => Str ; n : Number} ;
|
||||||
|
Noun = {s : Number => Str ; g : Gender} ;
|
||||||
|
MAIN,NP = {s : Str} ;
|
||||||
|
|
||||||
|
lin
|
||||||
|
Main np = np ;
|
||||||
|
SpecNoun spec noun = {s = spec.s ! noun.g ++ noun.s ! spec.n} ;
|
||||||
|
|
||||||
|
One = {s = table {Fem => "eine" ; _ => "ein"} ; n = Sg} ;
|
||||||
|
Two = {s = \\_ => "zwei" ; n = Pl} ;
|
||||||
|
|
||||||
|
Felis = mkNoun "Katze" "Katzen" Fem ;
|
||||||
|
Canis = mkNoun "Hund" "Hünde" Masc ;
|
||||||
|
|
||||||
|
oper
|
||||||
|
mkNoun : Str -> Str -> Gender -> {s : Number => Str ; g : Gender} = \s,p,g -> {
|
||||||
|
s = table {
|
||||||
|
Sg => s ;
|
||||||
|
Pl => p
|
||||||
|
} ;
|
||||||
|
g = g
|
||||||
|
} ;
|
||||||
|
}
|
||||||
20
examples/regulus/Toy0I.gf
Normal file
20
examples/regulus/Toy0I.gf
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
incomplete concrete Toy0I of Toy0 = open Syntax, Lexicon in {
|
||||||
|
|
||||||
|
lincat
|
||||||
|
Spec = Det ;
|
||||||
|
Noun = N ;
|
||||||
|
NP = Syntax.NP ;
|
||||||
|
MAIN = Utt ;
|
||||||
|
|
||||||
|
lin
|
||||||
|
Main np = mkUtt np ;
|
||||||
|
SpecNoun spec noun = mkNP spec noun ;
|
||||||
|
|
||||||
|
One = mkDet one_Quant ;
|
||||||
|
Two = mkDet (mkNum n2_Numeral) ;
|
||||||
|
|
||||||
|
Felis = cat_N ;
|
||||||
|
Canis = dog_N ;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
5
examples/regulus/Toy0Swe.gf
Normal file
5
examples/regulus/Toy0Swe.gf
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
--# -path=.:present:prelude
|
||||||
|
|
||||||
|
concrete Toy0Swe of Toy0 = Toy0I with
|
||||||
|
(Syntax = SyntaxSwe),
|
||||||
|
(Lexicon = LexiconSwe) ;
|
||||||
39
examples/regulus/Toy0_eng.gf
Normal file
39
examples/regulus/Toy0_eng.gf
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
-- grammar from Chapter 2 of the Regulus book
|
||||||
|
|
||||||
|
flags startcat=MAIN ;
|
||||||
|
|
||||||
|
cat
|
||||||
|
MAIN ; NP ; Noun ; Spec ;
|
||||||
|
|
||||||
|
fun
|
||||||
|
Main : NP -> MAIN ;
|
||||||
|
SpecNoun : Spec -> Noun -> NP ;
|
||||||
|
|
||||||
|
One, Two : Spec ;
|
||||||
|
Felis, Canis : Noun ;
|
||||||
|
|
||||||
|
param
|
||||||
|
Number = Sg | Pl ;
|
||||||
|
|
||||||
|
lincat
|
||||||
|
Spec = {s : Str ; n : Number} ;
|
||||||
|
Noun = {s : Number => Str} ;
|
||||||
|
MAIN,NP = {s : Str} ;
|
||||||
|
|
||||||
|
lin
|
||||||
|
Main np = np ;
|
||||||
|
SpecNoun spec noun = {s = spec.s ++ noun.s ! spec.n} ;
|
||||||
|
|
||||||
|
One = {s = "one" ; n = Sg} ;
|
||||||
|
Two = {s = "two" ; n = Pl} ;
|
||||||
|
|
||||||
|
Felis = regNoun "cat" ;
|
||||||
|
Canis = regNoun "dog" ;
|
||||||
|
|
||||||
|
oper
|
||||||
|
regNoun : Str -> {s : Number => Str} = \s -> {
|
||||||
|
s = table {
|
||||||
|
Sg => s ;
|
||||||
|
Pl => s + "s"
|
||||||
|
}
|
||||||
|
} ;
|
||||||
Reference in New Issue
Block a user