mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-11 22:09:32 -06:00
new tutorial example
This commit is contained in:
14
doc/tutorial/Food.gf
Normal file
14
doc/tutorial/Food.gf
Normal file
@@ -0,0 +1,14 @@
|
||||
abstract Food = {
|
||||
|
||||
cat
|
||||
S ; Item ; Kind ; Quality ;
|
||||
|
||||
fun
|
||||
Is : Item -> Quality -> S ;
|
||||
This, That : Kind -> Item ;
|
||||
QKind : Quality -> Kind -> Kind ;
|
||||
Wine, Cheese, Fish : Kind ;
|
||||
Very : Quality -> Quality ;
|
||||
Fresh, Warm, Italian, Expensive, Delicious, Boring : Quality ;
|
||||
|
||||
}
|
||||
23
doc/tutorial/Food2Eng.gf
Normal file
23
doc/tutorial/Food2Eng.gf
Normal file
@@ -0,0 +1,23 @@
|
||||
concrete Food2Eng of Food = open StringOper in {
|
||||
|
||||
lincat
|
||||
S, Item, Kind, Quality = SS ;
|
||||
|
||||
lin
|
||||
Is item quality = cc item (prefix "is" quality) ;
|
||||
This = prefix "this" ;
|
||||
That = prefix "that" ;
|
||||
QKind = cc ;
|
||||
Wine = ss "wine" ;
|
||||
Cheese = ss "cheese" ;
|
||||
Fish = ss "fish" ;
|
||||
Very = prefix "very" ;
|
||||
Fresh = ss "fresh" ;
|
||||
Warm = ss "warm" ;
|
||||
Italian = ss "Italian" ;
|
||||
Expensive = ss "expensive" ;
|
||||
Delicious = ss "delicious" ;
|
||||
Boring = ss "boring" ;
|
||||
|
||||
}
|
||||
|
||||
23
doc/tutorial/FoodEng.gf
Normal file
23
doc/tutorial/FoodEng.gf
Normal file
@@ -0,0 +1,23 @@
|
||||
concrete FoodEng of Food = {
|
||||
|
||||
lincat
|
||||
S, Item, Kind, Quality = {s : Str} ;
|
||||
|
||||
lin
|
||||
Is item quality = {s = item.s ++ "is" ++ quality.s} ;
|
||||
This kind = {s = "this" ++ kind.s} ;
|
||||
That kind = {s = "that" ++ kind.s} ;
|
||||
QKind quality kind = {s = quality.s ++ kind.s} ;
|
||||
Wine = {s = "wine"} ;
|
||||
Cheese = {s = "cheese"} ;
|
||||
Fish = {s = "fish"} ;
|
||||
Very quality = {s = "very" ++ quality.s} ;
|
||||
Fresh = {s = "fresh"} ;
|
||||
Warm = {s = "warm"} ;
|
||||
Italian = {s = "Italian"} ;
|
||||
Expensive = {s = "expensive"} ;
|
||||
Delicious = {s = "delicious"} ;
|
||||
Boring = {s = "boring"} ;
|
||||
|
||||
}
|
||||
|
||||
22
doc/tutorial/FoodIta.gf
Normal file
22
doc/tutorial/FoodIta.gf
Normal file
@@ -0,0 +1,22 @@
|
||||
concrete FoodIta of Food = {
|
||||
|
||||
lincat
|
||||
S, Item, Kind, Quality = {s : Str} ;
|
||||
|
||||
lin
|
||||
Is item quality = {s = item.s ++ "è" ++ quality.s} ;
|
||||
This kind = {s = "questo" ++ kind.s} ;
|
||||
That kind = {s = "quello" ++ kind.s} ;
|
||||
QKind quality kind = {s = kind.s ++ quality.s} ;
|
||||
Wine = {s = "vino"} ;
|
||||
Cheese = {s = "formaggio"} ;
|
||||
Fish = {s = "pesce"} ;
|
||||
Very quality = {s = "molto" ++ quality.s} ;
|
||||
Fresh = {s = "fresco"} ;
|
||||
Warm = {s = "caldo"} ;
|
||||
Italian = {s = "italiano"} ;
|
||||
Expensive = {s = "caro"} ;
|
||||
Delicious = {s = "delizioso"} ;
|
||||
Boring = {s = "noioso"} ;
|
||||
|
||||
}
|
||||
5
doc/tutorial/Foodmarket.gf
Normal file
5
doc/tutorial/Foodmarket.gf
Normal file
@@ -0,0 +1,5 @@
|
||||
abstract Foodmarket = Food, Fruit, Mushroom ** {
|
||||
fun
|
||||
FruitKind : Fruit -> Kind ;
|
||||
MushroomKind : Mushroom -> Kind ;
|
||||
}
|
||||
5
doc/tutorial/FoodmarketEng.gf
Normal file
5
doc/tutorial/FoodmarketEng.gf
Normal file
@@ -0,0 +1,5 @@
|
||||
concrete FoodmarketEng of Foodmarket = FoodEng, FruitEng, MushroomEng ** {
|
||||
lin
|
||||
FruitKind x = x ;
|
||||
MushroomKind x = x ;
|
||||
}
|
||||
14
doc/tutorial/Foods.gf
Normal file
14
doc/tutorial/Foods.gf
Normal file
@@ -0,0 +1,14 @@
|
||||
abstract Foods = {
|
||||
|
||||
cat
|
||||
S ; Item ; Kind ; Quality ;
|
||||
|
||||
fun
|
||||
Is : Item -> Quality -> S ;
|
||||
This, That, All, Most : Kind -> Item ;
|
||||
QKind : Quality -> Kind -> Kind ;
|
||||
Wine, Cheese, Fish : Kind ;
|
||||
Very : Quality -> Quality ;
|
||||
Fresh, Warm, Italian, Expensive, Delicious, Boring : Quality ;
|
||||
|
||||
}
|
||||
35
doc/tutorial/FoodsEng.gf
Normal file
35
doc/tutorial/FoodsEng.gf
Normal file
@@ -0,0 +1,35 @@
|
||||
--# -path=.:prelude
|
||||
|
||||
concrete FoodsEng of Foods = open Prelude, MorphoEng in {
|
||||
|
||||
lincat
|
||||
S, Quality = SS ;
|
||||
Kind = {s : Number => Str} ;
|
||||
Item = {s : Str ; n : Number} ;
|
||||
|
||||
lin
|
||||
Is item quality = ss (item.s ++ (mkVerb "are" "is").s ! item.n ++ quality.s) ;
|
||||
This = det Sg "this" ;
|
||||
That = det Sg "that" ;
|
||||
All = det Pl "all" ;
|
||||
Most = det Pl "most" ;
|
||||
QKind quality kind = {s = \\n => quality.s ++ kind.s ! n} ;
|
||||
Wine = regNoun "wine" ;
|
||||
Cheese = regNoun "cheese" ;
|
||||
Fish = mkNoun "fish" "fish" ;
|
||||
Very = prefixSS "very" ;
|
||||
Fresh = ss "fresh" ;
|
||||
Warm = ss "warm" ;
|
||||
Italian = ss "Italian" ;
|
||||
Expensive = ss "expensive" ;
|
||||
Delicious = ss "delicious" ;
|
||||
Boring = ss "boring" ;
|
||||
|
||||
oper
|
||||
det : Number -> Str -> Noun -> {s : Str ; n : Number} = \n,d,cn -> {
|
||||
s = d ++ cn.s ! n ;
|
||||
n = n
|
||||
} ;
|
||||
|
||||
}
|
||||
|
||||
4
doc/tutorial/Fruit.gf
Normal file
4
doc/tutorial/Fruit.gf
Normal file
@@ -0,0 +1,4 @@
|
||||
abstract Fruit = {
|
||||
cat Fruit ;
|
||||
fun Apple, Peach : Fruit ;
|
||||
}
|
||||
5
doc/tutorial/FruitEng.gf
Normal file
5
doc/tutorial/FruitEng.gf
Normal file
@@ -0,0 +1,5 @@
|
||||
concrete FruitEng of Fruit = {
|
||||
lin
|
||||
Apple = {s = "apple"} ;
|
||||
Peach = {s = "peach"} ;
|
||||
}
|
||||
8
doc/tutorial/Morefood.gf
Normal file
8
doc/tutorial/Morefood.gf
Normal file
@@ -0,0 +1,8 @@
|
||||
abstract Morefood = Food ** {
|
||||
cat
|
||||
Question ;
|
||||
fun
|
||||
QIs : Item -> Quality -> Question ;
|
||||
Pizza : Kind ;
|
||||
|
||||
}
|
||||
7
doc/tutorial/MorefoodEng.gf
Normal file
7
doc/tutorial/MorefoodEng.gf
Normal file
@@ -0,0 +1,7 @@
|
||||
concrete MorefoodEng of Morefood = FoodEng ** {
|
||||
lincat
|
||||
Question = {s : Str} ;
|
||||
lin
|
||||
QIs item quality = {s = "is" ++ item.s ++ quality.s} ;
|
||||
Pizza = {s = "pizza"} ;
|
||||
}
|
||||
4
doc/tutorial/Mushroom.gf
Normal file
4
doc/tutorial/Mushroom.gf
Normal file
@@ -0,0 +1,4 @@
|
||||
abstract Mushroom = {
|
||||
cat Mushroom ;
|
||||
fun Cep, Agaric : Mushroom ;
|
||||
}
|
||||
5
doc/tutorial/MushroomEng.gf
Normal file
5
doc/tutorial/MushroomEng.gf
Normal file
@@ -0,0 +1,5 @@
|
||||
concrete MushroomEng of Mushroom = {
|
||||
lin
|
||||
Cep = {s = "cep"} ;
|
||||
Agaric = {s = "agaric"} ;
|
||||
}
|
||||
10
doc/tutorial/StringOper.gf
Normal file
10
doc/tutorial/StringOper.gf
Normal file
@@ -0,0 +1,10 @@
|
||||
resource StringOper = {
|
||||
oper
|
||||
SS : Type = {s : Str} ;
|
||||
|
||||
ss : Str -> SS = \x -> {s = x} ;
|
||||
|
||||
cc : SS -> SS -> SS = \x,y -> ss (x.s ++ y.s) ;
|
||||
|
||||
prefix : Str -> SS -> SS = \p,x -> ss (p ++ x.s) ;
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 2.5 KiB |
6
doc/tutorial/food.cf
Normal file
6
doc/tutorial/food.cf
Normal file
@@ -0,0 +1,6 @@
|
||||
S ::= Item "is" Quality ;
|
||||
Item ::= "this" Kind | "that" Kind ;
|
||||
Kind ::= Quality Kind ;
|
||||
Kind ::= "wine" | "cheese" | "fish" ;
|
||||
Quality ::= "very" Quality ;
|
||||
Quality ::= "fresh" | "warm" | "Italian" | "expensive" | "delicious" | "boring" ;
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
23
doc/tutorial/old/paleolithic.cf
Normal file
23
doc/tutorial/old/paleolithic.cf
Normal file
@@ -0,0 +1,23 @@
|
||||
PredVP. S ::= NP VP ;
|
||||
UseV. VP ::= V ;
|
||||
ComplTV. VP ::= TV NP ;
|
||||
UseA. VP ::= "is" A ;
|
||||
This. NP ::= "this" CN ;
|
||||
That. NP ::= "that" CN ;
|
||||
Def. NP ::= "the" CN ;
|
||||
Indef. NP ::= "a" CN ;
|
||||
ModA. CN ::= A CN ;
|
||||
Boy. CN ::= "boy" ;
|
||||
Louse. CN ::= "louse" ;
|
||||
Snake. CN ::= "snake" ;
|
||||
Worm. CN ::= "worm" ;
|
||||
Green. A ::= "green" ;
|
||||
Rotten. A ::= "rotten" ;
|
||||
Thick. A ::= "thick" ;
|
||||
Warm. A ::= "warm" ;
|
||||
Laugh. V ::= "laughs" ;
|
||||
Sleep. V ::= "sleeps" ;
|
||||
Swim. V ::= "swims" ;
|
||||
Eat. TV ::= "eats" ;
|
||||
Kill. TV ::= "kills"
|
||||
Wash. TV ::= "washes" ;
|
||||
@@ -1,8 +0,0 @@
|
||||
S ::= NP VP ;
|
||||
VP ::= V | TV NP | "is" A ;
|
||||
NP ::= "this" CN | "that" CN | "the" CN | "a" CN ;
|
||||
CN ::= A CN ;
|
||||
CN ::= "boy" | "louse" | "snake" | "worm" ;
|
||||
A ::= "green" | "rotten" | "thick" | "warm" ;
|
||||
V ::= "laughs" | "sleeps" | "swims" ;
|
||||
TV ::= "eats" | "kills" | "washes" ;
|
||||
Reference in New Issue
Block a user