From 6234e536f63e3e803286b94cee8a0e0a3adcdcb2 Mon Sep 17 00:00:00 2001 From: aarne Date: Thu, 16 Aug 2007 16:18:54 +0000 Subject: moved tutorial examples to GF/examples --- examples/tutorial/syntax/SyntaxEng.gf | 118 ++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 examples/tutorial/syntax/SyntaxEng.gf (limited to 'examples/tutorial/syntax/SyntaxEng.gf') diff --git a/examples/tutorial/syntax/SyntaxEng.gf b/examples/tutorial/syntax/SyntaxEng.gf new file mode 100644 index 000000000..f1de47e21 --- /dev/null +++ b/examples/tutorial/syntax/SyntaxEng.gf @@ -0,0 +1,118 @@ +--# -path=.: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 + + } ; + + ComplAP ap = {s = \\_,b,n => } ; + + 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 of { + => <[],fin> ; + _ => + } ; + + 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"}} ; +} -- cgit v1.2.3