mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-17 00:39:32 -06:00
started examples-3.0 with examples that are tested to work
This commit is contained in:
86
examples-3.0/tutorial/syntax/Grammar.gf
Normal file
86
examples-3.0/tutorial/syntax/Grammar.gf
Normal file
@@ -0,0 +1,86 @@
|
||||
abstract Grammar = {
|
||||
|
||||
flags startcat=Phr ;
|
||||
|
||||
cat
|
||||
Phr ; -- any complete sentence e.g. "Is this pizza good?"
|
||||
S ; -- declarative sentence e.g. "this pizza is good"
|
||||
QS ; -- question sentence e.g. "is this pizza good"
|
||||
Cl ; -- declarative clause e.g. "this pizza is good"
|
||||
QCl ; -- question clause e.g. "is this pizza good"
|
||||
NP ; -- noun phrase e.g. "this pizza"
|
||||
IP ; -- interrogative phrase e.g "which pizza"
|
||||
CN ; -- common noun phrase e.g. "very good pizza"
|
||||
Det ; -- determiner e.g. "this"
|
||||
IDet ; -- interrog. determiner e.g. "which"
|
||||
AP ; -- adjectival phrase e.g. "very good"
|
||||
Adv ; -- adverb e.g. "today"
|
||||
AdA ; -- adadjective e.g. "very"
|
||||
VP ; -- verb phrase e.g. "is good"
|
||||
N ; -- noun e.g. "pizza"
|
||||
A ; -- adjective e.g. "good"
|
||||
V ; -- intransitive verb e.g. "boil"
|
||||
V2 ; -- two-place verb e.g. "eat"
|
||||
Pol ; -- polarity (pos or neg)
|
||||
Conj ; -- conjunction e.g. "and"
|
||||
Subj ; -- conjunction e.g. "because"
|
||||
|
||||
fun
|
||||
PhrS : S -> Phr ;
|
||||
PhrQS : QS -> Phr ;
|
||||
|
||||
UseCl : Pol -> Cl -> S ;
|
||||
UseQCl : Pol -> QCl -> QS ;
|
||||
|
||||
QuestCl : Cl -> QCl ;
|
||||
|
||||
SubjS : Subj -> S -> Adv ;
|
||||
|
||||
PredVP : NP -> VP -> Cl ;
|
||||
|
||||
QuestVP : IP -> VP -> QCl ;
|
||||
QuestV2 : IP -> NP -> V2 -> QCl ;
|
||||
|
||||
ComplV2 : V2 -> NP -> VP ;
|
||||
ComplAP : AP -> VP ;
|
||||
|
||||
DetCN : Det -> CN -> NP ;
|
||||
|
||||
ModCN : AP -> CN -> CN ;
|
||||
AdVP : Adv -> VP -> VP ;
|
||||
AdAP : AdA -> AP -> AP ;
|
||||
|
||||
IDetCN : IDet -> CN -> IP ;
|
||||
|
||||
ConjS : Conj -> S -> S -> S ;
|
||||
ConjNP : Conj -> NP -> NP -> NP ;
|
||||
|
||||
-- lexical insertion
|
||||
|
||||
UseN : N -> CN ;
|
||||
UseA : A -> AP ;
|
||||
UseV : V -> VP ;
|
||||
|
||||
-- entries of the closed lexicon
|
||||
|
||||
this_Det : Det ;
|
||||
that_Det : Det ;
|
||||
these_Det : Det ;
|
||||
those_Det : Det ;
|
||||
every_Det : Det ;
|
||||
theSg_Det : Det ;
|
||||
thePl_Det : Det ;
|
||||
indef_Det : Det ;
|
||||
plur_Det : Det ;
|
||||
two_Det : Det ;
|
||||
which_IDet : IDet ;
|
||||
today_Adv : Adv ;
|
||||
very_AdA : AdA ;
|
||||
and_Conj : Conj ;
|
||||
because_Subj : Subj ;
|
||||
|
||||
-- polarities
|
||||
|
||||
PPos, PNeg : Pol ;
|
||||
|
||||
}
|
||||
151
examples-3.0/tutorial/syntax/GrammarEng.gf
Normal file
151
examples-3.0/tutorial/syntax/GrammarEng.gf
Normal file
@@ -0,0 +1,151 @@
|
||||
--# -path=.:prelude
|
||||
|
||||
concrete GrammarEng of Grammar = open Prelude, MorphoEng in {
|
||||
|
||||
lincat
|
||||
Phr = {s : Str} ;
|
||||
S = {s : Str} ;
|
||||
QS = {s : Str} ;
|
||||
Cl = {s : Order => Bool => Str} ;
|
||||
QCl = {s : Order => Bool => Str} ;
|
||||
NP = NounPhrase ;
|
||||
IP = NounPhrase ;
|
||||
CN = Noun ;
|
||||
Det = {s : Str ; n : Number} ;
|
||||
IDet = {s : Str ; n : Number} ;
|
||||
AP = {s : Str} ;
|
||||
Adv = {s : Str} ;
|
||||
AdA = {s : Str} ;
|
||||
VP = VerbPhrase ;
|
||||
N = Noun ;
|
||||
A = {s : Str} ;
|
||||
V = Verb ;
|
||||
V2 = Verb2 ;
|
||||
Conj = {s : Str} ;
|
||||
Subj = {s : Str} ;
|
||||
Pol = {s : Str ; p : Bool} ;
|
||||
|
||||
lin
|
||||
PhrS = postfixSS "." ;
|
||||
PhrQS = postfixSS "?" ;
|
||||
|
||||
UseCl pol cl = {s = pol.s ++ cl.s ! Dir ! pol.p} ;
|
||||
UseQCl pol qcl = {s = pol.s ++ qcl.s ! Inv ! pol.p} ;
|
||||
|
||||
QuestCl cl = cl ;
|
||||
|
||||
SubjS subj s = {s = subj.s ++ s.s} ;
|
||||
|
||||
PredVP = predVP ;
|
||||
|
||||
QuestVP ip vp = let cl = predVP ip vp in {s = \\_ => cl.s ! Dir};
|
||||
|
||||
QuestV2 ip np v2 = {
|
||||
s = \\ord,pol =>
|
||||
let
|
||||
vp : VerbPhrase = predVerb v2
|
||||
in
|
||||
bothWays (ip.s ++ (predVP np vp).s ! ord ! pol) v2.c
|
||||
} ;
|
||||
|
||||
ComplV2 v np = insertObject (v.c ++ np.s) (predVerb v) ;
|
||||
|
||||
ComplAP ap = {
|
||||
s = \\_,b,n => {
|
||||
fin = copula b n ;
|
||||
inf = ap.s
|
||||
}
|
||||
} ;
|
||||
|
||||
DetCN det cn = {s = det.s ++ cn.s ! det.n ; n = det.n} ;
|
||||
|
||||
ModCN ap cn = {s = \\n => ap.s ++ cn.s ! n} ;
|
||||
|
||||
AdVP adv = insertObject adv.s ;
|
||||
|
||||
AdAP ada ap = {s = ada.s ++ ap.s} ;
|
||||
|
||||
IDetCN det cn = {s = det.s ++ cn.s ! det.n ; n = det.n} ;
|
||||
|
||||
ConjS c a b = {s = a.s ++ c.s ++ b.s} ;
|
||||
ConjNP c a b = {s = a.s ++ c.s ++ b.s ; n = Pl} ;
|
||||
|
||||
UseN n = n ;
|
||||
UseA a = a ;
|
||||
UseV = predVerb ;
|
||||
|
||||
this_Det = {s = "this" ; n = Sg} ;
|
||||
that_Det = {s = "that" ; n = Sg} ;
|
||||
these_Det = {s = "these" ; n = Pl} ;
|
||||
those_Det = {s = "those" ; n = Pl} ;
|
||||
every_Det = {s = "every" ; n = Sg} ;
|
||||
theSg_Det = {s = "the" ; n = Sg} ;
|
||||
thePl_Det = {s = "the" ; n = Pl} ;
|
||||
indef_Det = {s = artIndef ; n = Sg} ;
|
||||
plur_Det = {s = [] ; n = Pl} ;
|
||||
two_Det = {s = "two" ; n = Pl} ;
|
||||
today_Adv = {s = "today"} ;
|
||||
very_AdA = {s = "very"} ;
|
||||
which_IDet = {s = "which" ; n = Sg} ;
|
||||
|
||||
and_Conj = {s = "and"} ;
|
||||
because_Subj = {s = "because"} ;
|
||||
|
||||
PPos = {s = [] ; p = True} ;
|
||||
PNeg = {s = [] ; p = False} ;
|
||||
|
||||
param
|
||||
Order = Dir | Inv ;
|
||||
|
||||
oper
|
||||
NounPhrase = {s : Str ; n : Number} ;
|
||||
VerbPhrase = {s : Order => Bool => Number => {fin,inf : Str}} ;
|
||||
|
||||
predVP : NounPhrase -> VerbPhrase -> {s : Order => Bool => Str} =
|
||||
\np,vp -> {
|
||||
s = \\q,p =>
|
||||
let vps = vp.s ! q ! p ! np.n
|
||||
in case q of {
|
||||
Dir => np.s ++ vps.fin ++ vps.inf ;
|
||||
Inv => vps.fin ++ np.s ++ vps.inf
|
||||
}
|
||||
} ;
|
||||
|
||||
copula : Bool -> Number -> Str = \b,n -> case n of {
|
||||
Sg => posneg b "is" ;
|
||||
Pl => posneg b "are"
|
||||
} ;
|
||||
|
||||
do : Bool -> Number -> Str = \b,n ->
|
||||
posneg b ((mkV "do").s ! n) ;
|
||||
|
||||
predVerb : Verb -> VerbPhrase = \verb -> {
|
||||
s = \\q,b,n =>
|
||||
let
|
||||
inf = verb.s ! Pl ;
|
||||
fin = verb.s ! n ;
|
||||
aux = do b n
|
||||
in
|
||||
case <q,b> of {
|
||||
<Dir,True> => {fin = [] ; inf = fin} ;
|
||||
_ => {fin = aux ; inf = inf}
|
||||
}
|
||||
} ;
|
||||
|
||||
insertObject : Str -> VerbPhrase -> VerbPhrase =
|
||||
\obj,vp -> {
|
||||
s = \\q,b,n => let vps = vp.s ! q ! b! n in {
|
||||
fin = vps.fin ;
|
||||
inf = vps.inf ++ obj
|
||||
}
|
||||
} ;
|
||||
|
||||
posneg : Bool -> Str -> Str = \b,do -> case b of {
|
||||
True => do ;
|
||||
False => do + "n't"
|
||||
} ;
|
||||
|
||||
artIndef : Str =
|
||||
pre {"a" ; "an" / strs {"a" ; "e" ; "i" ; "o"}} ;
|
||||
|
||||
}
|
||||
132
examples-3.0/tutorial/syntax/GrammarIta.gf
Normal file
132
examples-3.0/tutorial/syntax/GrammarIta.gf
Normal file
@@ -0,0 +1,132 @@
|
||||
--# -path=.:prelude
|
||||
|
||||
concrete GrammarIta of Grammar = open Prelude, MorphoIta in {
|
||||
|
||||
lincat
|
||||
Phr = {s : Str} ;
|
||||
S = {s : Str} ;
|
||||
QS = {s : Str} ;
|
||||
Cl = Clause ;
|
||||
QCl = Clause ;
|
||||
NP = NounPhrase ;
|
||||
IP = NounPhrase ;
|
||||
CN = Noun ;
|
||||
Det = {s : Gender => Str ; n : Number} ;
|
||||
IDet = {s : Gender => Str ; n : Number} ;
|
||||
AP = {s : Gender => Number => Str} ;
|
||||
AdA = {s : Str} ;
|
||||
VP = VerbPhrase ;
|
||||
N = Noun ;
|
||||
A = Adjective ;
|
||||
V = Verb ;
|
||||
V2 = Verb2 ;
|
||||
Conj = {s : Str} ;
|
||||
Subj = {s : Str} ;
|
||||
Pol = {s : Str ; p : Bool} ;
|
||||
|
||||
oper
|
||||
Clause : Type = {s : Bool => Str} ;
|
||||
NounPhrase : Type = {s : Str ; g : Gender ; n : Number} ;
|
||||
VerbPhrase : Type = {s : Bool => Gender => Number => Str} ;
|
||||
lin
|
||||
PhrS = postfixSS "." ;
|
||||
PhrQS = postfixSS "?" ;
|
||||
|
||||
UseCl pol cl = {s = pol.s ++ cl.s ! pol.p} ;
|
||||
UseQCl pol qcl = {s = pol.s ++ qcl.s ! pol.p} ;
|
||||
|
||||
QuestCl cl = cl ;
|
||||
|
||||
SubjS subj s = {s = subj.s ++ s.s} ;
|
||||
|
||||
PredVP = predVP ;
|
||||
|
||||
QuestVP = predVP ;
|
||||
|
||||
QuestV2 ip np v2 =
|
||||
{s = \\b => v2.c ++ ip.s ++ posneg b ++ v2.s ! np.n ++ np.s} ;
|
||||
|
||||
ComplV2 v2 np = {s = \\b,_,n => posneg b ++ v2.s ! n ++ v2.c ++ np.s} ;
|
||||
ComplAP ap = {s = \\b,g,n => posneg b ++ copula n ++ ap.s ! g ! n} ;
|
||||
|
||||
DetCN det cn = {s = det.s ! cn.g ++ cn.s ! det.n ; g = cn.g ; n = det.n} ;
|
||||
|
||||
ModCN ap cn = {s = \\n => cn.s ! n ++ ap.s ! cn.g ! n ; g = cn.g} ;
|
||||
|
||||
AdVP adv vp = {s = \\p,n,g => vp.s ! p ! n ! g ++ adv.s} ;
|
||||
AdAP ada ap = {s = \\n,g => ada.s ++ ap.s ! n ! g} ;
|
||||
|
||||
IDetCN det cn = {s = det.s ! cn.g ++ cn.s ! det.n ; g = cn.g ; n = det.n} ;
|
||||
|
||||
ConjS c a b = {s = a.s ++ c.s ++ b.s} ;
|
||||
ConjNP c a b = {s = a.s ++ c.s ++ b.s ; n = Pl ; g = conjGender a.g b.g} ;
|
||||
|
||||
UseN n = n ;
|
||||
UseA a = a ;
|
||||
UseV v = {s = \\b,_,n => posneg b ++ v.s ! n} ;
|
||||
|
||||
this_Det = mkDet Sg (regAdjective "questo") ;
|
||||
that_Det = mkDet Sg (regAdjective "quello") ;
|
||||
these_Det = mkDet Pl (regAdjective "questo") ;
|
||||
those_Det = mkDet Pl (regAdjective "quello") ;
|
||||
every_Det = {s = \\_ => "ogni" ; n = Sg} ;
|
||||
theSg_Det = {s = artDef Sg ; n = Sg} ;
|
||||
thePl_Det = {s = artDef Pl ; n = Pl} ;
|
||||
indef_Det = {s = artIndef ; n = Sg} ;
|
||||
plur_Det = {s = \\_ => [] ; n = Pl} ;
|
||||
two_Det = {s = \\_ => "due" ; n = Pl} ;
|
||||
today_Adv = {s = "oggi"} ;
|
||||
very_AdA = {s = "molto"} ;
|
||||
which_IDet = {s = \\_ => "quale" ; n = Sg} ;
|
||||
and_Conj = {s = "e"} ;
|
||||
because_Subj = {s = "perché"} ;
|
||||
|
||||
PPos = {s = [] ; p = True} ;
|
||||
PNeg = {s = [] ; p = False} ;
|
||||
|
||||
oper
|
||||
predVP : NounPhrase -> VerbPhrase -> Clause = \np,vp ->
|
||||
{s = \\b => np.s ++ vp.s ! b ! np.g ! np.n} ;
|
||||
|
||||
copula : Number -> Str = \n -> case n of {
|
||||
Sg => "è" ;
|
||||
Pl => "sono"
|
||||
} ;
|
||||
|
||||
posneg : Bool -> Str = \b -> case b of {
|
||||
True => [] ;
|
||||
False => "non"
|
||||
} ;
|
||||
|
||||
mkDet : Number -> Adjective -> Det = \n,adj -> {
|
||||
s = \\g => adj.s ! g ! n ;
|
||||
n = n ;
|
||||
lock_Det = <>
|
||||
} ;
|
||||
|
||||
artDef : Number -> Gender => Str = \n -> case n of {
|
||||
Sg => table {
|
||||
Masc => pre {"il" ; "lo" / sImpuro} ;
|
||||
Fem => "la"
|
||||
} ;
|
||||
Pl => table {
|
||||
Masc => pre {"i" ; "gli" / sImpuro ; "gli" / vowel} ;
|
||||
Fem => "le"
|
||||
}
|
||||
} ;
|
||||
|
||||
artIndef : Gender => Str = table {
|
||||
Masc => pre {"un" ; "uno" / sImpuro} ;
|
||||
Fem => pre {"una" ; "un'" / vowel}
|
||||
} ;
|
||||
|
||||
conjGender : Gender -> Gender -> Gender = \g,h -> case g of {
|
||||
Masc => Masc ;
|
||||
_ => h
|
||||
} ;
|
||||
|
||||
sImpuro : Strs = strs {"sb" ; "sp" ; "sy" ; "z"} ;
|
||||
vowel : Strs = strs {"a" ; "e" ; "i" ; "o" ; "u"} ;
|
||||
|
||||
|
||||
}
|
||||
69
examples-3.0/tutorial/syntax/MorphoEng.gf
Normal file
69
examples-3.0/tutorial/syntax/MorphoEng.gf
Normal file
@@ -0,0 +1,69 @@
|
||||
--# -path=.:prelude
|
||||
|
||||
resource MorphoEng = open Prelude in {
|
||||
|
||||
-- the lexicon construction API
|
||||
|
||||
oper
|
||||
mkN : overload {
|
||||
mkN : (bus : Str) -> Noun ;
|
||||
mkN : (man,men : Str) -> Noun ;
|
||||
} ;
|
||||
|
||||
mkA : (warm : Str) -> Adjective ;
|
||||
|
||||
mkV : overload {
|
||||
mkV : (kiss : Str) -> Verb ;
|
||||
mkV : (do,does : Str) -> Verb ;
|
||||
} ;
|
||||
|
||||
mkV2 : overload {
|
||||
mkV2 : (love : Verb) -> Verb2 ;
|
||||
mkV2 : (talk : Verb) -> (about : Str) -> Verb2 ;
|
||||
} ;
|
||||
|
||||
-- grammar-internal definitions
|
||||
|
||||
param
|
||||
Number = Sg | Pl ;
|
||||
|
||||
oper
|
||||
Noun, Verb : Type = {s : Number => Str} ;
|
||||
Adjective : Type = {s : Str} ;
|
||||
Verb2 : Type = Verb ** {c : Str} ;
|
||||
|
||||
mkN = overload {
|
||||
mkN : (bus : Str) -> Noun = \s -> mkNoun s (add_s s) ;
|
||||
mkN : (man,men : Str) -> Noun = mkNoun ;
|
||||
} ;
|
||||
|
||||
mkA : (warm : Str) -> Adjective = ss ;
|
||||
|
||||
mkV = overload {
|
||||
mkV : (kiss : Str) -> Verb = \s -> mkVerb s (add_s s) ;
|
||||
mkV : (do,does : Str) -> Verb = mkVerb ;
|
||||
} ;
|
||||
|
||||
mkV2 = overload {
|
||||
mkV2 : (love : Verb) -> Verb2 = \love -> love ** {c = []} ;
|
||||
mkV2 : (talk : Verb) -> (about : Str) -> Verb2 =
|
||||
\talk,about -> talk ** {c = about} ;
|
||||
} ;
|
||||
|
||||
add_s : Str -> Str = \w -> case w of {
|
||||
_ + "oo" => w + "s" ; -- bamboo
|
||||
_ + ("s" | "z" | "x" | "sh" | "o") => w + "es" ; -- bus, hero
|
||||
_ + ("a" | "o" | "u" | "e") + "y" => w + "s" ; -- boy
|
||||
x + "y" => x + "ies" ; -- fly
|
||||
_ => w + "s" -- car
|
||||
} ;
|
||||
|
||||
mkNoun : Str -> Str -> Noun = \x,y -> {
|
||||
s = table {
|
||||
Sg => x ;
|
||||
Pl => y
|
||||
}
|
||||
} ;
|
||||
|
||||
mkVerb : Str -> Str -> Verb = \x,y -> mkNoun y x ;
|
||||
}
|
||||
100
examples-3.0/tutorial/syntax/MorphoIta.gf
Normal file
100
examples-3.0/tutorial/syntax/MorphoIta.gf
Normal file
@@ -0,0 +1,100 @@
|
||||
--# -path=.:prelude
|
||||
|
||||
-- This is a simple Italian resource morphology for the GF tutorial.
|
||||
|
||||
resource MorphoIta = open Prelude in {
|
||||
|
||||
-- the lexicographer's API
|
||||
|
||||
oper
|
||||
masculine, feminine : Gender ;
|
||||
|
||||
|
||||
|
||||
param
|
||||
Number = Sg | Pl ;
|
||||
Gender = Masc | Fem ;
|
||||
|
||||
oper
|
||||
Noun : Type = {s : Number => Str ; g : Gender} ;
|
||||
Adjective : Type = {s : Gender => Number => Str} ;
|
||||
|
||||
-- we will only use present indicative third person verb forms
|
||||
|
||||
Verb : Type = {s : Number => Str} ;
|
||||
|
||||
-- two-place verbs have a preposition
|
||||
|
||||
Verb2 : Type = Verb ** {c : Str} ;
|
||||
|
||||
-- this function takes the gender and both singular and plural forms
|
||||
|
||||
mkNoun : Gender -> Str -> Str -> Noun = \g,vino,vini -> {
|
||||
s = table {
|
||||
Sg => vino ;
|
||||
Pl => vini
|
||||
} ;
|
||||
g = g
|
||||
} ;
|
||||
|
||||
-- this function takes the singular form
|
||||
|
||||
regNoun : Str -> Noun = \vino ->
|
||||
case vino of {
|
||||
vin + c@("c" | "g") + "a"
|
||||
=> mkNoun Fem vino (vin + c + "he") ; -- banche
|
||||
vin + "a"
|
||||
=> mkNoun Fem vino (vin + "e") ; -- pizza
|
||||
vin + c@("c" | "g") + "o"
|
||||
=> mkNoun Masc vino (vin + c + "hi") ; -- boschi
|
||||
vin + ("o" | "e")
|
||||
=> mkNoun Masc vino (vin + "i") ; -- vino, pane
|
||||
_ => mkNoun Masc vino vino -- tram
|
||||
} ;
|
||||
|
||||
-- to make nouns such as "carne", "università" feminine
|
||||
|
||||
femNoun : Noun -> Noun = \mano -> {
|
||||
s = mano.s ;
|
||||
g = Fem
|
||||
} ;
|
||||
|
||||
-- this takes both genders and numbers
|
||||
|
||||
mkAdjective : (x1,_,_,x4 : Str) -> Adjective = \nero,nera,neri,nere -> {
|
||||
s = table {
|
||||
Masc => (mkNoun Masc nero neri).s ;
|
||||
Fem => (mkNoun Fem nera nere).s
|
||||
}
|
||||
} ;
|
||||
|
||||
-- this takes the masculine singular form
|
||||
|
||||
regAdjective : Str -> Adjective = \nero ->
|
||||
let ner = init nero in
|
||||
case last nero of {
|
||||
"o" => mkAdjective (ner + "o") (ner + "a") (ner + "i") (ner + "e") ;
|
||||
"e" => mkAdjective (ner + "e") (ner + "e") (ner + "i") (ner + "i") ;
|
||||
_ => mkAdjective nero nero nero nero
|
||||
} ;
|
||||
|
||||
-- this function takes the singular and plural forms
|
||||
|
||||
mkVerb : Str -> Str -> Verb = \ama,amano -> {
|
||||
s = table {
|
||||
Sg => ama ;
|
||||
Pl => amano
|
||||
}
|
||||
} ;
|
||||
|
||||
-- this function takes the infinitive form
|
||||
|
||||
regVerb : Str -> Verb = \amare ->
|
||||
let am = Predef.tk 3 amare in
|
||||
case Predef.dp 3 amare of {
|
||||
"ere" => mkVerb (am + "e") (am + "ono") ; -- premere
|
||||
"ire" => mkVerb (am + "isce") (am + "iscono") ; -- finire
|
||||
_ => mkVerb (am + "a") (am + "ano") -- amare
|
||||
} ;
|
||||
|
||||
}
|
||||
43
examples-3.0/tutorial/syntax/Syntax.gf
Normal file
43
examples-3.0/tutorial/syntax/Syntax.gf
Normal file
@@ -0,0 +1,43 @@
|
||||
interface Syntax = open Prelude, Grammar in {
|
||||
|
||||
oper
|
||||
mkPhr = overload {
|
||||
mkPhr : S -> Phr
|
||||
= PhrS ;
|
||||
mkPhr : QS -> Phr
|
||||
= PhrQS ;
|
||||
} ;
|
||||
|
||||
mkS = overload {
|
||||
mkS : Pol -> NP -> VP -> S
|
||||
= \p,np,vp -> UseCl p (PredVP np vp) ;
|
||||
mkS : NP -> VP -> S
|
||||
= \np,vp -> UseCl PPos (PredVP np vp) ;
|
||||
mkS : Pol -> NP -> V2 -> NP -> S
|
||||
= \p,np,v,o -> UseCl p (PredVP np (ComplV2 v o)) ;
|
||||
mkS : NP -> V2 -> NP -> S
|
||||
= \np,v,o -> UseCl PPos (PredVP np (ComplV2 v o)) ;
|
||||
mkS : Pol -> NP -> AP -> S
|
||||
= \p,np,ap -> UseCl p (PredVP np (ComplAP ap)) ;
|
||||
mkS : NP -> AP -> S
|
||||
= \np,ap -> UseCl PPos (PredVP np (ComplAP ap)) ;
|
||||
} ;
|
||||
|
||||
mkNP : Det -> CN -> NP
|
||||
= DetCN ;
|
||||
|
||||
mkCN = overload {
|
||||
mkCN : AP -> CN -> CN
|
||||
= ModCN ;
|
||||
mkCN : N -> CN
|
||||
= UseN ;
|
||||
} ;
|
||||
|
||||
mkAP = overload {
|
||||
mkAP : AdA -> AP -> AP
|
||||
= AdAP ;
|
||||
mkAP : A -> AP
|
||||
= UseA ;
|
||||
} ;
|
||||
|
||||
}
|
||||
3
examples-3.0/tutorial/syntax/SyntaxEng.gf
Normal file
3
examples-3.0/tutorial/syntax/SyntaxEng.gf
Normal file
@@ -0,0 +1,3 @@
|
||||
--# -path=.:resource:prelude
|
||||
|
||||
instance SyntaxEng of Syntax = open Prelude, GrammarEng in {} ;
|
||||
3
examples-3.0/tutorial/syntax/SyntaxIta.gf
Normal file
3
examples-3.0/tutorial/syntax/SyntaxIta.gf
Normal file
@@ -0,0 +1,3 @@
|
||||
--# -path=.:resource:prelude
|
||||
|
||||
instance SyntaxIta of Syntax = open Prelude, GrammarIta in {} ;
|
||||
8
examples-3.0/tutorial/syntax/Test.gf
Normal file
8
examples-3.0/tutorial/syntax/Test.gf
Normal file
@@ -0,0 +1,8 @@
|
||||
abstract Test = Grammar ** {
|
||||
|
||||
fun
|
||||
wine_N, cheese_N, fish_N, pizza_N, waiter_N, customer_N : N ;
|
||||
fresh_A, warm_A, italian_A, expensive_A, delicious_A, boring_A : A ;
|
||||
stink_V : V ;
|
||||
eat_V2, love_V2, talk_V2 : V2 ;
|
||||
}
|
||||
23
examples-3.0/tutorial/syntax/TestEng.gf
Normal file
23
examples-3.0/tutorial/syntax/TestEng.gf
Normal file
@@ -0,0 +1,23 @@
|
||||
--# -path=.:resource:prelude
|
||||
|
||||
concrete TestEng of Test = GrammarEng ** open Prelude, MorphoEng in {
|
||||
|
||||
lin
|
||||
wine_N = mkN "wine" ;
|
||||
cheese_N = mkN "cheese" ;
|
||||
fish_N = mkN "fish" "fish" ;
|
||||
pizza_N = mkN "pizza" ;
|
||||
waiter_N = mkN "waiter" ;
|
||||
customer_N = mkN "customer" ;
|
||||
fresh_A = mkA "fresh" ;
|
||||
warm_A = mkA "warm" ;
|
||||
italian_A = mkA "Italian" ;
|
||||
expensive_A = mkA "expensive" ;
|
||||
delicious_A = mkA "delicious" ;
|
||||
boring_A = mkA "boring" ;
|
||||
stink_V = mkV "stink" ;
|
||||
eat_V2 = mkV2 (mkV "eat") ;
|
||||
love_V2 = mkV2 (mkV "love") ;
|
||||
talk_V2 = mkV2 (mkV "talk") "about" ;
|
||||
}
|
||||
|
||||
23
examples-3.0/tutorial/syntax/TestIta.gf
Normal file
23
examples-3.0/tutorial/syntax/TestIta.gf
Normal file
@@ -0,0 +1,23 @@
|
||||
--# -path=.:resource:prelude
|
||||
|
||||
concrete TestIta of Test = GrammarIta ** open Prelude, MorphoIta in {
|
||||
|
||||
lin
|
||||
wine_N = regNoun "vino" ;
|
||||
cheese_N = regNoun "formaggio" ;
|
||||
fish_N = regNoun "pesce" ;
|
||||
pizza_N = regNoun "pizza" ;
|
||||
waiter_N = regNoun "cameriere" ;
|
||||
customer_N = regNoun "cliente" ;
|
||||
fresh_A = regAdjective "fresco" ;
|
||||
warm_A = regAdjective "caldo" ;
|
||||
italian_A = regAdjective "italiano" ;
|
||||
expensive_A = regAdjective "caro" ;
|
||||
delicious_A = regAdjective "delizioso" ;
|
||||
boring_A = regAdjective "noioso" ;
|
||||
stink_V = regVerb "puzzare" ;
|
||||
eat_V2 = regVerb "mangiare" ** {c = []} ;
|
||||
love_V2 = regVerb "amare" ** {c = []} ;
|
||||
talk_V2 = regVerb "parlare" ** {c = "di"} ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user