code: def auto_label(
      input_texts,
      data_type,
      end_words=["。", ".", "?", "？", "!", "！"],
      mode="cn",
  ):
      writer = open(
          f"example_{mode}_{data_type}.txt", "w", encoding="utf8"
      )
      for input_text in input_texts:
          words = psg.cut(input_text)
  
          for word, pos in words:
              word, pos = word.strip(), pos.strip()
              if not (word and pos):
                  continue
  
              """ 如果是英文，需要转换成list，否则会按照Character级别遍历 """
              if mode == "en":
                  word = word.split(" ")
  
              """ 如果词性不是实体的标记，则打上O标记 """
              if pos not in label_set:
                  for char in word:
                      string = char + " " + "O" + "\n"
                      """ 在句子的结尾换行 """
                      if char in end_words:
                          string += "\n"
                      writer.write(string)
              else:
                  """如果词性是实体的标记，则打上BI标记"""
                  for i, char in enumerate(word):
                      if i == 0:
                          string = char + " " + "B-" + pos + "\n"
                      else:
                          string = char + " " + "I-" + pos + "\n"
                      writer.write(string)
  
file_path: DeepKE/example/ner/prepare-data/prepare_weaksupervised_data.py
imports: import os
  import random
  import jieba.posseg
  import jieba
  import csv
  import argparse
label_desc: Use image node_id 2 for calling a global function with example usage: auto_label(input_texts, data_type, end_words, mode) without return types