summaryrefslogtreecommitdiff
path: root/doc/tutorial/resource/SyntaxEng.gf
blob: e4787af473c85db353c3baf8a53d563d606a3178 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
--# -path=.:prelude

concrete SyntaxEng of Syntax = open Prelude, MorphoEng in {

  lincat
    S    = {s : Str} ;
    NP   = {s : Str ; n : Number} ;
    CN   = {s : Number => Str} ;
    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} ;

  lin
    PosVP  np vp = {s = np.s ++ vp.s ! True  ! np.n} ;
    NegVP  np vp = {s = np.s ++ vp.s ! False ! np.n} ;
 
    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} ;

    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} ;

    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} ;
    a_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
    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
        } ;

    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"}} ;


}