|
@@ -4,6 +4,7 @@ import requests
|
|
|
from difflib import SequenceMatcher
|
|
|
from django.utils import timezone
|
|
|
from django.conf import settings
|
|
|
+from nlu_job.nlu_utils import clean_text
|
|
|
|
|
|
from .models import Review, CustomReply
|
|
|
|
|
@@ -14,17 +15,18 @@ replies = CustomReply.objects.all()
|
|
|
|
|
|
|
|
|
def model_inference(text):
|
|
|
- url = nlu_server_url + '/model/parse'
|
|
|
+ url = nlu_server_url + '/predict'
|
|
|
+ text = clean_text(text)
|
|
|
payload = {'text': text}
|
|
|
headers = {'content-type': 'application/json'}
|
|
|
response = requests.post(url, data=json.dumps(payload), headers=headers)
|
|
|
if response.status_code == 200:
|
|
|
res = response.json()
|
|
|
- intents_rankings = res.get('intent_ranking')
|
|
|
+ res_intents = res.get('response').get('intents')
|
|
|
intents = []
|
|
|
- for intent in intents_rankings:
|
|
|
- if intent.get('confidence') > 0.3:
|
|
|
- intents.append(intent['name'])
|
|
|
+ for k, v in res_intents:
|
|
|
+ if v <= 0.3:
|
|
|
+ intents.append(k)
|
|
|
return intents
|
|
|
|
|
|
|