input: Write a python function to preprocess text by tokenizing, removing stopwords, and applying stemming, then assert the function with some test cases.
  assert preprocess_text("This is a sample text.") == ['sampl', 'text']
  assert preprocess_text("NLTK and Python are great for text processing.") == ['nltk', 'python', 'great', 'text', 'process']
  assert preprocess_text("Natural Language Processing with Python.") == ['natur', 'languag', 'process', 'python']
output: def preprocess_text(text):
      import nltk
      from nltk.corpus import stopwords
      from nltk.tokenize import word_tokenize
      from nltk.stem import PorterStemmer
  
      nltk.download('punkt')
      nltk.download('stopwords')
  
      stop_words = set(stopwords.words('english'))
      ps = PorterStemmer()
  
      word_tokens = word_tokenize(text.lower())
      filtered_words = [ps.stem(w) for w in word_tokens if w.isalnum() and w not in stop_words]
  
      return filtered_words