def interlinguish_tell_verb1_operation(self, op, say): """Handle a sentence of the form 'Tell (me) ....' Accept queries about what we know. Mostly this is for debugging and for the time being it is useful to answer these queries no matter who hasks.""" # Currently no checking for trus here. # We are being liberal with interpretation of "subject" and "object" subject=say[1].word predicate=say[2].word object=say[3].word k=self.get_knowledge(predicate, object) if k==None: pass # return Operation('talk',Entity(say="I know nothing about the "+predicate+" of "+object)) else: k_type = type(k) if k_type==type(Location()): dist = distance_to(self.location, k) dist.z = 0 distmag = dist.mag() if distmag < 8: k = 'right here' else: # Currently this assumes dist is relative to TLVE k='%f metres %s' % (distmag, vector_to_compass(dist)) elif k_type!=StringType: k='difficult to explain' elif predicate=='about': return Operation('talk', Entity(say=k)) + \ self.face(self.map.get(op.to)) return Operation('talk', Entity(say="The " + predicate + " of " + object + " is " + k)) + \ self.face(self.map.get(op.to))
def interlinguish_tell_verb1_operation(self, op, say): """Handle a sentence of the form 'Tell (me) ....' Accept queries about what we know. Mostly this is for debugging and for the time being it is useful to answer these queries no matter who asks.""" # Ignore messages addressed to others if not self.is_talk_op_addressed_to_me_or_none(op): return None # Currently no checking for trus here. # We are being liberal with interpretation of "subject" and "object" word_subject = say[1].word word_predicate = say[2].word word_object = say[3].word k = self.get_knowledge(word_predicate, word_object) if k is None: pass # return Operation('talk',Entity(say="I know nothing about the "+predicate+" of "+object)) else: k_type = type(k) if isinstance(k_type, Location): dist = self.steering.direction_to(k) dist.y = 0 distmag = dist.mag() if distmag < 8: k = 'right here' else: # Currently this assumes dist is relative to TLVE k = '%f metres %s' % (distmag, vector_to_compass(dist)) elif k_type != str: k = 'difficult to explain' elif word_predicate == 'about': return self.face_and_address(op.to, k) return self.face_and_address( op.to, "The " + word_predicate + " of " + word_object + " is " + k)