How to use spacy-annotator - 4 common examples

To help you get started, we’ve selected a few spacy-annotator 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 explosion / spacy-dev-resources / spacy-annotator / displacy / server.py View on Github external
def on_post(self, req, resp):
        req_body = req.stream.read()
        json_data = json.loads(req_body.decode('utf8'))
        paragraphs = json_data.get('paragraphs')
        model_name = json_data.get('model', 'en')
        try:
            model = get_model(model_name)
            entities = []
            for p in paragraphs:
                e = Entities(model, p.get('text'))
                entities.append(e.to_json())
            resp.body = json.dumps(entities, sort_keys=True, indent=2)
            resp.content_type = 'application/json'
            resp.status = falcon.HTTP_200
        except Exception:
            resp.status = falcon.HTTP_500
github explosion / spacy-dev-resources / spacy-annotator / displacy / server.py View on Github external
def on_post(self, req, resp):
        req_body = req.stream.read()
        json_data = json.loads(req_body.decode('utf8'))
        paragraphs = json_data.get('paragraphs')
        model_name = json_data.get('model', 'en')
        try:
            model = get_model(model_name)
            texts = [paragraph.get('text') for paragraph in paragraphs]
            update_vocabulary(model, texts)
            entities = []
            for p in paragraphs:
                e = TrainEntities(model, p.get('text'), p.get('tags'))
                entities.append(e.to_json())
            resp.body = json.dumps(entities, sort_keys=True, indent=2)
            resp.content_type = 'application/json'
            resp.status = falcon.HTTP_200
        except Exception:
            print("Unexpected error:", sys.exc_info()[0])
            resp.status = falcon.HTTP_500
github explosion / spacy-dev-resources / spacy-annotator / displacy / server.py View on Github external
texts = [paragraph.get('text') for paragraph in paragraphs]
            update_vocabulary(model, texts)
            entities = []
            for p in paragraphs:
                e = TrainEntities(model, p.get('text'), p.get('tags'))
                entities.append(e.to_json())
            resp.body = json.dumps(entities, sort_keys=True, indent=2)
            resp.content_type = 'application/json'
            resp.status = falcon.HTTP_200
        except Exception:
            print("Unexpected error:", sys.exc_info()[0])
            resp.status = falcon.HTTP_500

cors = CORS(allow_all_origins=True)
APP = falcon.API(middleware=[cors.middleware])
APP.add_route('/ent', EntResource())
APP.add_route('/train', TrainEntResource())
github explosion / spacy-dev-resources / spacy-annotator / displacy / server.py View on Github external
update_vocabulary(model, texts)
            entities = []
            for p in paragraphs:
                e = TrainEntities(model, p.get('text'), p.get('tags'))
                entities.append(e.to_json())
            resp.body = json.dumps(entities, sort_keys=True, indent=2)
            resp.content_type = 'application/json'
            resp.status = falcon.HTTP_200
        except Exception:
            print("Unexpected error:", sys.exc_info()[0])
            resp.status = falcon.HTTP_500

cors = CORS(allow_all_origins=True)
APP = falcon.API(middleware=[cors.middleware])
APP.add_route('/ent', EntResource())
APP.add_route('/train', TrainEntResource())

spacy-annotator

SpaCy annotator for Named Entity Recognition (NER) using ipywidgets.

MIT
Latest version published 22 days ago

Package Health Score

60 / 100
Full package analysis