summaryrefslogtreecommitdiff
path: root/examples/phrasebook/Sentences.gf
blob: a5249d3ca776b773f8a24bfc64a68c46b8695740 (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

-- 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.

  cat
    Phrase ;      -- complete phrase, the unit of translation  e.g. "Where are you?"
    Sentence ;    -- declarative sentence                      e.g. "I am in the bar"
    Question ;    -- question, either yes/no or wh             e.g. "where are you"
    -- Greeting ; -- idiomatic phrase, not inflected,          e.g. "hello"
    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"
    Item ;        -- a single entity                           e.g. "this pizza"
    Kind ;        -- a type of an item                         e.g. "pizza"
    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"
    -- Numeral ;  -- number expression 1 .. 999,999            e.g. "twenty"

-- Many of the categories are accessible as Phrases, i.e. as translation units.

  fun
    PSentence : Sentence -> Phrase ;
    PQuestion : Question -> Phrase ;

    PObject   : Object   -> Phrase ;
    PKind     : Kind     -> Phrase ;
    PQuality  : Quality  -> Phrase ;
    PNumeral  : Numeral  -> Phrase ;
    PPlace    : Place    -> Phrase ;
    PPlaceKind: PlaceKind-> Phrase ;
    PCurrency : Currency -> Phrase ;
    PPrice    : Price    -> Phrase ;
    PLanguage : Language -> Phrase ;
    PCitizenship : Citizenship -> Phrase ;
    PCountry  : Country -> Phrase ;
    PDay      : Day -> Phrase ;

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

    Is       : Item -> Quality -> Proposition ;  -- this pizza is good

    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 -> Object ;                 -- this pizza
    ObjNumber : Numeral -> Kind -> Object ;      -- five pizzas
    ObjIndef  : Kind -> Object ;                 -- a pizza
    
    SuchKind : Quality -> Kind -> Kind ;         -- Italian pizza
    Very : Property -> Quality ;                 -- very Italian
    Too  : Property -> Quality ;                 -- too Italian      
    PropQuality : Property -> Quality ;          -- Italian

-- Determiners.

    This, That, These, Those : Kind -> Item ;    -- this pizza,...,those pizzas
    The, Thes : Kind -> Item ;                   -- the pizza, the pizzas

    AmountCurrency : Numeral -> Currency -> Price ;  -- five euros
    HowMuchCost    : Item -> Question ;              -- how much does the pizza cost
    ItCost         : Item -> Price -> Proposition ;  -- the pizza costs five euros

    ThePlace : PlaceKind -> Place ;                  -- the 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

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

    AHave    : Person -> Kind        -> Action ;  -- you have a pizza
    ACitizen : Person -> Citizenship -> Action ;  -- you are Swedish
    ABePlace : Person -> Place       -> Action ;  -- you are in the bar



}