forked from GitHub/gf-core
polished the syntax grammar for the book
This commit is contained in:
@@ -6,12 +6,15 @@ concrete GrammarEng of Grammar = open Prelude, MorphoEng in {
|
||||
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 ;
|
||||
@@ -19,36 +22,59 @@ concrete GrammarEng of Grammar = open Prelude, MorphoEng in {
|
||||
V = Verb ;
|
||||
V2 = Verb2 ;
|
||||
Conj = {s : Str} ;
|
||||
Subj = {s : Str} ;
|
||||
Pol = {s : Str ; p : Bool} ;
|
||||
|
||||
lin
|
||||
PhrS = postfixSS "." ;
|
||||
PhrS = postfixSS "." ;
|
||||
PhrQS = postfixSS "?" ;
|
||||
|
||||
PredVP = predVP True ;
|
||||
QuestVP = predVP False ;
|
||||
IPPredVP = predVP True ;
|
||||
|
||||
IPPredV2 p ip np v2 = {
|
||||
s = let
|
||||
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 = {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>
|
||||
bothWays (ip.s ++ (predVP np vp).s ! ord ! pol) v2.c
|
||||
} ;
|
||||
|
||||
ComplAP ap = {s = \\_,b,n => <copula b n, ap.s>} ;
|
||||
ComplV2 v2 np = {
|
||||
s = \\q,b,n =>
|
||||
let vp = predVerb v2 q b n in {
|
||||
fin = vp.fin ;
|
||||
inf = vp.inf ++ v2.c ++ np.s
|
||||
}
|
||||
} ;
|
||||
|
||||
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 vp = {
|
||||
s = \\o,b,n =>
|
||||
let vps = vp.s ! o ! b ! n in {
|
||||
fin = vps.fin ;
|
||||
inf = vps.inf ++ adv.s
|
||||
}
|
||||
} ;
|
||||
|
||||
AdAP ada ap = {s = ada.s ++ ap.s} ;
|
||||
|
||||
IDetCN det cn = {s = det.s ++ cn.s ! det.n ; n = det.n} ;
|
||||
@@ -70,26 +96,30 @@ concrete GrammarEng of Grammar = open Prelude, MorphoEng in {
|
||||
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 : Bool => Bool => Number => Str * Str} ; -- decl, pol
|
||||
VerbPhrase = {s : Order => Bool => Number => {fin,inf : Str}} ;
|
||||
|
||||
predVP : Bool -> {s : Str ; p : Bool} -> NounPhrase -> VerbPhrase -> SS =
|
||||
\q,p,np,vp -> {
|
||||
s = let vps = vp.s ! q ! p.p ! np.n
|
||||
predVP : NounPhrase -> VerbPhrase -> {s : Order => Bool => Str} =
|
||||
\np,vp -> {
|
||||
s = \\q,p =>
|
||||
let vps = vp.s ! q ! 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
|
||||
Dir => np.s ++ vps.fin ++ vps.inf ;
|
||||
Inv => vps.fin ++ np.s ++ vps.inf
|
||||
}
|
||||
} ;
|
||||
|
||||
@@ -101,15 +131,16 @@ concrete GrammarEng of Grammar = open Prelude, MorphoEng in {
|
||||
do : Bool -> Number -> Str = \b,n ->
|
||||
posneg b ((mkV "do").s ! n) ;
|
||||
|
||||
predVerb : Verb -> Bool -> Bool -> Number -> Str * Str = \verb,q,b,n ->
|
||||
predVerb : Verb -> Order -> Bool -> Number -> {fin,inf : 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>
|
||||
<Dir,True> => {fin = [] ; inf = fin} ;
|
||||
_ => {fin = aux ; inf = inf}
|
||||
} ;
|
||||
|
||||
posneg : Bool -> Str -> Str = \b,do -> case b of {
|
||||
|
||||
Reference in New Issue
Block a user