input: Write a function to train an AI model in Python that classifies emails from the Enron Spam Dataset as either spam or non-spam. The function should load the dataset, split it into training and testing sets, create a bag of words model, train an SVM classifier, and finally, print the precision score of the model.
  assert train_spam_classifier("spam.csv", encoding='iso-8859-1')==0.98
  assert train_spam_classifier("non_existing_file.csv", encoding='iso-8859-1')==None
output: def train_spam_classifier(file_path, encoding='iso-8859-1'):
      try:
          import pandas as pd
          from sklearn.model_selection import train_test_split
          from sklearn.feature_extraction.text import CountVectorizer
          from sklearn.svm import SVC
          from sklearn.metrics import precision_score
          
          df = pd.read_csv(file_path, encoding=encoding)
          X_train, X_test, y_train, y_test = train_test_split(df['text'], df['label'], test_size=0.2, random_state=42)
          
          vectorizer = CountVectorizer()
          X_train_vec = vectorizer.fit_transform(X_train)
          X_test_vec = vectorizer.transform(X_test)
          
          svm_classifier = SVC(kernel='linear')
          svm_classifier.fit(X_train_vec, y_train)
          
          y_pred = svm_classifier.predict(X_test_vec)
          precision = precision_score(y_test, y_pred, pos_label='spam')
          
          return precision
      except Exception as e:
          return None