input: Write a function to perform sentiment analysis on product reviews using natural language processing techniques like tokenization and n-grams, and use a classification model to assign sentiments to the reviews. The function should read in the data from a CSV file, preprocess the reviews by tokenizing, removing stopwords, normalizing words, and generating features using CountVectorizer. It should then train a Multinomial Naive Bayes model on the training data and generate a classification report for the test predictions. Return the classification report as a string.
  assert perform_sentiment_analysis("reviews.csv")==classification_report
  assert perform_sentiment_analysis("empty_reviews.csv")=="No data to process"
  assert perform_sentiment_analysis("missing_reviews.csv")=="File not found"
  assert perform_sentiment_analysis("invalid_reviews.csv")=="Invalid data format"
output: def perform_sentiment_analysis(file_path):
      import pandas as pd
      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
      from nltk.corpus import stopwords
      from nltk.tokenize import word_tokenize
      import string
      import os
  
      try:
          df = pd.read_csv(file_path)
      except FileNotFoundError:
          return "File not found"
      except pd.errors.EmptyDataError:
          return "No data to process"
      except pd.errors.ParserError:
          return "Invalid data format"
  
      if df.empty:
          return "No data to process"
  
      def preprocess(text):
          tokens = word_tokenize(text.lower())
          tokens = [word for word in tokens if word.isalpha() and word not in stopwords.words('english')]
          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 = CountVectorizer(ngram_range=(1, 2))
      X_train_vec = vectorizer.fit_transform(X_train)
      X_test_vec = vectorizer.transform(X_test)
  
      model = MultinomialNB()
      model.fit(X_train_vec, y_train)
  
      y_pred = model.predict(X_test_vec)
      report = classification_report(y_test, y_pred)
  
      return report