def __init__(self, scene=None, speaker=None): self.scene = scene if scene is None: self.scene = Scene(3) # not a very furnished scene, we only have one table table = Landmark('table', RectangleRepresentation(rect=BoundingBox([Vec2(5,5), Vec2(6,7)])), None, ObjectClass.TABLE) self.scene.add_landmark(table) self.table = table self.table = self.scene.landmarks['table'] # there is a person standing at this location # he will be our reference if speaker is None: self.speaker = Speaker(Vec2(5.5, 4.5)) else: self.speaker = speaker # NOTE we need to keep around the list of landmarks so that we can # access them by id, which is the index of the landmark in this list # collect all possible landmarks self.landmarks = [] for scene_lmk in self.scene.landmarks.itervalues(): self.landmarks.append(scene_lmk) # a scene can be represented as a plane, line, etc # each representation of a scene has different landmarks rs = [scene_lmk.representation] rs.extend(scene_lmk.representation.get_alt_representations()) for r in rs: for lmk in r.get_landmarks(): self.landmarks.append(lmk) # FIXME we are using sentences with 1 or 2 LANDMARK-PHRASEs # so we need to restrict the landmarks to 0 or 1 ancestors self.landmarks = [l for l in self.landmarks if l.get_ancestor_count() < 2]