input: Write a python function to summarize a text using NLTK, including sentence tokenization, word tokenization, stemming, and stop word removal. Use sentence scores to determine the top n sentences for the summary.
  assert summarize("These are some words. These are some more words. These are even more words. Here is a summary sentence.") == "These are some words. Here is a summary sentence."
  assert summarize("This is a test sentence. Another test sentence. Yet another test sentence. This one should be included in summary.") == "This is a test sentence. This one should be included in summary."
  assert summarize("Python is a programming language. It is widely used. NLTK is a toolkit for NLP. This is a summary of the text.") == "Python is a programming language. This is a summary of the text."
output: def summarize(text, n=2):
      import nltk
      from nltk.corpus import stopwords
      from nltk.tokenize import sent_tokenize, word_tokenize
      from nltk.stem import PorterStemmer
      from collections import defaultdict
  
      nltk.download('punkt')
      nltk.download('stopwords')
  
      # Tokenize sentences
      sentences = sent_tokenize(text)
      
      # Tokenize words and process
      ps = PorterStemmer()
      stop_words = set(stopwords.words('english'))
      
      word_frequencies = defaultdict(int)
      for sentence in sentences:
          words = word_tokenize(sentence.lower())
          for word in words:
              if word.isalnum() and word not in stop_words:
                  stemmed_word = ps.stem(word)
                  word_frequencies[stemmed_word] += 1
  
      # Compute sentence scores
      sentence_scores = defaultdict(int)
      for sentence in sentences:
          words = word_tokenize(sentence.lower())
          for word in words:
              if word.isalnum() and word not in stop_words:
                  stemmed_word = ps.stem(word)
                  if stemmed_word in word_frequencies:
                      sentence_scores[sentence] += word_frequencies[stemmed_word]
  
      # Get top n sentences
      summary_sentences = sorted(sentence_scores, key=sentence_scores.get, reverse=True)[:n]
      summary = ' '.join(summary_sentences)
      
      return summary