

@factory.post_generation
def e_occurrences(self, create, extracted, **kwargs):
    doc = self.segment.document
    for (eotokens, offset, kind_name) in extracted:
        alias = ' '.join(eotokens)
        EntityOccurrenceFactory(entity__kind__name=kind_name, entity__key=alias, alias=alias, document=doc, offset=offset, offset_end=(offset + len(eotokens)))
    self.segment.entity_occurrences = doc.entity_occurrences.filter(offset__gte=self.segment.offset, offset_end__lte=self.segment.offset_end)

dataset/ETHPy150Open machinalis/iepy/tests/factories.py EvidenceFactory.e_occurrences/original