docs: def modified_ngram_precision(references, pred, n):
      '''
      Borrowed from the ntlk BLEU implementation:
      http://www.nltk.org/_modules/nltk/translate/bleu_score.html
  
      >>> modified_ngram_precision([['the', 'fat', 'cat', 'the', 'rat']],
      ...                          ['the', 'the', 'the', 'the', 'the'], 1)
      (2, 5)
      >>> modified_ngram_precision([['the', 'fat', 'cat', 'the', 'rat']],
      ...                          ['the', 'fat', 'the', 'rat'], 2)
      (2, 3)
      '''
      counts = Counter(iter_ngrams(pred, n))
      max_counts = {}
      for reference in references:
          reference_counts = Counter(iter_ngrams(reference, n))
          for ngram in counts:
              max_counts[ngram] = max(max_counts.get(ngram, 0),
                                      reference_counts[ngram])
  
      clipped_counts = {ngram: min(count, max_counts[ngram])
                        for ngram, count in counts.items()}
  
      numerator = sum(clipped_counts.values())
      denominator = sum(counts.values())
      return numerator, denominator