Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
2.1 kB
1
Indexable
Never
Text -32 application hcm opm talent profile application data error employee hired chroma recruitment module however org related details captured profile master report well please check fix priorityemployee code employee name nithin r 983 l2 support Roshni Gangrade

This is the input text and we are getting output as this below-

['32', '983', 'Roshni Gangrade', 'application hcm opm talent profile application data error employee hired chroma recruitment module however org related details captured profile master report well please check fix priorityemployee code employee name nithin r 983 l2 support']

All we need is this output as - [983 ,'Roshni Gangrade','l2 support']

def extract_combined_info(text):
    words = text.split()
    info = []
    current_info = []

    for word in words:
        if word.isnumeric():
            current_info.append(word)
        elif word[0].isupper() and current_info:
            current_name = ' '.join(words[words.index(word):])
            info.append(current_info + [current_name])
            current_info = []

    return info

def extract_role_name(text):
    role_name = re.findall(r'\d+\s+([\w\s]+?)\s+[A-Z]', text)
    return role_name

def event_prediction(input_tenant_id,input_ticket_category, input_ticket_type, input_ticket_item, input_ticket_summary, input_ticket_desc):
    try:
        user_recommendation_list_tfidf = event_prediction_tfidf(input_tenant_id,input_ticket_category, input_ticket_type, input_ticket_item, input_ticket_summary, input_ticket_desc)
        print("TFIDF Prediction Done", user_recommendation_list_tfidf)

        user_recommendation_info = []
        for res in user_recommendation_list_tfidf:
            info = extract_combined_info(res)
            role_name = extract_role_name(res)
            if info:
                info[0].append(role_name[0] if role_name else None)
                user_recommendation_info.append(info[0])
        
        return user_recommendation_info
    
    except:
        user_recommendation_list = []
        return user_recommendation_list