Ejemplo n.º 1
0
 def __str__(self):
     if self.instances:
         return "{}".format(english.join(self.instances))
     elif self.noun:
         return "the {}".format(self.noun.plural)
     elif self.pronoun:
         return "{}".format(self.pronoun)
     else:
         return "(anonymous group of instances #{})".format(self.id)
Ejemplo n.º 2
0
    def text(self, argument: Argument) -> str:
        conditions = find_conditions(self, argument)
        
        # Special condition: something can fly if it is a bird -> birds can fly
        if len(conditions) == 1:
            (condition,) = conditions
            if self.subject == condition.subject \
                and condition.verb is not None \
                and condition.verb.literal in ('is', 'are') \
                and isinstance(condition.object, Prototype):
                return "{a!s} {verb!s} {b!s}".format(a=condition.object.text(argument), verb=self.verb, b=self.object.text(argument))

        return "{} {} {}".format(
            super().text(argument),
            self.conj if self.conj is not None else "if",
            english.join([claim.text(argument) for claim in sorted(conditions, key=lambda condition: condition.id)]))
Ejemplo n.º 3
0
 def __str__(self):
     return super().__str__() + ' if ' + english.join(self.conditions)
Ejemplo n.º 4
0
 def __str__(self):
     return "{target!s} {conj} {sources}".format(
         target=self.target,
         conj='because' if self.type == self.SUPPORT else 'except',
         sources=english.join(self.sources))