code: def rouge_n(evaluated_sentences, reference_sentences, n=2):
      
      if len(evaluated_sentences) <= 0 or len(reference_sentences) <= 0:
          raise ValueError("Collections must contain at least 1 sentence.")
  
      evaluated_ngrams = _get_word_ngrams(n, evaluated_sentences)
      reference_ngrams = _get_word_ngrams(n, reference_sentences)
      reference_count = len(reference_ngrams)
      evaluated_count = len(evaluated_ngrams)
  
      # Gets the overlapping ngrams between evaluated and reference
      overlapping_ngrams = evaluated_ngrams.intersection(reference_ngrams)
      overlapping_count = len(overlapping_ngrams)
  
      # Handle edge case. This isn't mathematically correct, but it's good enough
      if evaluated_count == 0:
          precision = 0.0
      else:
          precision = overlapping_count / evaluated_count
  
      # Handle edge case for recall, same as for precision
      if reference_count == 0:
          recall = 0.0
      else:
          recall = overlapping_count / reference_count
      f1_score = 2.0 * ((precision * recall) / (precision + recall + 1e-8))
  
      # return overlapping_count / reference_count
      return f1_score, precision, recall
docs: Computes ROUGE-N of two text collections of sentences.
      Sourece: http://research.microsoft.com/en-us/um/people/cyl/download/
      papers/rouge-working-note-v1.3.1.pdf
  
      Args:
        evaluated_sentences: The sentences that have been picked by the summarizer
        reference_sentences: The sentences from the referene set
        n: Size of ngram.  Defaults to 2.
  
      Returns:
        A tuple (f1, precision, recall) for ROUGE-N
  
      Raises:
        ValueError: raises exception if a param has len <= 0