def as_triples(self, slot_collection):
    """Print qualified triples for every slot filler."""
    # Collect inherited attributes attached to the entity.
    inherit = {}
    if self.inherit_props_from_entity:
      for slot in slot_collection.slot_list:
        if not isinstance(slot, sling.Frame):
          continue
        if slot.id in self.inherit_props_from_entity:
          inherit[slot] = slot_collection.value_lists[slot]

    triples = []
    for slot in slot_collection.slot_list:
      if not isinstance(slot, sling.Frame):
        continue
      if self.valid_slot(slot):
        values = slot_collection.value_lists[slot]
        if slot.id == INSTANCE_OF_ID and FLAGS.close_types_with_inheritance:
          values = self.transitively_close(values, SUBCLASS_OF_ID)
        if slot.id == LOCATED_IN_ID and FLAGS.close_locations_with_containment:
          values = self.transitively_close(values, LOCATED_IN_ID)
        for val in values:
          obj = self.get_object(slot, val)
          if self.valid_object(obj):
            if FLAGS.skip_qualifiers:
              if self.valid_slot_obj(obj, []):
                triples.append('\t'.join([
                    self.as_string(slot),
                    self.as_string(slot_collection.subject),
                    self.as_string(obj)]))
            else:
              quals = self.get_qualifiers(slot, val)
              # Original qualifiers.
              filtered_quals = []
              filtered_qrels = set()
              for (qrel, qval) in quals:
                if self.valid_object(qval):
                  filtered_qrels.add(qrel)
                  filtered_quals.append((qrel, qval))
              # Inherited qualifiers.
              inherited_quals = []
              if slot.id not in self.inherit_props_from_entity:
                for e_rel, e_vals in inherit.items():
                  if e_rel not in filtered_qrels:
                    for e_val in e_vals:
                      if self.valid_object(e_val):
                        inherited_quals.append((e_rel, e_val))
              if self.valid_slot_obj(obj, filtered_quals + inherited_quals):
                qual_string = '\t'.join([
                    '%s=%s' % (self.as_string(qrel), self.as_string(qval))
                    for qrel, qval in filtered_quals])
                if inherited_quals:
                  qual_string += '\t' + '\t'.join([
                      '%s*=%s' % (self.as_string(irel), self.as_string(ival))
                      for irel, ival in inherited_quals])
                triples.append('\t'.join([
                    self.as_string(slot),
                    self.as_string(slot_collection.subject),
                    self.as_string(obj),
                    qual_string]))
    return triples
Print qualified triples for every slot filler.
language/templama/sling2facts.py