input: Write a function to analyze the sentiment of a given text and categorize it into positive, negative, or neutral sentiments. The function should use NLTK to tokenize the text into sentences and classify each sentence using the NaiveBayesClassifier. Finally, it should return the predominant sentiment ('positive', 'negative', or 'neutral').
  assert analyze_sentiment("I love this product. It is amazing!") == 'positive'
  assert analyze_sentiment("I hate this product. It is terrible!") == 'negative'
  assert analyze_sentiment("The product is neither good nor bad.") == 'neutral'
  assert analyze_sentiment("This is a neutral sentence.") == 'neutral'
  assert analyze_sentiment("Wow! This is fantastic.") == 'positive'
output: from nltk.tokenize import sent_tokenize
  from nltk.classify import NaiveBayesClassifier
  from nltk.corpus import subjectivity
  from nltk.sentiment import SentimentAnalyzer
  from nltk.sentiment.util import *
  
  def analyze_sentiment(text):
      n_instances = 100
      subj_docs = [(sent, 'subj') for sent in subjectivity.sents(categories='subj')[:n_instances]]
      obj_docs = [(sent, 'obj') for sent in subjectivity.sents(categories='obj')[:n_instances]]
      train_data = subj_docs + obj_docs
      sentim_analyzer = SentimentAnalyzer()
      all_words_neg = sentim_analyzer.all_words([mark_negation(doc) for doc in train_data])
      unigram_feats = sentim_analyzer.unigram_word_feats(all_words_neg, min_freq=4)
      sentim_analyzer.add_feat_extractor(extract_unigram_feats, unigrams=unigram_feats)
      training_set = sentim_analyzer.apply_features(train_data)
      trainer = NaiveBayesClassifier.train
      classifier = sentim_analyzer.train(trainer, training_set)
      
      sentences = sent_tokenize(text)
      sentiments = [classifier.classify(dict([token, True] for token in sentim_analyzer.extract_features(sent))) for sent in sentences]
      
      positive_count = sentiments.count('subj')
      negative_count = sentiments.count('obj')
      
      if positive_count > negative_count:
          return 'positive'
      elif negative_count > positive_count:
          return 'negative'
      else:
          return 'neutral'