input: Write a function to analyze the sentiment of a given text. The function should categorize the text into 'positive', 'negative', and 'neutral' sentiments. The function should use the nltk library for tokenizing sentences and performing sentiment analysis. If the number of positive sentences is greater than the number of negative sentences, the sentiment should be categorized as 'positive'. If the number of negative sentences is greater than the number of positive sentences, the sentiment should be categorized as 'negative'. If the number of positive and negative sentences is equal, the sentiment should be categorized as 'neutral'. If the input text is empty, the function should return 'neutral'.
  
  import nltk
  from nltk.tokenize import sent_tokenize
  from nltk.classify import NaiveBayesClassifier
  
  def analyze_sentiment(text):
      sents = sent_tokenize(text)
      neg = 0
      pos = 0
      for sentence in sents:
          sentiment_analysis = NaiveBayesClassifier.classify(sentence)
          if sentiment_analysis == 'neg':
              neg += 1
          if sentiment_analysis == 'pos':
              pos += 1
      
      if neg > pos:
          sentiment = 'negative'
      elif pos > neg:
          sentiment = 'positive'
      else:
          sentiment = 'neutral'
      
      return sentiment
  
  assert analyze_sentiment("I love this movie! It's really amazing.") == 'positive'
  assert analyze_sentiment("I hate waiting in line. It's so annoying.") == 'negative'
  assert analyze_sentiment("The weather is neither good nor bad today.") == 'neutral'
  assert analyze_sentiment("") == 'neutral'
output: def analyze_sentiment(text):
      if not text:
          return 'neutral'
      
      sents = sent_tokenize(text)
      neg = 0
      pos = 0
      
      for sentence in sents:
          words = nltk.word_tokenize(sentence)
          tagged = nltk.pos_tag(words)
          sentiment = nltk.sentiment.util.extract_unigram_feats(tagged, ['happy', 'sad'])
          if sentiment.get('happy', 0) > sentiment.get('sad', 0):
              pos += 1
          elif sentiment.get('sad', 0) > sentiment.get('happy', 0):
              neg += 1
      
      if neg > pos:
          return 'negative'
      elif pos > neg:
          return 'positive'
      else:
          return 'neutral'