(ex_index, example, label_list, max_seq_length,
                                   tokenizer)
return feature_list
Converts a single `InputExample` into a single `InputFeatures`.
Converts a single `InputExample` into a single `InputFeatures`.
Converts a single InputExample into a single InputFeatures .
def convert_example_list_for_inews(ex_index, example, label_list, max_seq_length,
                                   tokenizer):
  """Converts a single `InputExample` into a single `InputFeatures`."""

  if isinstance(example, PaddingInputExample):
    return [InputFeatures(
        input_ids=[0] * max_seq_length,
        input_mask=[0] * max_seq_length,
        segment_ids=[0] * max_seq_length,
        label_id=0,
        is_real_example=False)]

  label_map = {}
  for (i, label) in enumerate(label_list):
    label_map[label] = i

  tokens_a = tokenizer(example.text_a)
  tokens_b = None
  if example.text_b:
    tokens_b = tokenizer(example.text_b)
    must_len = len(tokens_a) + 3
    extra_len = max_seq_length - must_len
  feature_list = []
  if example.text_b and extra_len > 0:
    extra_num = int((len(tokens_b) - 1) / extra_len) + 1
    for num in range(extra_num):
      max_len = min((num + 1) * extra_len, len(tokens_b))
      tokens_b_sub = tokens_b[num * extra_len: max_len]
      feature = convert_single_example_for_inews(
          ex_index, tokens_a, tokens_b_sub, label_map, max_seq_length, tokenizer, example)
      feature_list.append(feature)
  else:
    feature = convert_single_example_for_inews(
        ex_index, tokens_a, tokens_b, label_map, max_seq_length, tokenizer, example)
    feature_list.append(feature)
  return feature_list
def convert_example_list_for_inews ( ex_index , example , label_list , max_seq_length , tokenizer ) : if isinstance ( example , PaddingInputExample ) : return [ InputFeatures ( input_ids = [ 0 ] * max_seq_length , input_mask = [ 0 ] * max_seq_length , segment_ids = [ 0 ] * max_seq_length , label_id = 0 , is_real_example = False ) ] label_map = { } for ( i , label ) in enumerate ( label_list ) : label_map [ label ] = i tokens_a = tokenizer ( example . text_a ) tokens_b = None if example . text_b : tokens_b = tokenizer ( example . text_b ) must_len = len ( tokens_a ) + 3 extra_len = max_seq_length - must_len feature_list = [ ] if example . text_b and extra_len > 0 : extra_num = int ( ( len ( tokens_b ) - 1 ) / extra_len ) + 1 for num in range ( extra_num ) : max_len = min ( ( num + 1 ) * extra_len , len ( tokens_b ) ) tokens_b_sub = tokens_b [ num * extra_len : max_len ] feature = convert_single_example_for_inews ( ex_index , tokens_a , tokens_b_sub , label_map , max_seq_length , tokenizer , example ) feature_list . append ( feature ) else : feature = convert_single_example_for_inews ( ex_index , tokens_a , tokens_b , label_map , max_seq_length , tokenizer , example ) feature_list . append ( feature ) return feature_list