mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-10-22 07:33:12 -06:00
new tutorial example
This commit is contained in:
1 parent
e4314a739d
commit
de6b09f650
34 files changed
+940
-668
No files matched your search
@@ -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 ;
|
||||
|
||||
}
|
||||
@@ -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" ;
|
||||
|
||||
}
|
||||
|
||||
@@ -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"} ;
|
||||
|
||||
}
|
||||
|
||||
@@ -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"} ;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
abstract Foodmarket = Food, Fruit, Mushroom ** {
|
||||
fun
|
||||
FruitKind : Fruit -> Kind ;
|
||||
MushroomKind : Mushroom -> Kind ;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
concrete FoodmarketEng of Foodmarket = FoodEng, FruitEng, MushroomEng ** {
|
||||
lin
|
||||
FruitKind x = x ;
|
||||
MushroomKind x = x ;
|
||||
}
|
||||
@@ -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 ;
|
||||
|
||||
}
|
||||
@@ -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
|
||||
} ;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
abstract Fruit = {
|
||||
cat Fruit ;
|
||||
fun Apple, Peach : Fruit ;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
concrete FruitEng of Fruit = {
|
||||
lin
|
||||
Apple = {s = "apple"} ;
|
||||
Peach = {s = "peach"} ;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
abstract Morefood = Food ** {
|
||||
cat
|
||||
Question ;
|
||||
fun
|
||||
QIs : Item -> Quality -> Question ;
|
||||
Pizza : Kind ;
|
||||
|
||||
}
|
||||
@@ -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"} ;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
abstract Mushroom = {
|
||||
cat Mushroom ;
|
||||
fun Cep, Agaric : Mushroom ;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
concrete MushroomEng of Mushroom = {
|
||||
lin
|
||||
Cep = {s = "cep"} ;
|
||||
Agaric = {s = "agaric"} ;
|
||||
}
|
||||
@@ -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 |
@@ -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" ;
|
||||
+367
-339
File diff suppressed because it is too large.
Load diff
+360
-321
File diff suppressed because it is too large.
Load diff
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -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" ;
|
||||
File renamed without changes.
@@ -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