This is the code for extracting the name -
def extract_names(text):
words = text.split()
names = []
current_name = ""
for word in words:
if word[0].isupper():
if current_name:
current_name += " " + word
else:
current_name = word
elif current_name:
names.append(current_name)
current_name = ""
if current_name:
names.append(current_name)
return names
def event_prediction(input_ticket_category, input_ticket_type, input_ticket_item, input_ticket_summary, input_ticket_desc):
try:
user_recommendation_list_tfidf = event_prediction_tfidf(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_list_context = event_prediction_context(input_ticket_category, input_ticket_type, input_ticket_item, input_ticket_summary, input_ticket_desc)
#print("Contexual Prediction Done")
# Combine the recommendations from both methods
user_recommendation_list = user_recommendation_list_tfidf ## Changes done here
user_recommendation_persons = []
for res in user_recommendation_list:
names = extract_names(res)
user_recommendation_persons.extend(names)
return user_recommendation_persons
except:
user_recommendation_list = []
return user_recommendation_list
I am getting the output as -
USer recommendation List from event_prediction_tfidf function : ['application hcm expenses claims expenses claims application function error submission form bb 604 l2 support Rupam Dhara', 'application hcm expenses claims expenses claims application function error submission form bb 604 l2 support Rupam Dhara', 'application hcm expenses claims expenses claims application function error error claiming 1414 l2 support Anisha Nandi', 'application hcm expenses claims expenses claims application function error error message submitting editing claims 1414 l2 support Anisha Nandi', 'application hcm expenses claims expenses claims application function error incorrect mailer sent 138 l2 support Jagdish Bangera']
TFIDF Prediction Done ['application hcm expenses claims expenses claims application function error submission form bb 604 l2 support Rupam Dhara', 'application hcm expenses claims expenses claims application function error submission form bb 604 l2 support Rupam Dhara', 'application hcm expenses claims expenses claims application function error error claiming 1414 l2 support Anisha Nandi', 'application hcm expenses claims expenses claims application function error error message submitting editing claims 1414 l2 support Anisha Nandi', 'application hcm expenses claims expenses claims application function error incorrect mailer sent 138 l2 support Jagdish Bangera']
User Recommendations: ['Rupam Dhara', 'Rupam Dhara', 'Anisha Nandi', 'Anisha Nandi', 'Jagdish Bangera']
I want to extract the 604 as well as l2 support along with name of person.
The final output should be-
User Recommendations: [[602,'l2 support','Rupam Dhara',],.. [..]]