code: def is_good_snippet(snippet, len_range, min_text_frac, exclude_en):
      """
      Args:
          snippet (str)
          len_range (Tuple[int, int])
          min_text_frac (float)
          exclude_en (bool)
  
      Returns:
          bool
      """
      len_snippet = len(snippet)
      if len_snippet < len_range[0] or len_snippet >= len_range[1]:
          return False
      # make sure snippet is *mostly* text
      len_text = sum(
          match.end() - match.start()
          for match in re_text.finditer(snippet)
      )
      if len_text / len_snippet < min_text_frac:
          return False
      # ugh, math and urls!
      if any(
          s in snippet
          for s in (r"\displaystyle", "http://", "https://")
      ):
          return False
      # check for citations/references
      if any(
          re_pat.search(snippet)
          for re_pat in (re_doi, re_issn, re_isbn)
      ):
          return False
      # filter out english copy-paste jobs
      if exclude_en is True:
          is_reliable, _, best_guesses = cld2_detect(
              snippet.encode("utf-8"), bestEffort=True
          )
          if is_reliable is True and best_guesses[0][1] == "en":
              logging.debug(
                  "found english-heavy snippet in non-english wiki text:\n%s",
                  snippet,
              )
              return False
      return True
  
file_path: textacy/scripts/fetch_wiki_lang_snippets.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import argparse
  import datetime
  import io
  import logging
  import os
  import random
  import re
  import sys
  import time
  import warnings
  import wikipedia
  from cld2 import detect
  from tqdm import tqdm
label_desc: Use image node_id 6 for calling a global function with example usage: is_good_snippet(snippet, len_range, min_text_frac, exclude_en) and returns: True, False, False, False, False, False