def get_person_text(cand: DataPoint) -> DataPoint: """ Returns the text for the two person mentions in candidate """ person_names = [] for index in [1, 2]: field_name = "person{}_word_idx".format(index) start = cand[field_name][0] end = cand[field_name][1] + 1 person_names.append(" ".join(cand["tokens"][start:end])) cand.person_names = person_names return cand
def get_person_text(cand: DataPoint) -> DataPoint: """ Returns the text for the two person mentions in candidate sentence. :param cand: A candidate DF. :return: Candidate DF with new column, a list of entity names. """ person_names = [] for index in [1, 2]: field_name = "person{j}_word_idx".format(j=index) start = cand[field_name][0] end = cand[field_name][1] + 1 person_names.append(" ".join(cand["tokens"][start:end])) cand.person_names = person_names return cand