Exemplo n.º 1
0
def mainmodel_func(query,tok,module_tok,entity):
    top_intent = ''
    query = query.lower()
    if(re.search('verbal interpretation|numerical reasoning|spatial visualization|perceptual speed|verbal reasoning|capability [assessment|profile]',query)):
        top_intent = 'capability_module'
        print(top_intent)
        top_intent = capability_assessment_model(query,module_tok[3],entity)
    elif(re.search('emotional mindset|happiness|optimism|self esteem|self motivation|understading self and others|understanding self & others|understanding self|empathy|mastering self with others|assertiveness|influence|managing relationships|decision confidence|emotional expression|mastering self|stress managment|impulse control|emotional self control|bias managment|change managment',query)):
        top_intent = 'emotional assessment'
        top_intent = emotional_assessment_model(query,module_tok[4],entity)
    elif(re.search('stress |conscious persona| working enviroment|core persona| natural enviroment|flex|shift above|shift below|shifted above|shifted below|[change|changed][my|her|his|there|their]* behavior|[change|changed][ |my|her|his|there|their]* behaviour|[modified|modify] there|behavioral profile',query)):
        top_intent = 'Behavioral_Module'
        top_intent = behavioral_assessment_model(query,module_tok[2],entity)
    else:
        m = load_model("D:\\bot\\botapi\\botapi\\models\\Main\\Main_Model.h5")
        score = model_score_LSTM(query,tok,m)
        print(score)
        if((score[0][0]>score[0][1])&(score[0][0]>score[0][2])&(score[0][0]>score[0][3])&(score[0][0]>score[0][4])):
            top_intent = 'Behavioral_Module'
            top_intent = behavioral_assessment_model(query,module_tok[2],entity)
        elif((score[0][1]>score[0][0])&(score[0][1]>score[0][2])&(score[0][1]>score[0][3])&(score[0][1]>score[0][4])):
            top_intent = 'capability_module'
            print(top_intent)
            top_intent = capability_assessment_model(query,module_tok[3],entity)
        elif((score[0][2]>score[0][0])&(score[0][2]>score[0][1])&(score[0][2]>score[0][3])&(score[0][2]>score[0][4])):
            top_intent = 'emotional assessment'
            top_intent = emotional_assessment_model(query,module_tok[4],entity)
        elif((score[0][3]>score[0][0])&(score[0][3]>score[0][1])&(score[0][3]>score[0][2])&(score[0][3]>score[0][4])):
            top_intent = 'Leave'
            top_intent = leave_func(query,module_tok[0],entity)
        else:
            top_intent = 'Separation'
            top_intent = separation_func(query,module_tok[1],entity)
    return top_intent
Exemplo n.º 2
0
def leave_func(query, leave_entities, entities):
    top_intent = ''
    query = query.lower()
    m = load_model("D:\\bot\\botapi\\botapi\\models\\Leave\\Leave_Model.h5")
    score = model_score_LSTM(query, leave_entities[0], m)
    if ((score[0][0] > score[0][1]) & (score[0][0] > score[0][2]) &
        (score[0][0] > score[0][3])):
        Score = round(score[0][0] * 100, 2)
        top_intent = 'Leave_Request'
    elif ((score[0][1] > score[0][0]) & (score[0][1] > score[0][2]) &
          (score[0][1] > score[0][3])):
        top_intent = 'Leave_Approval'
        Score = round(score[0][1] * 100, 2)
        entities.append(leave_approval(query, leave_entities[2]))
        #print(leave_approval(query,leave_entities[2]))
    elif ((score[0][2] > score[0][0]) & (score[0][2] > score[0][1]) &
          (score[0][2] > score[0][3])):
        Score = round(score[0][2] * 100, 2)
        top_intent = "Leave_Request"
        leave_type = emotional_leave(query, leave_entities[1])
        if leave_type not in entities:
            entities.append(leave_type)
    else:
        Score = round(score[0][3] * 100, 2)
        top_intent = 'Leave_Inquiry'
    Score = str(Score)
    return ('{"TopIntent": "' + top_intent + '", "Percentage":' + Score,
            entities)
Exemplo n.º 3
0
def quantity_module(name, tok_quantity):
    sub_intent = ''
    m = load_model(
        'D:\\bot\\botapi\\botapi\\models\\Quantity\\Quantity_Model.h5')
    score = model_score_LSTM(name, tok_quantity, m)
    if (score[0][0] > score[0][1]):
        sub_intent = sub_intent + "A"
    else:
        sub_intent = sub_intent + "P"
    return sub_intent
