def response(request): data = data = json.loads(request.body.decode("utf-8")) user_msg = data["text"] intend = adapterIntend.get_intend(user_msg) print(intend) # return intend if manager.getState(request) == 1: if intend == 1: data = adapterGreeting.make_response(user_msg) elif intend == 2: data = adapterNer.detect_entity(user_msg) elif intend == 3: data = adapterNer.detect_entity(user_msg) else: data = None return make_msg(request, data, intend) elif manager.getState(request) == 2: if intend == 1: data = adapterGreeting.make_response(user_msg) elif intend == 2: data = adapterNer.detect_entity(user_msg) elif intend == 3: data = adapterNer.detect_entity(user_msg) else: data = adapterNer.detect_entity(user_msg) return make_msg(request, data, intend) elif manager.getState(request) == 3: data = adapterNer.detect_entity(user_msg) if adapterNer.detect_question_again(user_msg): data = adapterNer.detect_entity(user_msg) print("Hihhi", data) return make_msg(request, data, intend) else: manager.updateState(request, 1) manager.updateTime(request, None) manager.updateLoc(request, None) if intend == 1: data = adapterGreeting.make_response(user_msg) elif intend == 2: data = adapterNer.detect_entity(user_msg) elif intend == 3: data = adapterNer.detect_entity(user_msg) else: data = None return make_msg(request, data, intend)
def response_no_accent(user_msg): intend = adapterIntend.get_intend(user_msg) data = adapterNerCrf.detect_entity(user_msg) print(data) # return intend if session['bot_state'] == 1: if intend == 1: data = adapterGreeting.make_response(user_msg) elif intend == 2: data = adapterNerCrf.detect_entity(user_msg) elif intend == 3: data = adapterNerCrf.detect_entity(user_msg) else: data = None return make_msg(data, intend) elif session['bot_state'] == 2: if intend == 1: data = adapterGreeting.make_response(user_msg) elif intend == 2: data = adapterNerCrf.detect_entity(user_msg) elif intend == 3: data = adapterNerCrf.detect_entity(user_msg) else: data = adapterNerCrf.detect_entity(user_msg) return make_msg(data, intend) elif session['bot_state'] == 3: data = adapterNerCrf.detect_entity(user_msg) if adapterNerCrf.detect_question_again(user_msg): data = adapterNerCrf.detect_entity(user_msg) return make_msg(data, intend) # elif data['LOC'] != [] or data['TIME'] != [] or data['WEATHER'] != []: # return make_msg(data, intend) else: session['bot_state'] = 1 session['time'] = None session['loc'] = None if intend == 1: data = adapterGreeting.make_response(user_msg) elif intend == 2: data = adapterNerCrf.detect_entity(user_msg) elif intend == 3: data = adapterNerCrf.detect_entity(user_msg) else: data = None return make_msg(data, intend)