@hook.command('pig', 'piglatin')
def piglatin(text):
 global pronunciations
 if (not pronunciations):
  return 'Please wait, getting NLTK ready!'
 words = []
 for word in text.split():
  if (word[(-1)] in string.punctuation):
   end = word[(-1)]
   word = word[:(-1)]
  else:
   end = ''
  out_word = translate(word)
  if (word.isupper() and (not (word == 'I'))):
   out_word = out_word.upper()
  elif word[0].isupper():
   out_word = out_word.title()
  else:
   out_word = out_word.lower()
  words.append((out_word + end))
 if text.isupper():
  return ' '.join(words).upper()
 else:
  return ' '.join(words)

@ hook . command ( 'pig' , 'piglatin' ) def piglatin ( text ) : global pronunciations if ( not pronunciations ) : return 'Please wait, getting NLTK ready!' words = [ ] for word in text . split ( ) : if ( word [ ( - 1 ) ] in string . punctuation ) : end = word [ ( - 1 ) ] word = word [ : ( - 1 ) ] else : end = '' out_word = translate ( word ) if ( word . isupper ( ) and ( not ( word == 'I' ) ) ) : out_word = out_word . upper ( ) elif word [ 0 ] . isupper ( ) : out_word = out_word . title ( ) else : out_word = out_word . lower ( ) words . append ( ( out_word + end ) ) if text . isupper ( ) : return ' ' . join ( words ) . upper ( ) else : return ' ' . join ( words )
pig <text> -- converts <text> to pig latin .