input: Write a function to perform sentiment analysis on product reviews. The function should use natural language processing techniques such as tokenization, stopword removal, lemmatization, and n-gram generation to create features for sentiment classification. The function should then train a Multinomial Naive Bayes classification model on the features and evaluate the model's performance using a classification report.
  def sentiment_analysis(filename):
      import numpy as np
      import pandas as pd
      import nltk
      from nltk.tokenize import word_tokenize
      import matplotlib.pyplot as plt
      from nltk.corpus import stopwords
      from nltk.stem import WordNetLemmatizer 
      from sklearn.feature_extraction.text import CountVectorizer
      from sklearn.model_selection import train_test_split
      from sklearn.naive_bayes import MultinomialNB
      from sklearn.metrics import classification_report
  
      # Read in the data
      data = pd.read_csv(filename)
  
      # Tokenise the texts
      data['tokenised'] = data['review'].apply(word_tokenize)
  
      # Remove stopwords
      stop_words = set(stopwords.words('english'))
      data['filtered'] = data['tokenised'].apply(lambda x: [val for val in x if val not in stop_words])
  
      # Normalize words
      wordnet_lemmatizer = WordNetLemmatizer()
      data['normalised'] = data['filtered'].apply(lambda x: [wordnet_lemmatizer.lemmatize(val) for val in x])
  
      # Generate features using CountVectorizer
      cv = CountVectorizer()
      data['features'] = cv.fit_transform(data['normalised'].astype('str')).toarray()
  
      # Split into training and test sets
      X = data['features']
      y = data['sentiment']
      X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
  
      # Train model
      model = MultinomialNB(alpha=0.1)
      model.fit(X_train, y_train)
  
      # Predict using the test set
      predictions = model.predict(X_test)
  
      # Generate a classification report
      report = classification_report(y_test, predictions)
      return report
  
  assert sentiment_analysis('reviews.csv') is not None
  assert 'precision' in sentiment_analysis('reviews.csv')
  assert 'recall' in sentiment_analysis('reviews.csv')
  assert 'f1-score' in sentiment_analysis('reviews.csv')
  assert 'support' in sentiment_analysis('reviews.csv')
output: 
  def sentiment_analysis(filename):
      import numpy as np
      import pandas as pd
      import nltk
      from nltk.tokenize import word_tokenize
      from nltk.corpus import stopwords
      from nltk.stem import WordNetLemmatizer 
      from sklearn.feature_extraction.text import CountVectorizer
      from sklearn.model_selection import train_test_split
      from sklearn.naive_bayes import MultinomialNB
      from sklearn.metrics import classification_report
  
      data = pd.read_csv(filename)
      data['tokenised'] = data['review'].apply(word_tokenize)
      stop_words = set(stopwords.words('english'))
      data['filtered'] = data['tokenised'].apply(lambda x: [val for val in x if val not in stop_words])
      wordnet_lemmatizer = WordNetLemmatizer()
      data['normalised'] = data['filtered'].apply(lambda x: [wordnet_lemmatizer.lemmatize(val) for val in x])
      cv = CountVectorizer()
      data['features'] = cv.fit_transform(data['normalised'].astype('str')).toarray()
      X = data['features']
      y = data['sentiment']
      X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
      model = MultinomialNB(alpha=0.1)
      model.fit(X_train, y_train)
      predictions = model.predict(X_test)
      report = classification_report(y_test, predictions)
      return report
  