code: def med_mentions_reader(
      directory_path: str, split: str
  ) -> Callable[[Language], Iterator[Example]]:
      train, dev, test = read_full_med_mentions(
          directory_path,
          label_mapping=None,
          span_only=True,
          spacy_format=True,
      )
  
      def corpus(nlp: Language) -> Iterator[Example]:
          if split == "train":
              original_examples = train
          elif split == "dev":
              original_examples = dev
          elif split == "test":
              original_examples = test
          else:
              raise Exception(f"Unexpected split {split}")
  
          for original_example in original_examples:
              doc = nlp.make_doc(original_example[0])
              with warnings.catch_warnings():
                  warnings.simplefilter("ignore", category=UserWarning)
                  spacy_example = Example.from_dict(
                      doc, original_example[1]
                  )
              yield spacy_example
  
      return corpus
  
file_path: scispacy/scispacy/base_project_code.py
imports: from typing import Optional, Callable, Iterable, Iterator
  from pathlib import Path
  import random
  import itertools
  import spacy
  import warnings
  from spacy.training import Corpus, Example
  from spacy.language import Language
  from scispacy.custom_tokenizer import combined_rule_tokenizer
  from scispacy.data_util import read_full_med_mentions, read_ner_from_tsv
label_desc: Use image node_id 4 for calling a global function with example usage: med_mentions_reader(directory_path, split) and returns: corpus