code: def check_and_clean_text(
      args,
      words,
      ngrams,
      text,
      start_position,
      text_buf_ngram_free,
      text_buf,
      local_ngram,
  ):
      seq = " ".join(words)
      if seq in ngrams:
          print(" [matched]: {}".format(seq), flush=True)
  
          if args.get_ngram_freq_only:
              # increase freq of this seq and then only consider the later part
              # of the text for further processing
              if seq in local_ngram:
                  local_ngram[seq] += 1
              else:
                  local_ngram[seq] = 1
              # print(" [increased]: {} {}".format(seq, ngrams[seq]), flush=True)
              if (start_position + len(seq) + 1) < len(text):
                  text_buf.append(
                      text[start_position + len(seq) + 1 : len(text)]
                  )
              return False
  
          # split the text
          text_first, text_second = split_text(
              text, start_position, args.remove_char_each_side, seq
          )
  
          # first part of ngrams free
          if len(text_first) > args.filter_text_char_len:
              text_buf_ngram_free.append(text_first)
  
          # add second part for further processing
          if len(text_second) > args.filter_text_char_len:
              text_buf.append(text_second)
  
          return False  # not ngram free
  
      # ngram free
      return True
  
imports: import argparse
  from functools import partial
  import json
  import multiprocessing
  import nltk
  import pickle
  import re
  import string
  import sys
  import time
label_desc: Use image node_id 3 for calling a global function with example usage: check_and_clean_text(args, words, ngrams, text, start_position, text_buf_ngram_free, text_buf, local_ngram) and returns: True, False, False