summaryrefslogtreecommitdiff
path: root/doc/tutorial/resource/SyntaxEng.gf
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2007-08-16 09:41:00 +0000
committeraarne <aarne@cs.chalmers.se>2007-08-16 09:41:00 +0000
commit1f342b2c25a5b3026de101028a56b3ff17e04e5b (patch)
tree02ab8398695564ed6e019a0c028e4e068c952cc2 /doc/tutorial/resource/SyntaxEng.gf
parent69129be4b25c6d764df449dfdb2e15cf4b4ebd0a (diff)
prepared mini syntax example
Diffstat (limited to 'doc/tutorial/resource/SyntaxEng.gf')
-rw-r--r--doc/tutorial/resource/SyntaxEng.gf88
1 files changed, 68 insertions, 20 deletions
diff --git a/doc/tutorial/resource/SyntaxEng.gf b/doc/tutorial/resource/SyntaxEng.gf
index e4787af47..4eac0058e 100644
--- a/doc/tutorial/resource/SyntaxEng.gf
+++ b/doc/tutorial/resource/SyntaxEng.gf
@@ -3,23 +3,53 @@
concrete SyntaxEng of Syntax = open Prelude, MorphoEng in {
lincat
+ Phr = {s : Str} ;
S = {s : Str} ;
- NP = {s : Str ; n : Number} ;
- CN = {s : Number => Str} ;
+ QS = {s : Str} ;
+ NP = MorphoEng.NP ;
+ IP = MorphoEng.NP ;
+ CN = Noun ;
Det = {s : Str ; n : Number} ;
AP = {s : Str} ;
AdA = {s : Str} ;
- VP = {s : Bool => Number => Str} ;
- V = {s : Number => Str} ;
- V2 = {s : Number => Str ; c : Str} ;
+ VP = MorphoEng.VP ;
+ N = Noun ;
+ A = {s : Str} ;
+ V = Verb ;
+ V2 = Verb ** {c : Str} ;
lin
- PosVP np vp = {s = np.s ++ vp.s ! True ! np.n} ;
- NegVP np vp = {s = np.s ++ vp.s ! False ! np.n} ;
+ PhrS = postfixSS "." ;
+ PhrQS = postfixSS "?" ;
- PredAP ap = {s = \\b,n => copula b n ++ ap.s} ;
- PredV v = {s = \\b,n => predVerb b n v} ;
- PredV2 v2 np = {s = \\b,n => predVerb b n v2 ++ v2.c ++ np.s} ;
+ 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 : MorphoEng.VP = {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 : MorphoEng.VP = {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} ;
@@ -27,6 +57,12 @@ concrete SyntaxEng of Syntax = open Prelude, MorphoEng in {
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} ;
@@ -34,25 +70,39 @@ concrete SyntaxEng of Syntax = open Prelude, MorphoEng in {
every_Det = {s = "every" ; n = Sg} ;
theSg_Det = {s = "the" ; n = Sg} ;
thePl_Det = {s = "the" ; n = Pl} ;
- a_Det = {s = artIndef ; n = Sg} ;
+ indef_Det = {s = artIndef ; n = Sg} ;
plur_Det = {s = [] ; n = Pl} ;
two_Det = {s = "two" ; n = Pl} ;
very_AdA = {s = "very"} ;
- too_AdA = {s = "too"} ;
-
oper
+ predVP : Bool -> Bool -> MorphoEng.NP -> MorphoEng.VP -> 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"
} ;
- predVerb : Bool -> Number -> Verb -> Str = \b,n,verb ->
- let inf = verb.s ! Sg in
- case b of {
- True => verb.s ! n ;
- False => posneg b ((regVerb "do").s ! n) ++ inf
+ do : Bool -> Number -> Str = \b,n ->
+ posneg b ((regVerb "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 {
@@ -62,6 +112,4 @@ concrete SyntaxEng of Syntax = open Prelude, MorphoEng in {
artIndef : Str =
pre {"a" ; "an" / strs {"a" ; "e" ; "i" ; "o"}} ;
-
-
}