Esempio n. 1
0
    def caption(self, predication, world):
        if predication.num_agreeing == 0:
            return None

        entity = predication.random_agreeing_entity()

        if self.attribute == 'shape':
            attribute = Attribute(predtype='shape', value=entity.shape.name)

        elif self.attribute == 'color':
            attribute = Attribute(predtype='color', value=entity.color.name)

        elif self.attribute == 'texture':
            attribute = Attribute(predtype='texture',
                                  value=entity.texture.name)

        if predication.contradictory(predicate=attribute):
            assert False
        elif not self.pragmatical_redundancy and predication.num_entities > 1 and predication.redundant(
                predicate=attribute):
            return None

        attribute.apply_to_predication(predication=predication)

        return attribute
Esempio n. 2
0
    def caption(self, predication, world):
        if predication.num_agreeing == 0:
            return None

        values = list()
        for entity in predication.agreeing:
            if self.attribute == 'shape':
                values.append(entity.shape.name)
            elif self.attribute == 'color':
                values.append(entity.color.name)
            elif self.attribute == 'texture':
                values.append(entity.texture.name)

        value = choice(values)

        if self.attribute == 'shape':
            attribute = Attribute(predtype='shape', value=value)

        elif self.attribute == 'color':
            attribute = Attribute(predtype='color', value=value)

        elif self.attribute == 'texture':
            attribute = Attribute(predtype='texture', value=value)

        if predication.contradictory(predicate=attribute):
            assert False
        elif not self.pragmatical_redundancy and predication.num_entities > 1 and predication.redundant(predicate=attribute):
            assert False
            return None

        attribute.apply_to_predication(predication=predication)

        return attribute
Esempio n. 3
0
    def caption(self, predication, world):
        if predication.num_agreeing == 0:
            return None

        entity = choice(
            list(
                set((entity.shape.name, entity.color.name, entity.texture.name)
                    for entity in predication.agreeing)))
        # predication.random_agreeing_entity()

        if world.meta[self.label] == 'shape':
            attribute = Attribute(predtype='shape', value=entity[0])

        elif world.meta[self.label] == 'color':
            attribute = Attribute(predtype='color', value=entity[1])

        elif world.meta[self.label] == 'texture':
            attribute = Attribute(predtype='texture', value=entity[2])

        if predication.contradictory(predicate=attribute):
            assert False
        elif not self.pragmatical_redundancy and predication.num_entities > 1 and predication.redundant(
                predicate=attribute):
            assert False
            return None

        attribute.apply_to_predication(predication=predication)

        return attribute