input: Write a function to perform sentiment analysis on product reviews using natural language processing techniques like tokenization, stopword removal, lemmatization, and n-grams. The function should generate features for sentiment analysis using CountVectorizer and use a multinomial Naive Bayes classifier to assign sentiments to the reviews. If the input data is empty, the function should return a message indicating no data.
  assert sentiment_analysis(pd.DataFrame({'review': ["This product is amazing!", "Terrible experience."], 'sentiment': ['positive', 'negative']}))
  assert sentiment_analysis(pd.DataFrame({'review': [], 'sentiment': []}))=='No data to analyze'
output: def sentiment_analysis(df):
      if df.empty:
          return 'No data to analyze'
      
      from sklearn.feature_extraction.text import CountVectorizer
      from sklearn.naive_bayes import MultinomialNB
      from sklearn.pipeline import make_pipeline
      from nltk.corpus import stopwords
      from nltk.tokenize import word_tokenize
      from nltk.stem import WordNetLemmatizer
      import string
  
      stop_words = set(stopwords.words('english'))
      lemmatizer = WordNetLemmatizer()
  
      def preprocess(text):
          tokens = word_tokenize(text.lower())
          tokens = [lemmatizer.lemmatize(word) for word in tokens if word.isalpha() and word not in stop_words]
          return ' '.join(tokens)
  
      df['review'] = df['review'].apply(preprocess)
  
      model = make_pipeline(CountVectorizer(ngram_range=(1, 2)), MultinomialNB())
      model.fit(df['review'], df['sentiment'])
  
      return model