Exemplo n.º 4
0
def separation_func(query, separation_entities, entities):
    sub_intent = ''
    query = query.lower()
    m = load_model("D:\\bot\\botapi\\botapi\\models\\Separation\\Sepration.h5")
    score = model_score_LSTM(query, separation_entities[0], m)
    if ((score[0][0] > score[0][1]) & (score[0][0] > score[0][2]) &
        (score[0][0] > score[0][3]) & (score[0][0] > score[0][4]) &
        (score[0][0] > score[0][5])):
        sub_intent = "Blacklist Employees"
        Score = round(score[0][0] * 100, 2)
    elif ((score[0][1] > score[0][0]) & (score[0][1] > score[0][2]) &
          (score[0][1] > score[0][3]) & (score[0][1] > score[0][4]) &
          (score[0][1] > score[0][5])):
        sub_intent = "Exit Clearance "
        #status = exit_clearance_module(name)
        #entities.append('"Status:""'+status+'"')
        Score = round(score[0][1] * 100, 2)
    elif ((score[0][2] > score[0][0]) & (score[0][2] > score[0][1]) &
          (score[0][2] > score[0][3]) & (score[0][2] > score[0][4]) &
          (score[0][2] > score[0][5])):
        sub_intent = "Exit interview "
        #status = exit_interview_module(name)
        #entities.append('"Status:""'+status+'"')
        Score = round(score[0][2] * 100, 2)
    elif ((score[0][3] > score[0][0]) & (score[0][3] > score[0][1]) &
          (score[0][3] > score[0][2]) & (score[0][3] > score[0][4]) &
          (score[0][3] > score[0][5])):
        sub_intent = "Exit Survey "  #+
        #entities.append('"Status:""'+status+'"')
        #status = exit_survey_module(name)
        Score = round(score[0][3] * 100, 2)
    elif ((score[0][4] > score[0][0]) & (score[0][4] > score[0][1]) &
          (score[0][4] > score[0][2]) & (score[0][4] > score[0][3]) &
          (score[0][4] > score[0][5])):
        sub_intent = "Notice Period "
        #entities.append('"Status:""'+status+'"')
        #status = notice_period_module(name)
        Score = round(score[0][4] * 100, 2)
    else:
        sub_intent = "Resignation"  #+ resignation(name)
        Score = round(score[0][5] * 100, 2)
    Score = str(Score)
    return ('{"TopIntent": "' + sub_intent + '", "Percentage":' + Score,
            entities)
Exemplo n.º 5
0
def emotional_assessment_model(query, EA_tok, entity):
    report_check = 0
    graph_check = 0
    score_check = 0
    top_intent = '"Assessment"'
    sub_intent = '"Emotional_Assessment"'
    Score = '100'
    if (re.search(
            'emotional mindset|happiness|optimism|(self( |-)esteem)|(self( |-)motivation)',
            query)):
        entity = emotional_mindset_func(query, EA_tok[1], entity)
    elif (re.search(
            '(understanding self (&|and) other)|understanding self|empathy',
            query)):
        entity = understanding_self_and_others_func(query, EA_tok[2], entity)
    elif (re.search(
            'mastering self with other|assertiveness|influence|managing relationship|decision confidence|emotional expression',
            query)):
        entity = mastering_self_with_others(query, EA_tok[3], entity)
    elif (re.search(
            'mastering self|stress managment|impulse control|emotional self control|bias managment|change managment',
            query)):
        entity = mastering_self_func(query, EA_tok[4], entity)
    elif (re.search('(emotional (assessment|intelligence|profile))|eq',
                    query)):
        entity.append('"Status": "Emotional_Assessment"')
    else:
        m = load_model(
            'D:\\bot\\botapi\\botapi\\models\\Emotional_Assessment\\Emotional_main.h5'
        )
        score = model_score_LSTM(query, EA_tok[0], m)
        if ((score[0][0] > score[0][1]) & (score[0][0] > score[0][2]) &
            (score[0][0] > score[0][3]) & (score[0][0] > score[0][4])):
            entity = mastering_self_func(query, EA_tok[4], entity)
        elif ((score[0][1] > score[0][0]) & (score[0][1] > score[0][2]) &
              (score[0][1] > score[0][3]) & (score[0][1] > score[0][4])):
            entity = mastering_self_with_others(query, EA_tok[3], entity)
        elif ((score[0][2] > score[0][0]) & (score[0][2] > score[0][1]) &
              (score[0][2] > score[0][3]) & (score[0][2] > score[0][4])):
            entity = understanding_self_and_others_func(
                query, EA_tok[2], entity)
        elif ((score[0][3] > score[0][0]) & (score[0][3] > score[0][1]) &
              (score[0][3] > score[0][2]) & (score[0][3] > score[0][4])):
            entity = emotional_mindset_func(query, EA_tok[1], entity)
        else:
            entity.append('"Status": "Emotional_Assessment"')
    intent = overall(query, EA_tok[5])
    print(intent)
    if 'Report' in intent:
        report_check = 1
        entity.append('"Report":"1"')
    if 'Score' in intent:
        score_check = 1
        entity = main_entity(query, entity)
    if 'Graph' in intent:
        graph_check = 1
        entity.append('"Graph":"1"')
    if (score_check == 0):
        entity.append('"Percentile" : "0"')
        entity.append('"Intensity" : "0"')
    if (graph_check == 0):
        entity.append('"Graph":"0"')
    if (report_check == 0):
        entity.append('"Report":"0"')

    return ('{"TopIntent": ' + top_intent + ', "SubIntent": ' + sub_intent +
            ', "Percentage":' + Score, entity)