19 | 19 |
def __init__(self, phrase, participants, excl=False,
|
20 | 20 |
previous_location=None,
|
21 | 21 |
speaker=None,
|
22 | |
addressed_to=None):
|
|
22 |
addressed_to=None,
|
|
23 |
exciting=False):
|
23 | 24 |
"""participants[0] is always the initiator, and we
|
24 | 25 |
record the location that the event was initiated in.
|
25 | 26 |
|
|
46 | 47 |
self.excl = excl
|
47 | 48 |
self.speaker = speaker
|
48 | 49 |
self.addressed_to = addressed_to
|
|
50 |
self.exciting = exciting
|
49 | 51 |
|
50 | 52 |
def rephrase(self, new_phrase):
|
51 | 53 |
"""Does not modify the event. Returns a new copy."""
|
|
175 | 177 |
# maps main characters to where the reader last saw them
|
176 | 178 |
self.last_seen_at = {}
|
177 | 179 |
self.transformers = []
|
|
180 |
# maps characters to things that happened to them while not narrated
|
|
181 |
self.exciting_developments = {}
|
178 | 182 |
|
179 | 183 |
def add_transformer(self, transformer):
|
180 | 184 |
self.transformers.append(transformer)
|
|
201 | 205 |
# this is the first sentence of the paragraph
|
202 | 206 |
# if the reader wasn't aware they were here, add an event
|
203 | 207 |
if self.last_seen_at.get(pov_actor, None) != event.location:
|
204 | |
if not (('went to' in event.phrase) or ('made <his-1> way to' in event.phrase) or (event.phrase == '<1> <was-1> in <2>')):
|
|
208 |
if not (('went to' in event.phrase) or
|
|
209 |
('made <his-1> way to' in event.phrase) or
|
|
210 |
(event.phrase == '<1> <was-1> in <2>')):
|
205 | 211 |
paragraph_events.append(Event('<1> <was-1> in <2>', [pov_actor, event.location]))
|
|
212 |
# if something exciting happened, tell the reader
|
|
213 |
for (obj, loc) in self.exciting_developments.get(pov_actor, []):
|
|
214 |
paragraph_events.append(Event('<1> had found <2> in <3>', [pov_actor, obj, loc]))
|
|
215 |
self.exciting_developments[pov_actor] = []
|
206 | 216 |
|
207 | 217 |
# update our idea of where the character is, even if these are
|
208 | 218 |
# not events we will be dumping out
|
|
212 | 222 |
paragraph_events.append(event)
|
213 | 223 |
# update the reader's idea of where the character is
|
214 | 224 |
self.last_seen_at[event.initiator()] = event.location
|
|
225 |
else:
|
|
226 |
if event.exciting:
|
|
227 |
self.exciting_developments.setdefault(event.initiator(), []).append(
|
|
228 |
(event.participants[1], event.participants[2])
|
|
229 |
)
|
215 | 230 |
|
216 | 231 |
return paragraph_events
|
217 | 232 |
|