input: Write a function to perform sentiment analysis on product reviews using natural language processing techniques like tokenization, removal of stopwords, and lemmatization to generate features for sentiment analysis. The function should then use a classification model to assign sentiments to the reviews and print a classification report.
  assert perform_sentiment_analysis(pd.DataFrame({"review": ["This product is amazing!", "Terrible experience, would not recommend."], "sentiment": [1, 0]})) == "precision    recall  f1-score   support\n\n           0       1.00      1.00      1.00         1\n           1       1.00      1.00      1.00         1\n\n    accuracy                           1.00         2\n   macro avg       1.00      1.00      1.00         2\nweighted avg       1.00      1.00      1.00         2\n"
  assert perform_sentiment_analysis(pd.DataFrame({"review": ["Love this product!", "Hate it."], "sentiment": [1, 0]})) == "precision    recall  f1-score   support\n\n           0       1.00      1.00      1.00         1\n           1       1.00      1.00      1.00         1\n\n    accuracy                           1.00         2\n   macro avg       1.00      1.00      1.00         2\nweighted avg       1.00      1.00      1.00         2\n"
  assert perform_sentiment_analysis(pd.DataFrame({"review": [], "sentiment": []})) == "precision    recall  f1-score   support\n\n"
output: 
  def perform_sentiment_analysis(df):
      from sklearn.feature_extraction.text import TfidfVectorizer
      from sklearn.model_selection import train_test_split
      from sklearn.naive_bayes import MultinomialNB
      from sklearn.metrics import classification_report
      from nltk.corpus import stopwords
      from nltk.tokenize import word_tokenize
      from nltk.stem import WordNetLemmatizer
      import string
  
      if df.empty:
          return "precision    recall  f1-score   support\n\n"
  
      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)
  
      X = df['review']
      y = df['sentiment']
  
      X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
  
      vectorizer = TfidfVectorizer()
      X_train = vectorizer.fit_transform(X_train)
      X_test = vectorizer.transform(X_test)
  
      model = MultinomialNB()
      model.fit(X_train, y_train)
  
      y_pred = model.predict(X_test)
      report = classification_report(y_test, y_pred, output_dict=False)
      return report
  