summaryrefslogtreecommitdiff
path: root/examples/phrasebook/Sentences.gf
blob: 6798c2127534ba9a0150f7e9a4d444e11265caf9 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
--1 The Ontology of the Phrasebook

--2 Syntactic Structures of the Phrasebook

-- This module contains phrases that can be defined by a functor over the
-- resource grammar API. The phrases that are likely to have different implementations
-- are in the module Words. But the distinction is not quite sharp; thus it may happen
-- that the functor instantiations make exceptions.

abstract Sentences = Numeral ** {

-- The ontology of the phrasebook is defined by the following types. The commented ones
-- are defined in other modules.

  cat
    Phrase ;      -- complete phrase, the unit of translation  e.g. "Where are you?"
    Word ;        -- word that could be used as phrase         e.g. "Monday"
    Message ;     -- sequence of phrases, longest unit         e.g. "Hello! Where are you?"
    Greeting ;    -- idiomatic greeting                        e.g. "hello"
    Sentence ;    -- declarative sentence                      e.g. "I am in the bar"
    Question ;    -- question, either yes/no or wh             e.g. "where are you"
    Proposition ; -- can be turned into sentence or question   e.g. "this pizza is good"
    Object ;      -- the object of wanting, ordering, etc      e.g. "three pizzas and a beer"
    PrimObject ;  -- single object of wanting, ordering, etc   e.g. "three pizzas"
    Item ;        -- a single entity                           e.g. "this pizza"
    Kind ;        -- a type of an item                         e.g. "pizza"
    MassKind ;    -- a type mass (uncountable)                 e.g. "water"
    PlurKind ;    -- a type usually only in plural             e.g. "noodles"
    DrinkKind ;   -- a drinkable, countable type               e.g. "beer"
    Quality ;     -- qualification of an item, can be complex  e.g. "very good"
    Property ;    -- basic property of an item, one word       e.g. "good"
    Place ;       -- location                                  e.g. "the bar" 
    PlaceKind ;   -- type of location                          e.g. "bar" 
    Currency ;    -- currency unit                             e.g. "leu"  
    Price ;       -- number of currency units                  e.g. "eleven leu"
    Person ;      -- agent wanting or doing something          e.g. "you" 
    Action ;      -- proposition about a Person                e.g. "you are here"
    Nationality ; -- complex of language, property, country    e.g. "Swedish, Sweden"
    LAnguage ;    -- language (can be without nationality)     e.g. "Flemish"
    Citizenship ; -- property (can be without language)        e.g. "Belgian"
    Country ;     -- country (can be without language)         e.g. "Belgium"
    Day ;         -- weekday type                              e.g. "Friday"
    Date ;        -- definite date                             e.g. "on Friday"
    Name ;        -- name of person                            e.g. "NN"
    Number ;      -- number expression 1 .. 999,999            e.g. "twenty"
    Transport ;   -- transportation device                     e.g. "car"
    ByTransport ; -- mean of transportation                    e.g. "by tram"
    Superlative ; -- superlative modifiers of places           e.g. "the best restaurant"


  fun 

-- To build a whole message

    MPhrase   : Phrase -> Message ;
    MContinue : Phrase -> Message -> Message ;

-- Many of the categories are accessible as Phrases, i.e. as translation units.
-- To regulate whether words appear on the top level, change their status between
-- Word and Phrase, or uncomment PWord,

    --    PWord : Word -> Phrase ;

    PGreetingMale   : Greeting -> Phrase ;  -- depends on speaker e.g. in Thai
    PGreetingFemale : Greeting -> Phrase ;
    PSentence       : Sentence -> Phrase ;
    PQuestion       : Question -> Phrase ;

    PNumber      : Number      -> Phrase ;
    PPrice       : Price       -> Phrase ;
    PObject      : Object      -> Word ;
    PKind        : Kind        -> Word ;
    PMassKind    : MassKind    -> Word ;
    PQuality     : Quality     -> Word ;
    PPlace       : Place       -> Word ;
    PPlaceKind   : PlaceKind   -> Word ;
    PCurrency    : Currency    -> Word ;
    PLanguage    : LAnguage    -> Word ;
    PCitizenship : Citizenship -> Word ;
    PCountry     : Country     -> Word ;
    PDay         : Day         -> Word ;
    PByTransport : ByTransport -> Word ;
    PTransport   : Transport   -> Word ;

    PYes, PNo, PYesToNo : Greeting ;  -- yes, no, si/doch (pos. answer to neg. question)

-- To order something.

    GObjectPlease : Object -> Greeting ;           -- a pizza and beer, please!

-- This is the way to build propositions about inanimate items.

    Is     : Item -> Quality -> Proposition ;      -- this pizza is good
    IsMass : MassKind -> Quality -> Proposition ;  -- Belgian beer is good

-- To use propositions on higher levels.

    SProp    : Proposition -> Sentence ;         -- this pizza is good
    SPropNot : Proposition -> Sentence ;         -- this pizza isn't good
    QProp    : Proposition -> Question ;         -- is this pizza good

    WherePlace  : Place  -> Question ;           -- where is the bar
    WherePerson : Person -> Question ;           -- where are you

-- This is the way to build propositions about persons.

    PropAction : Action -> Proposition ;         -- (you (are|aren't) | are you) Swedish

-- Here are some general syntactic constructions.

    ObjItem   : Item -> PrimObject ;             -- this pizza
    ObjNumber : Number -> Kind -> PrimObject ;   -- five pizzas
    ObjIndef  : Kind -> PrimObject ;             -- a pizza
    ObjPlural : Kind -> PrimObject ;             -- pizzas
    ObjPlur   : PlurKind -> PrimObject ;         -- noodles
    ObjMass   : MassKind -> PrimObject ;         -- water
    ObjAndObj : PrimObject -> Object -> Object ; -- this pizza and a beer
    OneObj    : PrimObject -> Object ;           -- this pizza
    
    SuchKind : Quality -> Kind -> Kind ;         -- Italian pizza
    SuchMassKind : Quality -> MassKind -> MassKind ; -- Italian water
    Very : Property -> Quality ;                 -- very Italian
    Too  : Property -> Quality ;                 -- too Italian      
    PropQuality : Property -> Quality ;          -- Italian

    MassDrink   : DrinkKind -> MassKind ;               -- beer
    DrinkNumber : Number -> DrinkKind -> PrimObject ;   -- five beers

-- Determiners.

    This, That, These, Those : Kind -> Item ;           -- this pizza,...,those pizzas
    The, Thes : Kind -> Item ;                          -- the pizza, the pizzas
    ThisMass, ThatMass, TheMass : MassKind -> Item ;    -- this/that/the water
    ThesePlur, ThosePlur, ThesPlur : PlurKind -> Item ; -- these/those/the potatoes

    AmountCurrency : Number -> Currency -> Price ;    -- five euros

    ThePlace : PlaceKind -> Place ;                   -- the bar
    APlace : PlaceKind -> Place ;                     -- a bar
   
    IMale, IFemale,                     -- I, said by man/woman (affects agreement)
    YouFamMale, YouFamFemale,           -- familiar you, said to man/woman (affects agreement)
    YouPolMale, YouPolFemale : Person ; -- polite you, said to man/woman (affects agreement)

    LangNat    : Nationality -> LAnguage ;    -- Swedish
    CitiNat    : Nationality -> Citizenship ; -- Swedish
    CountryNat : Nationality -> Country ;     -- Sweden
    PropCit    : Citizenship -> Property ;    -- Swedish

    OnDay      : Day -> Date ;  -- on Friday
    Today      : Date ;         -- today

    PersonName : Name -> Person ;             -- person referred by name
    NameNN     : Name ;                       -- the name "NN"

----    NameString : String -> Name ; ---- creates ambiguities with all words --%

    NNumeral   : Numeral -> Number ;          -- numeral in words, e.g. "twenty"

-- Actions are typically language-dependent, not only lexically but also
-- structurally. However, these ones are mostly functorial.

    SHave       : Person -> Object      -> Sentence ;  -- you have beer
    SHaveNo     : Person -> Kind        -> Sentence ;  -- you have no apples
    SHaveNoMass : Person -> MassKind    -> Sentence ;  -- you have no beer
    QDoHave     : Person -> Object      -> Question ;  -- do you have beer

    AHaveCurr : Person -> Currency    -> Action ;  -- you have dollars
    ACitizen  : Person -> Citizenship -> Action ;  -- you are Swedish
    ABePlace  : Person -> Place       -> Action ;  -- you are in the bar

    ByTransp : Transport -> ByTransport ;          -- by bus

    AKnowSentence : Person -> Sentence -> Action ; -- you know that I am in the bar
    AKnowPerson   : Person -> Person   -> Action ; -- you know me
    AKnowQuestion : Person -> Question -> Action ; -- you know how far the bar is

------------------------------------------------------------------------------------------
-- New things added 30/11/2011 by AR
------------------------------------------------------------------------------------------

  cat
    VerbPhrase ;  -- things one does, can do, must do, wants to do, e.g. swim
    Modality ;    -- can, want, must
  fun
    ADoVerbPhrase       : Person -> VerbPhrase -> Action ;                       -- I swim
    AModVerbPhrase      : Modality -> Person -> VerbPhrase -> Action ;           -- I can swim
    ADoVerbPhrasePlace  : Person -> VerbPhrase -> Place -> Action ;              -- I swim in the hotel
    AModVerbPhrasePlace : Modality -> Person -> VerbPhrase -> Place -> Action ;  -- I can swim in the hotel

    QWhereDoVerbPhrase  : Person -> VerbPhrase -> Question ;                     -- where do you swim
    QWhereModVerbPhrase : Modality -> Person -> VerbPhrase -> Question ;         -- where can I swim

    MCan, MKnow, MMust, MWant : Modality ;
  
-- lexical items given in the resource Lexicon
    
    VPlay, VRun, VSit, VSleep, VSwim, VWalk : VerbPhrase ;
    VDrink, VEat, VRead, VWait, VWrite, VSit, VStop : VerbPhrase ;
    V2Buy, V2Drink, V2Eat : Object -> VerbPhrase ;
    V2Wait : Person -> VerbPhrase ;

    PImperativeFamPos,    -- eat
    PImperativeFamNeg,    -- don't eat
    PImperativePolPos,    -- essen Sie
    PImperativePolNeg,    -- essen Sie nicht
    PImperativePlurPos,   -- esst
    PImperativePlurNeg :  -- esst nicht
      VerbPhrase -> Phrase ;

-- other new things allowed by the resource

---    PBecause : Sentence -> Sentence -> Phrase ;  -- I want to swim because it is hot

    He, She,                                  -- he, she
    WeMale, WeFemale,                         -- we, said by men/women (affects agreement)
    YouPlurFamMale, YouPlurFamFemale,         -- plural familiar you, said to men/women (affects agreement)
    YouPlurPolMale, YouPlurPolFemale,         -- plural polite you, said to men/women (affects agreement)
    TheyMale, TheyFemale : Person ;           -- they, said of men/women (affects agreement)

}