def calculate_similar_score_keywords(mentees, mentors): mentor_keywords = get_keyword_list(mentors) mentee_keywords = get_keyword_list(mentees) glove = Glove(mentor_keywords + mentee_keywords) scores = [] for mentee_keyword, mentee in zip(mentee_keywords, mentees): glove_result = glove.get_score(mentee_keyword) scores.append(glove_result) return scores
def calculate_similar_score_flipped(mentees, mentors): mentor_keywords = get_keyword_list(mentors) mentee_contents = [mentee.content for mentee in mentees] glove = Glove(mentee_contents) scores = [] for mentee_keyword, mentee in zip(mentor_keywords, mentees): glove_result = glove.get_score(mentee_keyword) scores.append(glove_result) return scores
def reward_similarity_keyword_multiple_keywords_glove(matrix, mentees, mentors, score=0, **kwargs): mentor_keywords = get_keyword_list(mentors) mentee_keywords = get_keyword_list(mentees) all_mentee_keywords = [] for i, mentor in enumerate(mentors): for j, mentee in enumerate(mentees): all_mentee_keywords.append(str(mentee_keywords)) glove_result = glove_score_1v1(mentor_keywords, all_mentee_keywords) average = sum(glove_result) / len(glove_result) # Take result from glove and act accordingly for j, mentee in enumerate(mentees): if glove_result[j] > average: matrix[i][j] += score return matrix
def reward_similarity_keywords_to_texts_new(matrix, mentees, mentors, score=0, **kwargs): result_matrix = get_or_calculate_cache("glove_cache_new_{}.json".format( global_vars.ROUND), calculate_similar_score_new, mentees=mentees, mentors=mentors) first = True mentee_keywords = get_keyword_list(mentees) for mentee_idx, (mentee_scores, keyword) in enumerate(zip(result_matrix, mentee_keywords)): if first: first = False continue if keyword == ['nan']: continue # print(keyword) if isinstance(mentee_scores, float): continue try: top_5 = sorted(range(len(mentee_scores)), key=lambda i: mentee_scores[i])[-6:] except TypeError as e: print("Something went wrong") continue for index in top_5: if index > len(mentors): continue matrix[index][mentee_idx] += score return matrix