def IsWord(match, exceptions):
  """Determine if a match is a word.

  Args:
    match: re.Match Object
    exceptions: tuple of (str->bool, str->bool), functions that will return true
      if the letter before and after the match (respectively) indicate this
      match is not a word per se but instead part of a larger word.

  Returns:
    True if a match is a word; False otherwise.
  """

  before_exception, after_exception = exceptions
  before_index = match.start() - 1
  if before_index >= 0:
    if before_exception(match.string[before_index]):
      return False
  # NB(dbentley): match.end() is the character after the end already
  after_index = match.end()
  if after_index < len(match.string):
    if after_exception(match.string[after_index]):
      return False

  return True