code: def mark_noun_phrases(
      corpus_file,
      marked_corpus_file,
      nlp_parser,
      lines_count,
      chunker,
      mark_char="_",
      grouping=False,
  ):
      i = 0
      with tqdm(total=lines_count) as pbar:
          for doc in nlp_parser.pipe(corpus_file, n_threads=-1):
              if "nlp_arch" in chunker:
                  spans = get_noun_phrases(doc)
              else:
                  spans = list(doc.noun_chunks)
              i += 1
              if len(spans) > 0:
                  span = spans.pop(0)
              else:
                  span = None
              span_written = False
              for token in doc:
                  if span is None:
                      if len(token.text.strip()) > 0:
                          marked_corpus_file.write(token.text + " ")
                  else:
                      if (
                          token.idx < span.start_char
                          or token.idx >= span.end_char
                      ):  # outside a
                          # span
                          if len(token.text.strip()) > 0:
                              marked_corpus_file.write(token.text + " ")
                      else:
                          if not span_written:
                              # mark NP's
                              if (
                                  len(span.text) > 1
                                  and span.lemma_ != "-PRON-"
                              ):
                                  if grouping:
                                      text = get_group_norm(span)
                                  else:
                                      text = span.text
                                  # mark NP's
                                  text = (
                                      text.replace(" ", mark_char)
                                      + mark_char
                                  )
                                  marked_corpus_file.write(text + " ")
                              else:
                                  marked_corpus_file.write(
                                      span.text + " "
                                  )
                              span_written = True
                          if (
                              token.idx + len(token.text)
                              == span.end_char
                          ):
                              if len(spans) > 0:
                                  span = spans.pop(0)
                              else:
                                  span = None
                              span_written = False
              marked_corpus_file.write("\n")
              pbar.update(1)
  
file_path: nlp-architect/solutions/set_expansion/prepare_data.py
imports: import gzip
  import json
  import logging
  from argparse import ArgumentParser
  from os import path, makedirs
  from tqdm import tqdm
  from nlp_architect import LIBRARY_OUT
  from nlp_architect.pipelines.spacy_np_annotator import NPAnnotator, get_noun_phrases
  from nlp_architect.utils.io import check_size, download_unlicensed_file, validate_parent_exists
  from nlp_architect.utils.text import spacy_normalizer, SpacyInstance
label_desc: Use image node_id 4 for calling a global function with example usage: mark_noun_phrases(corpus_file, marked_corpus_file, nlp_parser, lines_count, chunker, mark_char, grouping) without return types