code: def convert_bsnlp(
      language, base_input_path, output_filename, split_filename=None
  ):
      """
      Converts the BSNLP dataset for the given language.
  
      If only one output_filename is provided, all of the output goes to that file.
      If split_filename is provided as well, 15% of the output chosen randomly
        goes there instead.  The dataset has no dev set, so this helps
        divide the data into train/dev/test.
      Note that the custom error fixes are only done for BG currently.
      Please manually correct the data as appropriate before using this
        for another language.
      """
      if language not in AVAILABLE_LANGUAGES:
          raise ValueError(
              "The current BSNLP datasets only include the following languages: %s"
              % ",".join(AVAILABLE_LANGUAGES)
          )
      if language != "bg":
          raise ValueError(
              "There were quite a few data fixes needed to get the data correct for BG.  Please work on similar fixes before using the model for %s"
              % language.upper()
          )
      pipeline = stanza.Pipeline(language, processors="tokenize")
      random.seed(1234)
  
      annotated_path = os.path.join(
          base_input_path, "annotated", "*", language, "*"
      )
      annotated_files = sorted(glob.glob(annotated_path))
      raw_path = os.path.join(
          base_input_path, "raw", "*", language, "*"
      )
      raw_files = sorted(glob.glob(raw_path))
  
      # if the instructions for downloading the data from the
      # process_ner_dataset script are followed, there will be two test
      # directories of data and a separate training directory of data.
      if len(annotated_files) == 0 and len(raw_files) == 0:
          logger.info("Could not find files in %s" % annotated_path)
          annotated_path = os.path.join(
              base_input_path, "annotated", language, "*"
          )
          logger.info("Trying %s instead" % annotated_path)
          annotated_files = sorted(glob.glob(annotated_path))
          raw_path = os.path.join(base_input_path, "raw", language, "*")
          raw_files = sorted(glob.glob(raw_path))
  
      if len(annotated_files) != len(raw_files):
          raise ValueError(
              "Unexpected differences in the file lists between %s and %s"
              % (annotated_files, raw_files)
          )
  
      for i, j in zip(annotated_files, raw_files):
          if os.path.split(i)[1][:-4] != os.path.split(j)[1][:-4]:
              raise ValueError(
                  "Unexpected differences in the file lists: found %s instead of %s"
                  % (i, j)
              )
  
      annotated_sentences = []
      if split_filename:
          split_sentences = []
      for annotated, raw in zip(annotated_files, raw_files):
          new_sentences = get_sentences(
              language, pipeline, annotated, raw
          )
          if not split_filename or random.random() < 0.85:
              annotated_sentences.extend(new_sentences)
          else:
              split_sentences.extend(new_sentences)
  
      write_sentences(output_filename, annotated_sentences)
      if split_filename:
          write_sentences(split_filename, split_sentences)
  
file_path: stanza/stanza/utils/datasets/ner/convert_bsnlp.py
imports: import argparse
  import glob
  import os
  import logging
  import random
  import re
  import stanza
label_desc: Use image node_id 5 for calling a global function with example usage: convert_bsnlp(language, base_input_path, output_filename, split_filename) without return types