input: Write a function to classify text documents into two classes: positive and negative using a Naive Bayes classifier. The function should take a single text document as input and return the classification label. The function should be trained on the provided sample data before making predictions. If no text is provided, the function should return None.
  assert classify_text("This is a great movie!")=='positive'
  assert classify_text("This movie was terrible")=='negative'
  assert classify_text("This movie was ok")==None
  assert classify_text("This movie was terrible")==None
output: def classify_text(text):
      if not text:
          return None
      sample_data = {
          "positive": ["This is a great movie!", "I loved this movie", "This movie was fantastic"],
          "negative": ["This movie was terrible", "I hated this movie", "This movie was awful"]
      }
      word_counts = {"positive": {}, "negative": {}}
      total_words = {"positive": 0, "negative": 0}
      
      for label, texts in sample_data.items():
          for doc in texts:
              for word in doc.split():
                  if word not in word_counts[label]:
                      word_counts[label][word] = 0
                  word_counts[label][word] += 1
                  total_words[label] += 1
      
      def calculate_probability(word, label):
          if word in word_counts[label]:
              return word_counts[label][word] / total_words[label]
          return 1 / total_words[label]
      
      def classify(text):
          words = text.split()
          pos_prob = sum(math.log(calculate_probability(word, "positive")) for word in words)
          neg_prob = sum(math.log(calculate_probability(word, "negative")) for word in words)
          return "positive" if pos_prob > neg_prob else "negative"
      
      return classify(text)