def fill_with(agent, tokens, _): 'to make full with a substance; to supply with as much as can be contained' [new_parent, substance] = tokens[1:3] return Configure('fill', agent, template='[agent/s] [fill/v] [indirect/o] with ' + '[direct/o]', direct=substance, new=('in', new_parent))
def give(agent, tokens, concept): 'to yield possession of; to deliver over, as property' to_be_given = check_for_metonymy(tokens[1], concept) return Configure('give', agent, template='[agent/s] [give/v] [direct/o] to [indirect/o]', direct=to_be_given, old=('of', agent), new=('of', tokens[2]))
def fill_with_from(agent, tokens, _): 'to make full with a substance from a source or vessel' [vessel, substance, source] = tokens[1:4] return Configure('fill', agent, template='[agent/s] [fill/v] [indirect/o] with ' + '[direct/o] from [' + source + '/o]', direct=substance, old=('in', source), new=('in', vessel))
def throw(agent, tokens, concept): 'to fling, cast, or hurl with a certain whirling motion of the arm' item = concept.item[tokens[1]] new_place = str(concept.room_of(agent)) return Configure('throw', agent, template='[agent/s] [toss/v] [direct/s] up', direct=tokens[1], old=(item.link, item.parent), new=('through', new_place))
def enter(agent, tokens, concept): 'to go into something, such as a compartment or door' link = 'in' if concept.item[tokens[1]].door: link = 'through' return Configure('enter', agent, template='[agent/s] [enter/v] [indirect/o]', direct=agent, new=(link, tokens[1]))
def drop(agent, tokens, concept): 'to let go; to set aside; to have done with; to let fall to the ground' to_be_dropped = check_for_metonymy(tokens[1], concept) room = str(concept.room_of(to_be_dropped)) return Configure('drop', agent, template=['[agent/s] [relinquish/v] [direct/o]', '[agent/s] [set/v] [direct/o] down'], direct=to_be_dropped, new=('in', room))
def fill_from(agent, tokens, concept): 'to make full from a source or vessel' [vessel, source] = tokens[1:3] if len(concept.item[source].children) > 0: (_, direct) = concept.item[source].children[0] else: direct = '@cosmos' return Configure('fill', agent, template='[agent/s] [fill/v] [indirect/o] from [' + source + '/o]', direct=direct, old=('in', source), new=('in', vessel))
def leave_from(agent, tokens, concept): 'to bring oneself out of some location' link = 'in' if (tokens[1] in concept.item and concept.item[tokens[1]] == concept.item[agent].parent): link = concept.item[agent].link room_tag = str(concept.room_of(agent)) template = '[agent/s] [get/v] out of [' + tokens[1] + '/o]' return Configure('depart', agent, template=template, direct=agent, old=(link, tokens[1]), new=('in', room_tag))
def free_from(agent, tokens, concept): 'to bring out from some specified compartment' [direct, container] = tokens[1:3] link = 'in' if (container in concept.item and concept.item[container] == concept.item[direct].parent): link = concept.item[direct].link room_tag = str(concept.room_of(agent)) template = '[agent/s] [free/v] [direct/o] from [' + container + '/o]' return Configure('free', agent, template=template, direct=direct, old=(link, container), new=('in', room_tag))
def remove_from(agent, tokens, concept): 'to bring out of some location' [direct, container] = tokens[1:3] if (direct == agent): return free_from(agent, tokens, concept) link = 'in' if (container in concept.item and concept.item[container] == concept.item[direct].parent): link = concept.item[direct].link template = '[agent/s] [remove/v] [direct/o] from [' + container + '/o]' return Configure('remove', agent, template=template, direct=direct, old=(link, container), new=('of', agent))
from item_model import Actor, Room, Thing from action_model import Behave, Configure, Sense import can discourse = { 'metadata': { 'title': 'The Simulated Bank Robbery'}, 'spin': {'commanded': '@robber', 'focalizer': '@robber', 'narratee': None, 'time_words': False, 'room_name_headings': False}} READ_SLIPS = Behave('read', '@teller', direct='@slips') SNOOZE = Behave('snooze', '@guard', template='[agent/s] [snooze/ing/v]') COUNT_SLIPS = Behave('count', '@teller', direct='@slips') DON_MASK = Configure('wear', '@robber', direct='@mask', new=('on', '@robber'), template='[agent/s] [put/v] on [direct/o]') TYPE = Behave('type', '@teller') PLAY = Behave('play', '@teller', template="[agent/s] [play/v] Solitaire a bit on [agent's] computer") ROBBER_TO_LOBBY = Behave('leave', '@robber', template='[agent/s] [leave/v] the street', direct='@robber', direction='in') WAVE = Behave('wave', '@teller', target='@robber', template='[agent/s] [wave/v] to [direct/o]') BRANDISH = Behave('brandish', '@robber', target='@teller', indirect='@fake_gun', template='[agent/s] [brandish/v] [indirect/o] at [direct/o]') LAUGH = Behave('laugh', '@teller') WAKE = Behave('wake', '@guard') SEE_ROBBER = Sense('see', '@guard', direct='@robber', modality='sight') GUARD_TO_LOBBY = Behave('leave', '@guard', template='[agent/s] [leave/v] the guard post',
def feed(agent, tokens, _): 'to give food to; to supply with nourishment' return Configure('feed', agent, template='[agent/s] [feed/v] [direct/o] to [indirect/s]', direct=tokens[1], old=('of', agent), new=('of', tokens[2]))
def doff(agent, tokens, _): 'to strip; to divest; to undress' return Configure('doff', agent, template='[agent/s] [take/v] off [direct/o]', direct=tokens[1], old=('on', agent), new=('of', agent))
def wear(agent, tokens, _): 'to carry or bear upon the person, as an article of clothing, etc.' return Configure('wear', agent, template='[agent/s] [put/v] [direct/o] on', direct=tokens[1], old=('of', agent), new=('on', agent))
def take(agent, tokens, concept): "to get into one's hold or possession; to procure; to seize and carry away" to_be_taken = check_for_metonymy(tokens[1], concept) return Configure('take', agent, template='[agent/s] [pick/v] [direct/o] up', direct=to_be_taken, new=('of', agent))
def put_on(agent, tokens, _): 'to bring to a position or place; to place; to lay; to set' return Configure('put', agent, template='[agent/s] [put/v] [direct/o] on [indirect/o]', direct=tokens[1], new=('on', tokens[2]))
def pour_on_from(agent, tokens, _): 'to cause a substance to flow from somewhere onto something' [substance, source, vessel] = tokens[1:4] return Configure('pour', agent, template='[agent/s] [pour/v] [direct/o] onto [indirect/o]', direct=substance, old=('in', source), new=('on', vessel))
def pour_on(agent, tokens, _): 'to cause a substance to flow in a stream onto something' [substance, vessel] = tokens[1:3] return Configure('pour', agent, template='[agent/s] [pour/v] [direct/o] onto [indirect/o]', direct=substance, new=('on', vessel))