bert_max_doc_str_max_str_pos_clean_doc_noise_doc/run_doc_qa.py
def make_fixed_length(start_position_list, end_position_list,
                          answer_index_list):
        """Returns three fixed length lists: start, end, and mask."""
        if start_position_list is None:
            return None, None, None, None

        # Truncates possible answers if there are too many possibles.
        len_ans = min(len(start_position_list), FLAGS.max_short_answers)

        # Initializes all lists.
        position_mask = [1 if kk < len_ans else 0
                         for kk in xrange(FLAGS.max_short_answers)]
        start_positions = list(position_mask)
        end_positions = list(position_mask)
        answer_indices = list(position_mask)

        for ii, (start, end, ans_ind) in enumerate(itertools.islice(
                itertools.izip(start_position_list, end_position_list,
                               answer_index_list), len_ans)):
            start_positions[ii] = start
            end_positions[ii] = end
            answer_indices[ii] = ans_ind

        if not start_position_list:
            raise ValueError("No answer positions!")

        return start_positions, end_positions, position_mask, answer_indices
Returns three fixed length lists: start, end, and mask.
Returns three fixed length lists: start, end, and mask.
Returns three fixed length lists : start end and mask .
def make_fixed_length(start_position_list, end_position_list,
                          answer_index_list):
        if start_position_list is None:
            return None, None, None, None
        len_ans = min(len(start_position_list), FLAGS.max_short_answers)
        position_mask = [1 if kk < len_ans else 0
                         for kk in xrange(FLAGS.max_short_answers)]
        start_positions = list(position_mask)
        end_positions = list(position_mask)
        answer_indices = list(position_mask)
        for ii, (start, end, ans_ind) in enumerate(itertools.islice(
                itertools.izip(start_position_list, end_position_list,
                               answer_index_list), len_ans)):
            start_positions[ii] = start
            end_positions[ii] = end
            answer_indices[ii] = ans_ind
        if not start_position_list:
            raise ValueError("No answer positions!")
        return start_positions, end_positions, position_mask, answer_indices
def make_fixed_length ( start_position_list , end_position_list , answer_index_list ) : if start_position_list is None : return None , None , None , None len_ans = min ( len ( start_position_list ) , FLAGS . max_short_answers ) position_mask = [ 1 if kk < len_ans else 0 for kk in xrange ( FLAGS . max_short_answers ) ] start_positions = list ( position_mask ) end_positions = list ( position_mask ) answer_indices = list ( position_mask ) for ii , ( start , end , ans_ind ) in enumerate ( itertools . islice ( itertools . izip ( start_position_list , end_position_list , answer_index_list ) , len_ans ) ) : start_positions [ ii ] = start end_positions [ ii ] = end answer_indices [ ii ] = ans_ind if not start_position_list : raise ValueError ( "No answer positions!" ) return start_positions , end_positions , position_mask , answer_indices
Returns three fixed length lists: start, end, and mask.
Returns three fixed length lists : start end and mask .
"""Returns three fixed length lists: start, end, and mask.""" # Truncates possible answers if there are too many possibles. # Initializes all lists.
start_position_list
end_position_list
answer_index_list