code: def clean_term_strings(terms: Iterable[str]) -> Iterable[str]:
      """
      Clean up a sequence of single- or multi-word terms as strings:
      strip leading/trailing junk chars, handle dangling parens and odd hyphenation,
      and normalize whitespace.
  
      Args:
          terms: Sequence of terms such as "environment", "plastic pollution",
              or "fossil fuel industry" that may be _unclean_ for whatever reason.
  
      Yields:
          Next term in ``terms`` but with the cruft cleaned up, excluding terms
          that were entirely cruft
  
      Warning:
          Terms with (intentionally) unusual punctuation may get "cleaned"
          into a form that changes or obscures the original meaning of the term.
      """
      # get rid of leading/trailing junk characters
      terms = (
          constants.RE_LEAD_TAIL_CRUFT_TERM.sub("", term)
          for term in terms
      )
      terms = (
          constants.RE_LEAD_HYPHEN_TERM.sub(r"\1", term)
          for term in terms
      )
      # handle dangling/backwards parens, don't allow '(' or ')' to appear alone
      terms = (
          ""
          if term.count(")") != term.count("(")
          or term.find(")") < term.find("(")
          else term
          if "(" not in term
          else constants.RE_DANGLING_PARENS_TERM.sub(r"\1\2\3", term)
          for term in terms
      )
      # handle oddly separated hyphenated words
      terms = (
          term
          if "-" not in term
          else constants.RE_NEG_DIGIT_TERM.sub(
              r"\1\2",
              constants.RE_WEIRD_HYPHEN_SPACE_TERM.sub(r"\1", term),
          )
          for term in terms
      )
      # handle oddly separated apostrophe'd words
      terms = (
          constants.RE_WEIRD_APOSTR_SPACE_TERM.sub(r"\1\2", term)
          if "'" in term
          else term
          for term in terms
      )
      # normalize whitespace
      terms = (
          constants.RE_NONBREAKING_SPACE.sub(" ", term).strip()
          for term in terms
      )
      for term in terms:
          if re.search(r"\w", term):
              yield term
  
file_path: textacy/src/textacy/extract/utils.py
imports: from __future__ import annotations
  import itertools
  import operator
  import re
  from typing import Callable, Collection, Iterable, Optional
  from cytoolz import itertoolz
  from spacy.tokens import Doc, Token
  from ..None import constants, errors, types, utils
  from .None import matches
label_desc: Use image node_id 2 for calling a global function with example usage: clean_term_strings(terms) without return types