input: Write a function to analyze the sentiment of given text and categorize it into positive, negative, and neutral sentiments. The function should use the NaiveBayesClassifier from nltk for sentiment analysis. If negative sentiment sentences outnumber positive, categorize the text as negative. If positive sentiment sentences outnumber negative, categorize it as positive. If they are equal, categorize the text as neutral.
  assert analyze_sentiment("I love this product very much!")=='positive'
  assert analyze_sentiment("I hate this product")=='negative'
  assert analyze_sentiment("This is a neutral statement")=='neutral'
output: 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)
      pos_count = 0
      neg_count = 0
      
      for sentence in sentences:
          sentiment = classifier.classify(extract_unigram_feats(word_tokenize(sentence), unigram_feats))
          if sentiment == 'subj':
              pos_count += 1
          else:
              neg_count += 1
      
      if pos_count > neg_count:
          return 'positive'
      elif neg_count > pos_count:
          return 'negative'
      else:
          return 'neutral'