-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathimperative_test.rb
141 lines (113 loc) · 3.93 KB
/
imperative_test.rb
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
# Democrats should hope for more snow this year... [is this even possible]?
# Democrats should hope Central Park snow increases year over year.
# If you're a Democrat, you should hope that _________
# Republicans, you need to hope that DDDDDDD is an even number this year.
# If you're a Democrat, you want vegetable use to increase this year.
require 'simplernlg'
NLG= SimplerNLG::NLG
party_phrase = NLG.phrase({
:s => "Democrats",
:number => :plural,
:v => 'hope',
:modal => "should",
:tense => :present,
})
## this bit should be identical to that used in the other generator.
bears = NLG.factory.create_noun_phrase('bear')
bears.set_feature SimplerNLG::NLG::Feature::NUMBER, SimplerNLG::NLG::NumberAgreement::PLURAL
comp = NLG.phrase({
:s => bears,
:v => 'kill',
:tense => :past,
:o => 'more than 10 people'
})
pp = NLG.factory.create_preposition_phrase(NLG.factory.create_noun_phrase('this', 'year'))
## end identical bit
party_phrase.add_complement(comp)
modifiers = [:add_post_modifier, :add_front_modifier]
party_phrase.send(modifiers.sample, pp)
NLG.realizer.setCommaSepCuephrase(true)
sent = NLG.realizer.realise_sentence(party_phrase)
puts sent
#################
address_phrase = NLG.phrase({
:s => "you",
:number => :plural,
:v => 'need',
:tense => :present,
})
inner = NLG.phrase({
:v => "hope"
})
## this bit should be identical to that used in the other generator.
bears = NLG.factory.create_noun_phrase('bear')
bears.set_feature NLG::Feature::NUMBER, NLG::NumberAgreement::PLURAL
comp = NLG.phrase({
:s => bears,
:v => 'kill',
:tense => :past,
:o => 'more than 10 people'
})
pp = NLG.factory.create_preposition_phrase(NLG.factory.create_noun_phrase('this', 'year'))
## end identical bit
inner.add_complement(comp)
modifiers = [:add_post_modifier, :add_front_modifier]
address_phrase.send(modifiers.sample, pp)
# SimplerNLG::NLG::Form::IMPERATIVE
inner.set_feature(NLG::Feature::FORM, SimplerNLG::NLG::Form::INFINITIVE)
address_phrase.add_complement(inner)
address_phrase.add_front_modifier("Democrats") # cue phrase
NLG.realizer.setCommaSepCuephrase(true)
sent = NLG.realizer.realise_sentence(address_phrase)
puts sent
#################
if_phrase = NLG.phrase({
:s => "you",
:number => :plural,
:v => 'hope',
:modal => "should",
:tense => :present,
})
## this bit should be identical to that used in the other generator.
bears = NLG.factory.create_noun_phrase('bear')
bears.set_feature SimplerNLG::NLG::Feature::NUMBER, SimplerNLG::NLG::NumberAgreement::PLURAL
comp = NLG.phrase({
:s => bears,
:v => 'kill',
:tense => :past,
:o => 'more than 10 people'
})
pp = NLG.factory.create_preposition_phrase(NLG.factory.create_noun_phrase('this', 'year'))
## end identical bit
if_phrase.add_complement(comp)
if_phrase.add_front_modifier("if you're a Democrat")
modifiers = [:add_post_modifier, :add_front_modifier]
if_phrase.send(modifiers.sample, pp)
NLG.realizer.setCommaSepCuephrase(true)
sent = NLG.realizer.realise_sentence(if_phrase)
puts sent
#############
imperative_phrase = NLG.phrase({
:number => :plural,
:v => ['hope', 'pray'].sample,
:tense => :present,
})
## this bit should be identical to that used in the other generator.
bears = NLG.factory.create_noun_phrase('bear')
bears.set_feature NLG::Feature::NUMBER, NLG::NumberAgreement::PLURAL
comp = NLG.phrase({
:s => bears,
:v => 'kill',
:tense => :past,
:o => 'more than 10 people'
})
pp = NLG.factory.create_preposition_phrase(NLG.factory.create_noun_phrase('this', 'year'))
## end identical bit
imperative_phrase.add_complement(comp)
modifiers = [:add_post_modifier, :add_front_modifier]
imperative_phrase.send(modifiers.sample, pp)
imperative_phrase.set_feature(NLG::Feature::FORM, SimplerNLG::NLG::Form::IMPERATIVE)
imperative_phrase.add_front_modifier("Democrats") # cue phrase
NLG.realizer.setCommaSepCuephrase(true)
sent = NLG.realizer.realise_sentence(imperative_phrase)
puts sent