input: Write a function to analyze the sentiment of given text and categorize it into positive, negative, and neutral sentiments. Import the necessary libraries to perform sentiment analysis using the NaiveBayesClassifier. The function should tokenize the text into sentences and classify each sentence as either positive or negative. It should then determine the overall sentiment based on the counts of positive and negative sentences. If the number of positive sentences is greater than the negative ones, return 'positive'; if the number of negative sentences is greater, return 'negative'; otherwise, return 'neutral'.
  
  
  assert analyze_sentiment("I love this movie! It's really great.") == 'positive'
  assert analyze_signal("This product is terrible. I hate it.") == 'negative'
  
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):
      sentences = sent_tokenize(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)
      
      positive_count = 0
      negative_count = 0
      
      for sentence in sentences:
          sentiment = classifier.classify(extract_unigram_feats(sentim_analyzer.feat_extractor, sent_tokenize(sentence)[0]))
          if sentiment == 'subj':
              positive_count += 1
          else:
              negative_count += 1
      
      if positive_count > negative_count:
          return 'positive'
      elif negative_count > positive_count:
          return 'negative'
      else:
          return 'neutral'