def get_left_tokens(cand: DataPoint) -> DataPoint: """ Returns tokens in the length 3 window to the left of the person mentions """ # TODO: need to pass window as input params window = 3 end = cand.person1_word_idx[0] cand.person1_left_tokens = cand.tokens[0:end][-1 - window:-1] end = cand.person2_word_idx[0] cand.person2_left_tokens = cand.tokens[0:end][-1 - window:-1] return cand
def get_left_tokens(cand: DataPoint) -> DataPoint: """ Returns tokens in the three length window to the left of entity mentions. :param cand: A candidate DF. :return: Candidate DF with two new columns, each a list of tokens to the left of entities. """ # TODO: make window a parameter window = 3 end = cand.person1_word_idx[0] cand.person1_left_tokens = cand.tokens[0:end][1 - window: -1] end = cand.person2_word_idx[0] cand.person2_left_tokens = cand.tokens[0:end][1 - window: -1] return cand