parameters: (s)
return_statement: return s2
docstring: Apply a set of standard transformations to string to produce an
      abbreviation no more than 4 characters long.
docstring_summary: Apply a set of standard transformations to string to produce an
      abbreviation no more than 4 characters long.
docstring_tokens: Apply a set of standard transformations to string to produce an abbreviation no more than 4 characters long .
function: def abbreviate(s):
      """Apply a set of standard transformations to string to produce an
      abbreviation no more than 4 characters long.
      """
      if not s:
          return ''
      # check the cache
      if s in abbreviate.abbreviations:
          return abbreviate.abbreviations[s]
      # anything less than 4 characters doesn't need
      # an abbreviation
      if len(s) < 4:
          # update cache
          abbreviate.abbreviations[s] = s
          return s
      # save the first character in case it's a vowel
      s1 = s[0]
      s2 = s[1:]
      if s.endswith('ing'):
          # strip off the 'ing'
          s2 = s2[:-3]
      # reduce all doubled characters to one
      s2 = ''.join(c for c, _ in groupby(s2))
      # remove all vowels
      s2 = s2.translate(None, "AEIOUaeiou")
      # shorten remaining consonants to 4 characters
      # and add the first char back to the front
      s2 = s1 + s2[:4]
      # update cache
      abbreviate.abbreviations[s] = s2
      return s2
function_tokens: def abbreviate ( s ) : if not s : return '' # check the cache if s in abbreviate . abbreviations : return abbreviate . abbreviations [ s ] # anything less than 4 characters doesn't need # an abbreviation if len ( s ) < 4 : # update cache abbreviate . abbreviations [ s ] = s return s # save the first character in case it's a vowel s1 = s [ 0 ] s2 = s [ 1 : ] if s . endswith ( 'ing' ) : # strip off the 'ing' s2 = s2 [ : - 3 ] # reduce all doubled characters to one s2 = '' . join ( c for c , _ in groupby ( s2 ) ) # remove all vowels s2 = s2 . translate ( None , "AEIOUaeiou" ) # shorten remaining consonants to 4 characters # and add the first char back to the front s2 = s1 + s2 [ : 4 ] # update cache abbreviate . abbreviations [ s ] = s2 return s2