|
@@ -1,4 +1,6 @@
|
|
|
import re
|
|
|
+import requests
|
|
|
+import json
|
|
|
from decimal import Decimal
|
|
|
from django.conf import settings
|
|
|
from .models import Staff
|
|
@@ -7,13 +9,15 @@ from review.models import Review
|
|
|
from facebook_app.models import FacebookReview, FacebookPage
|
|
|
from yelp.models import YelpReview, YelpLocation
|
|
|
|
|
|
-ner_model = getattr(settings, 'SPACY_NER_MODEL')
|
|
|
+ner_model_url = getattr(settings, 'NER_SERVER_URI')
|
|
|
|
|
|
|
|
|
def get_all_names(text):
|
|
|
- doc = ner_model(text)
|
|
|
- names = {ent.text for ent in doc.ents if ent.label_ in ['PERSON', 'ORG', 'PRODUCT']}
|
|
|
- return names
|
|
|
+ url = ner_model_url + '/names/all'
|
|
|
+ payload = {'text': text}
|
|
|
+ headers = {'content-type': 'application/json'}
|
|
|
+ res = requests.post(url, data=json.dumps(payload), headers=headers).json()
|
|
|
+ return res.get('names')
|
|
|
|
|
|
|
|
|
def all_staffs(location_id):
|