How to use the alephclient.services.entityextract_pb2.ExtractedEntity function in alephclient

To help you get started, we’ve selected a few alephclient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alephdata / aleph / services / extract-entities / entityextractor / service.py View on Github external
def extract_spacy(self, text):
        try:
            doc = self.spacy(text)
            for ent in doc.ents:
                type_ = SPACY_TYPES.get(ent.label_)
                label = ent.text.strip()
                if type_ is not None and len(label):
                    entity = ExtractedEntity()
                    entity.text = label
                    entity.type = type_
                    entity.start = ent.start
                    entity.end = ent.end
                    yield entity
        except Exception:
            log.exception("spaCy failed")
github alephdata / aleph / services / extract-entities / entityextractor / service.py View on Github external
def make_entity(self, text, type_, start, end):
        entity = ExtractedEntity()
        entity.text = text
        entity.type = type_
        entity.start = start
        entity.end = end
        return entity