Exemplo n.º 1
0
 def _create_example(self, lines, set_type):
     examples = []
     for (i, line) in enumerate(lines):
         guid = "%s-%s" % (set_type, i)
         text_a = tokenization.convert_to_unicode(line[1])
         text_b = tokenization.convert_to_unicode(line[2])
         label = tokenization.convert_to_unicode(line[0])
         examples.append(InputExample(
             guid=guid, text_a=text_a, text_b=text_b, label=label))
     return examples
 def _create_example(self, lines, set_type):
     examples = []
     for (i, line) in enumerate(lines):
         guid = "%s-%s" % (set_type, i)
         text = tokenization.convert_to_unicode(line[1])
         label = tokenization.convert_to_unicode(line[0])
         # if i == 0:
         #     print('label: ', label)
         examples.append(InputExample(guid=guid, text=text, label=label))
     return examples
 def _create_example(self, lines, set_type):
     examples = []
     for (i, line) in enumerate(lines):
         guid = "%s-%s" % (set_type, i)
         text_a = tokenization.convert_to_unicode(line[0])
         # 多标签分类的label
         label = np.zeros(shape=[50], dtype=np.int32)
         l_list = line[1].strip().split(' ')
         for l in l_list:
             label[self.labels.index(l)] = 1
         examples.append(InputExample(
             guid=guid, text_a=text_a, text_b=None, label=label))
     return examples
Exemplo n.º 4
0
  def _create_examples(self, df, set_type):
    """Creates examples for the training and dev sets."""
        #         lines 
    #         [
    #         ['O  O O O B-LOC B-LOC O B-LOC B- O O', '你 好 啊 啊 啊 啊 '],
    #         ['O  O O O B-LOC B-LOC O B-LOC B- O O', '你 好 啊 啊 啊 啊 ']
    #         ]
    #         """
        
    examples = []

    for (i, line) in df.iterrows():
       
      # if i == 0:
      #   continue
      guid = "%s-%s" % (set_type, i)
      texts = tokenization.convert_to_unicode(line['texts'])
      label = tokenization.convert_to_unicode(line['labels'])
     
      examples.append(
          InputExample(guid=guid, text=texts, label=label))
    return examples