docs: def _add_expansion_to_acronym_dict(acronym, expansion, level, dictionary):
      """Add an acronym to the dictionary.
  
      Takes care of avoiding duplicates and keeping the expansion marked with
      the best score.
      """
      if len(acronym) >= len(expansion) or acronym in expansion:
          return
  
      for punctuation in re.findall("\W", expansion):
          # The expansion contains non-basic punctuation. It is probable
          # that it is invalid. Discard it.
          if punctuation not in (",", " ", "-"):
              return False
  
      if acronym in dictionary:
          add = True
          for stored_expansion, stored_level in dictionary[acronym]:
              if _equivalent_expansions(stored_expansion, expansion):
                  if level < stored_level:
                      dictionary[acronym].remove(
                          (stored_expansion, stored_level))
                      break
                  else:
                      add = False
          if add:
              dictionary[acronym].append((expansion, level))
              return True
      else:
          dictionary.setdefault(acronym, []).append((expansion, level))
          return True
  
      return False