Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.9 kB
1
Indexable
Never
Code-

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 process_text(text):
    # Remove leading numbers using regular expression
    trimmed_text = re.sub(r'^\d+\s*', '', text)
    return trimmed_text

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 = process_text(res)
            info = extract_combined_info(info)
            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


Output I am getting is-

['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 i want is just-

['983', 'Roshni Gangrade', 'l2 support']