forked from GitHub/gf-core
refactored tutorial syntax example
This commit is contained in:
71
examples/tutorial/syntax/Grammar.gf
Normal file
71
examples/tutorial/syntax/Grammar.gf
Normal file
@@ -0,0 +1,71 @@
|
||||
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"
|
||||
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"
|
||||
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)
|
||||
|
||||
fun
|
||||
PhrS : S -> Phr ;
|
||||
PhrQS : QS -> Phr ;
|
||||
|
||||
PredVP : Pol -> NP -> VP -> S ;
|
||||
QuestVP : Pol -> NP -> VP -> QS ;
|
||||
|
||||
IPPredVP : Pol -> IP -> VP -> QS ;
|
||||
IPPredV2 : Pol -> IP -> NP -> V2 -> QS ;
|
||||
|
||||
ComplV2 : V2 -> NP -> VP ;
|
||||
ComplAP : AP -> VP ;
|
||||
|
||||
DetCN : Det -> CN -> NP ;
|
||||
|
||||
ModCN : AP -> CN -> CN ;
|
||||
|
||||
AdAP : AdA -> AP -> AP ;
|
||||
|
||||
IDetCN : IDet -> CN -> IP ;
|
||||
|
||||
-- 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 ;
|
||||
|
||||
very_AdA : AdA ;
|
||||
|
||||
-- polarities
|
||||
|
||||
PPos, PNeg : Pol ;
|
||||
|
||||
}
|
||||
116
examples/tutorial/syntax/GrammarEng.gf
Normal file
116
examples/tutorial/syntax/GrammarEng.gf
Normal file
@@ -0,0 +1,116 @@
|
||||
--# -path=.:prelude
|
||||
|
||||
concrete GrammarEng of Grammar = open Prelude, MorphoEng in {
|
||||
|
||||
lincat
|
||||
Phr = {s : Str} ;
|
||||
S = {s : Str} ;
|
||||
QS = {s : Str} ;
|
||||
NP = NounPhrase ;
|
||||
IP = NounPhrase ;
|
||||
CN = Noun ;
|
||||
Det = {s : Str ; n : Number} ;
|
||||
IDet = {s : Str ; n : Number} ;
|
||||
AP = {s : Str} ;
|
||||
AdA = {s : Str} ;
|
||||
VP = VerbPhrase ;
|
||||
N = Noun ;
|
||||
A = {s : Str} ;
|
||||
V = Verb ;
|
||||
V2 = Verb2 ;
|
||||
Pol = {s : Str ; p : Bool} ;
|
||||
|
||||
lin
|
||||
PhrS = postfixSS "." ;
|
||||
PhrQS = postfixSS "?" ;
|
||||
|
||||
PredVP = predVP True ;
|
||||
QuestVP = predVP False ;
|
||||
IPPredVP = predVP True ;
|
||||
|
||||
IPPredV2 p ip np v2 = {
|
||||
s = let
|
||||
vp : VerbPhrase = {s = \\q,b,n => predVerb v2 q b n} ;
|
||||
in
|
||||
bothWays (ip.s ++ (predVP False p np vp).s) v2.c
|
||||
} ;
|
||||
|
||||
|
||||
ComplV2 v2 np = {
|
||||
s = \\q,b,n =>
|
||||
let vp = predVerb v2 q b n in
|
||||
<vp.p1, vp.p2 ++ v2.c ++ np.s>
|
||||
} ;
|
||||
|
||||
ComplAP ap = {s = \\_,b,n => <copula b n, 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} ;
|
||||
|
||||
AdAP ada ap = {s = ada.s ++ ap.s} ;
|
||||
|
||||
IDetCN det cn = {s = det.s ++ cn.s ! det.n ; n = det.n} ;
|
||||
|
||||
UseN n = n ;
|
||||
UseA a = a ;
|
||||
UseV v = {s = \\q,b,n => predVerb v q b n} ;
|
||||
|
||||
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} ;
|
||||
|
||||
very_AdA = {s = "very"} ;
|
||||
|
||||
which_IDet = {s = "which" ; n = Sg} ;
|
||||
|
||||
PPos = {s = [] ; p = True} ;
|
||||
PNeg = {s = [] ; p = False} ;
|
||||
|
||||
oper
|
||||
NounPhrase = {s : Str ; n : Number} ;
|
||||
VerbPhrase = {s : Bool => Bool => Number => Str * Str} ; -- decl, pol
|
||||
|
||||
predVP : Bool -> {s : Str ; p : Bool} -> NounPhrase -> VerbPhrase -> SS =
|
||||
\q,p,np,vp -> {
|
||||
s = let vps = vp.s ! q ! p.p ! np.n
|
||||
in case q of {
|
||||
True => p.s ++ np.s ++ vps.p1 ++ vps.p2 ;
|
||||
False => p.s ++ vps.p1 ++ np.s ++ vps.p2
|
||||
}
|
||||
} ;
|
||||
|
||||
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 -> Bool -> Bool -> Number -> Str * Str = \verb,q,b,n ->
|
||||
let
|
||||
inf = verb.s ! Pl ;
|
||||
fin = verb.s ! n ;
|
||||
aux = do b n
|
||||
in
|
||||
case <q,b> of {
|
||||
<True,True> => <[],fin> ;
|
||||
_ => <aux,inf>
|
||||
} ;
|
||||
|
||||
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"}} ;
|
||||
}
|
||||
101
examples/tutorial/syntax/GrammarIta.gf
Normal file
101
examples/tutorial/syntax/GrammarIta.gf
Normal file
@@ -0,0 +1,101 @@
|
||||
--# -path=.:prelude
|
||||
|
||||
concrete GrammarIta of Grammar = open Prelude, MorphoIta in {
|
||||
|
||||
lincat
|
||||
Phr = {s : Str} ;
|
||||
S = {s : Str} ;
|
||||
QS = {s : Str} ;
|
||||
NP = {s : Str ; g : Gender ; n : Number} ;
|
||||
IP = {s : Str ; g : Gender ; n : Number} ;
|
||||
CN = Noun ;
|
||||
Det = {s : Gender => Str ; n : Number} ;
|
||||
IDet = {s : Gender => Str ; n : Number} ;
|
||||
AP = {s : Gender => Number => Str} ;
|
||||
AdA = {s : Str} ;
|
||||
VP = {s : Bool => Gender => Number => Str} ;
|
||||
N = Noun ;
|
||||
A = Adjective ;
|
||||
V = Verb ;
|
||||
V2 = Verb2 ;
|
||||
Pol = {s : Str ; p : Bool} ;
|
||||
|
||||
|
||||
lin
|
||||
PhrS = postfixSS "." ;
|
||||
PhrQS = postfixSS "?" ;
|
||||
|
||||
PredVP p np vp = {s = np.s ++ p.s ++ vp.s ! p.p ! np.g ! np.n} ;
|
||||
QuestVP p np vp = {s = np.s ++ p.s ++ vp.s ! p.p ! np.g ! np.n} ;
|
||||
IPPredVP p np vp = {s = np.s ++ p.s ++ vp.s ! p.p ! np.g ! np.n} ;
|
||||
|
||||
IPPredV2 p ip np v2 =
|
||||
{s = v2.c ++ ip.s ++ p.s ++ posneg p.p ++ 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} ;
|
||||
IDetCN 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} ;
|
||||
|
||||
AdAP ada ap = {s = \\n,g => ada.s ++ ap.s ! n ! 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} ;
|
||||
very_AdA = {s = "molto"} ;
|
||||
which_IDet = {s = \\_ => "quale" ; n = Sg} ;
|
||||
|
||||
PPos = {s = [] ; p = True} ;
|
||||
PNeg = {s = [] ; p = False} ;
|
||||
|
||||
oper
|
||||
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}
|
||||
} ;
|
||||
|
||||
sImpuro : Strs = strs {"sb" ; "sp" ; "sy" ; "z"} ;
|
||||
vowel : Strs = strs {"a" ; "e" ; "i" ; "o" ; "u"} ;
|
||||
|
||||
}
|
||||
@@ -1,60 +1,26 @@
|
||||
abstract Syntax = {
|
||||
interface Syntax = open Prelude, Grammar in {
|
||||
|
||||
flags startcat=Phr ;
|
||||
oper
|
||||
mkPhr = overload {
|
||||
mkPhr : S -> Phr
|
||||
= PhrS ;
|
||||
mkPhr : QS -> Phr
|
||||
= PhrQS ;
|
||||
} ;
|
||||
|
||||
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"
|
||||
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"
|
||||
AP ; -- adjectival phrase e.g. "very good"
|
||||
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"
|
||||
mkS = overload {
|
||||
mkS : Pol -> NP -> VP -> S
|
||||
= PredVP ;
|
||||
mkS : NP -> VP -> S
|
||||
= PredVP PPos ;
|
||||
mkS : Pol -> NP -> V2 -> NP -> S
|
||||
= \p,np,v,o -> PredVP p np (ComplV2 v o) ;
|
||||
mkS : NP -> V2 -> NP -> S
|
||||
= \np,v,o -> PredVP PPos np (ComplV2 v o) ;
|
||||
mkS : Pol -> NP -> AP -> S
|
||||
= \p,np,ap -> PredVP p np (ComplAP ap) ;
|
||||
mkS : NP -> AP -> S
|
||||
= \np,ap -> PredVP PPos np (ComplAP ap) ;
|
||||
} ;
|
||||
|
||||
fun
|
||||
PhrS : S -> Phr ;
|
||||
PhrQS : QS -> Phr ;
|
||||
|
||||
PosVP, NegVP : NP -> VP -> S ;
|
||||
QPosVP, QNegVP : NP -> VP -> QS ;
|
||||
|
||||
IPPosVP, IPNegVP : IP -> VP -> QS ;
|
||||
IPPosV2, IPNegV2 : IP -> NP -> V2 -> QS ;
|
||||
|
||||
ComplV2 : V2 -> NP -> VP ;
|
||||
ComplAP : AP -> VP ;
|
||||
|
||||
DetCN : Det -> CN -> NP ;
|
||||
|
||||
ModCN : AP -> CN -> CN ;
|
||||
|
||||
AdAP : AdA -> AP -> AP ;
|
||||
|
||||
WhichCN : CN -> IP ;
|
||||
|
||||
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 ;
|
||||
|
||||
very_AdA : AdA ;
|
||||
}
|
||||
}
|
||||
@@ -1,118 +1,3 @@
|
||||
--# -path=.:prelude
|
||||
--# -path=.:resource:prelude
|
||||
|
||||
concrete SyntaxEng of Syntax = open Prelude, MorphoEng in {
|
||||
|
||||
lincat
|
||||
Phr = {s : Str} ;
|
||||
S = {s : Str} ;
|
||||
QS = {s : Str} ;
|
||||
NP = NounPhrase ;
|
||||
IP = NounPhrase ;
|
||||
CN = Noun ;
|
||||
Det = {s : Str ; n : Number} ;
|
||||
AP = {s : Str} ;
|
||||
AdA = {s : Str} ;
|
||||
VP = VerbPhrase ;
|
||||
N = Noun ;
|
||||
A = {s : Str} ;
|
||||
V = Verb ;
|
||||
V2 = Verb2 ;
|
||||
|
||||
lin
|
||||
PhrS = postfixSS "." ;
|
||||
PhrQS = postfixSS "?" ;
|
||||
|
||||
PosVP = predVP True True ;
|
||||
NegVP = predVP True False ;
|
||||
QPosVP = predVP False True ;
|
||||
QNegVP = predVP False False ;
|
||||
IPPosVP = predVP True True ;
|
||||
IPNegVP = predVP True False ;
|
||||
|
||||
IPPosV2 ip np v2 = {
|
||||
s = let
|
||||
vp : VerbPhrase = {s = \\q,b,n => predVerb v2 q b n} ;
|
||||
in
|
||||
bothWays (ip.s ++ (predVP False True np vp).s) v2.c
|
||||
} ;
|
||||
IPNegV2 ip np v2 = {
|
||||
s = let
|
||||
vp : VerbPhrase = {s = \\q,b,n => predVerb v2 q b n} ;
|
||||
in
|
||||
bothWays (ip.s ++ (predVP False False np vp).s) v2.c
|
||||
} ;
|
||||
|
||||
|
||||
ComplV2 v2 np = {
|
||||
s = \\q,b,n =>
|
||||
let vp = predVerb v2 q b n in
|
||||
<vp.p1, vp.p2 ++ v2.c ++ np.s>
|
||||
} ;
|
||||
|
||||
ComplAP ap = {s = \\_,b,n => <copula b n, 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} ;
|
||||
|
||||
AdAP ada ap = {s = ada.s ++ ap.s} ;
|
||||
|
||||
WhichCN cn = {s = "which" ++ cn.s ! Sg ; n = Sg} ;
|
||||
|
||||
UseN n = n ;
|
||||
UseA a = a ;
|
||||
UseV v = {s = \\q,b,n => predVerb v q b n} ;
|
||||
|
||||
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} ;
|
||||
|
||||
very_AdA = {s = "very"} ;
|
||||
|
||||
oper
|
||||
NounPhrase = {s : Str ; n : Number} ;
|
||||
VerbPhrase = {s : Bool => Bool => Number => Str * Str} ; -- decl, pol
|
||||
|
||||
predVP : Bool -> Bool -> NounPhrase -> VerbPhrase -> SS =
|
||||
\q,b,np,vp -> {
|
||||
s = let vps = vp.s ! q ! b ! np.n
|
||||
in case q of {
|
||||
True => np.s ++ vps.p1 ++ vps.p2 ;
|
||||
False => vps.p1 ++ np.s ++ vps.p2
|
||||
}
|
||||
} ;
|
||||
|
||||
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 -> Bool -> Bool -> Number -> Str * Str = \verb,q,b,n ->
|
||||
let
|
||||
inf = verb.s ! Pl ;
|
||||
fin = verb.s ! n ;
|
||||
aux = do b n
|
||||
in
|
||||
case <q,b> of {
|
||||
<True,True> => <[],fin> ;
|
||||
_ => <aux,inf>
|
||||
} ;
|
||||
|
||||
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"}} ;
|
||||
}
|
||||
instance SyntaxEng of Syntax = open Prelude, GrammarEng in {} ;
|
||||
|
||||
@@ -1,102 +1,3 @@
|
||||
--# -path=.:prelude
|
||||
--# -path=.:resource:prelude
|
||||
|
||||
concrete SyntaxIta of Syntax = open Prelude, MorphoIta in {
|
||||
|
||||
lincat
|
||||
Phr = {s : Str} ;
|
||||
S = {s : Str} ;
|
||||
QS = {s : Str} ;
|
||||
NP = {s : Str ; g : Gender ; n : Number} ;
|
||||
IP = {s : Str ; g : Gender ; n : Number} ;
|
||||
CN = Noun ;
|
||||
Det = {s : Gender => Str ; n : Number} ;
|
||||
AP = {s : Gender => Number => Str} ;
|
||||
AdA = {s : Str} ;
|
||||
VP = {s : Bool => Gender => Number => Str} ;
|
||||
|
||||
N = Noun ;
|
||||
A = Adjective ;
|
||||
V = Verb ;
|
||||
V2 = Verb2 ;
|
||||
|
||||
lin
|
||||
PhrS = postfixSS "." ;
|
||||
PhrQS = postfixSS "?" ;
|
||||
|
||||
PosVP np vp = {s = np.s ++ vp.s ! True ! np.g ! np.n} ;
|
||||
NegVP np vp = {s = np.s ++ vp.s ! False ! np.g ! np.n} ;
|
||||
QPosVP np vp = {s = np.s ++ vp.s ! True ! np.g ! np.n} ;
|
||||
QNegVP np vp = {s = np.s ++ vp.s ! False ! np.g ! np.n} ;
|
||||
IPPosVP np vp = {s = np.s ++ vp.s ! True ! np.g ! np.n} ;
|
||||
IPNegVP np vp = {s = np.s ++ vp.s ! False ! np.g ! np.n} ;
|
||||
|
||||
IPPosV2 ip np v2 = {s = v2.c ++ ip.s ++ v2.s ! np.n ++ np.s} ;
|
||||
IPNegV2 ip np v2 = {s = v2.c ++ ip.s ++ "non" ++ 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} ;
|
||||
|
||||
AdAP ada ap = {s = \\n,g => ada.s ++ ap.s ! n ! g} ;
|
||||
|
||||
WhichCN cn = {s = "quale" ++ cn.s ! Sg ; g = cn.g ; n = Sg} ;
|
||||
|
||||
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} ;
|
||||
|
||||
very_AdA = {s = "molto"} ;
|
||||
|
||||
|
||||
oper
|
||||
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}
|
||||
} ;
|
||||
|
||||
sImpuro : Strs = strs {"sb" ; "sp" ; "sy" ; "z"} ;
|
||||
vowel : Strs = strs {"a" ; "e" ; "i" ; "o" ; "u"} ;
|
||||
|
||||
}
|
||||
instance SyntaxIta of Syntax = open Prelude, GrammarIta in {} ;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
abstract Test = Syntax ** {
|
||||
abstract Test = Grammar ** {
|
||||
|
||||
fun
|
||||
wine_N, cheese_N, fish_N, pizza_N, waiter_N, customer_N : N ;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--# -path=.:resource:prelude
|
||||
|
||||
concrete TestEng of Test = SyntaxEng ** open Prelude, MorphoEng in {
|
||||
concrete TestEng of Test = GrammarEng ** open Prelude, MorphoEng in {
|
||||
|
||||
lin
|
||||
wine_N = mkN "wine" ;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--# -path=.:resource:prelude
|
||||
|
||||
concrete TestIta of Test = SyntaxIta ** open Prelude, MorphoIta in {
|
||||
concrete TestIta of Test = GrammarIta ** open Prelude, MorphoIta in {
|
||||
|
||||
lin
|
||||
wine_N = regNoun "vino" ;
|
||||
|
||||
Reference in New Issue
Block a user