-
Notifications
You must be signed in to change notification settings - Fork 2
/
exhortation_mockup.rb
106 lines (80 loc) · 2.88 KB
/
exhortation_mockup.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
case [:you, :if, :imperative].sample # removed :bare because it sucks
when :you
phrase = NLG.phrase({
:s => "you",
:number => :plural,
:v => 'need',
:tense => :present,
})
inner = NLG.phrase({
:v => "hope"
})
inner.add_complement(@data_phrase)
party_np = NLG.factory.create_noun_phrase(party_member_name)
party_np.set_feature(NLG::Feature::NUMBER, NLG::NumberAgreement::PLURAL)
phrase.add_front_modifier(party_np) # cue phrase
modifiers = [:add_post_modifier, :add_front_modifier]
phrase.send(modifiers.sample, pp)
inner.set_feature(NLG::Feature::FORM, NLG::Form::INFINITIVE)
phrase.add_complement(inner)
NLG.realizer.setCommaSepCuephrase(true)
when :if
phrase = NLG.phrase({
:s => "you",
:number => :plural,
:v => 'hope',
:modal => "should",
:tense => :present,
})
phrase.add_complement(@data_phrase)
phrase.add_front_modifier("if you're a " + party_member_name)
modifiers = [:add_post_modifier, :add_front_modifier]
phrase.send(modifiers.sample, pp)
NLG.realizer.setCommaSepCuephrase(true)
when :imperative
phrase = NLG.phrase({
:number => :plural,
:v => ['hope', 'pray'].sample,
:tense => :present,
})
phrase.add_complement(@data_phrase)
modifiers = [:add_post_modifier, :add_front_modifier]
phrase.send(modifiers.sample, pp)
phrase.set_feature(NLG::Feature::FORM, NLG::Form::IMPERATIVE)
np = NLG.factory.create_noun_phrase(party_member_name)
np.set_feature(NLG::Feature::NUMBER, NLG::NumberAgreement::PLURAL)
phrase.add_front_modifier( np ) # cue phrase
NLG.realizer.setCommaSepCuephrase(true)
end
party_member_name, claim_polarity = *[[@prediction_meta[:party].member_name, @prediction_meta[:claim_polarity]], [@prediction_meta[:party].member_name.downcase.include?("democrat") ? "Republican" : "Democrat", !@prediction_meta[:claim_polarity]]].sample
phrase = {
:s => "you",
:number => :plural,
:v => 'need',j
:tense => :present,# TODO can be other stuff too
:complements => [
{
:v => "hope",
:complements => [
@data_phrase.merge({
tense: :present,
complementiser: 'that',
negated: @prediction_meta[:politics_condition].control ? !claim_polarity : claim_polarity
})
],
:pp => [
{
:determiner => 'this',
:rest => 'year',
:exclude_positions => [:pre]
}
]
}
]
}
party_np = NLG.factory.create_noun_phrase(party_member_name)
party_np.set_feature(NLG::Feature::NUMBER, NLG::NumberAgreement::PLURAL)
phrase.add_front_modifier(party_np) # cue phrase
inner.set_feature(NLG::Feature::FORM, NLG::Form::INFINITIVE)
phrase.add_complement(inner)
NLG.realizer.setCommaSepCuephrase(true)