Esempio n. 1
0
def pnr(request):
    """This functionality calls the get_pnr() functionality to detect pnr. It is called through api call

    Attributes:
        request: url parameters

    """
    try:
        parameters_dict = get_parameters_dictionary(request)
        ner_logger.debug('Start: %s ' % parameters_dict[PARAMETER_ENTITY_NAME])
        entity_output = get_pnr(parameters_dict[PARAMETER_MESSAGE], parameters_dict[PARAMETER_ENTITY_NAME],
                                parameters_dict[PARAMETER_STRUCTURED_VALUE],
                                parameters_dict[PARAMETER_FALLBACK_VALUE],
                                parameters_dict[PARAMETER_BOT_MESSAGE])
        ner_logger.debug('Finished %s : %s ' % (parameters_dict[PARAMETER_ENTITY_NAME], entity_output))
    except TypeError, e:
        ner_logger.debug('Exception for pnr: %s ' % e)
        return HttpResponse(status=400)
Esempio n. 2
0
def pnr(request):
    """This functionality calls the get_pnr() functionality to detect pnr. It is called through api call

    Attributes:
        request: url parameters

    """
    try:
        parameters_dict = parse_parameters_from_request(request)
        entity_output = get_pnr(parameters_dict[PARAMETER_MESSAGE], parameters_dict[PARAMETER_ENTITY_NAME],
                                parameters_dict[PARAMETER_STRUCTURED_VALUE],
                                parameters_dict[PARAMETER_FALLBACK_VALUE],
                                parameters_dict[PARAMETER_BOT_MESSAGE])
        ner_logger.debug('Finished %s : %s ' % (parameters_dict[PARAMETER_ENTITY_NAME], entity_output))
    except TypeError as e:
        ner_logger.exception('Exception for pnr: %s ' % e)
        return HttpResponse(status=500)

    return HttpResponse(json.dumps({'data': entity_output}), content_type='application/json')