Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
24 lines (19 sloc) 562 Bytes
from flask import Flask, request, jsonify
import spacy
app = Flask(__name__)
NLP = spacy.load('en')
@app.route('/ner', methods=['POST'])
def ner():
data = request.form.get('text')
entities = []
if data:
for ent in NLP(data).ents:
entities.append({
'text': ent.text,
'label': ent.label_,
'start': ent.start_char,
'stop': ent.end_char
})
response = jsonify(entities)
response.headers.add('Access-Control-Allow-Origin', '*')
return response