def recount(tokens, world, discourse): 'Returns a report and a reply with narration of previous events.' reply_text = None if len(world.concept[discourse.spin['focalizer']].act) == 0: report_text = report('nothing_happened') else: report_text = report('recounting') concept = world.concept[discourse.spin['focalizer']] ids = concept.act.keys() ids.sort() start = ids[0] end = ids[-1] if len(tokens) >= 2: start = int(tokens[1]) if len(tokens) == 3: end = int(tokens[2]) recount_ids = [] current = start while current <= end: if current in concept.act: recount_ids.append(current) current = current + 1 original_time = discourse.spin['time'] discourse.spin['time'] = 'after' reply_plan = reply_planner.plan(recount_ids, concept, discourse) section = microplanner.specify(reply_plan, concept, discourse) reply_text = section.realize(concept, discourse) discourse.spin['time'] = original_time return (report_text, reply_text, world, discourse)
def teller(id_list, concept, discourse): 'Narrate actions based on the concept. Update the discourse.' reply_plan = reply_planner.plan(id_list, concept, discourse) section = microplanner.specify(reply_plan, concept, discourse) output = section.realize(concept, discourse) return output, discourse