def _compute_precision(references, translation, n):
    """Compute ngram precision.

    Parameters
    ----------
    references: list(list(str))
        A list of references.
    translation: list(str)
        A translation.
    n: int
        Order of n-gram.

    Returns
    -------
    matches: int
        Number of matched nth order n-grams
    candidates
        Number of possible nth order n-grams
    """
    matches = 0
    candidates = 0
    ref_ngram_counts = Counter()

    for reference in references:
        ref_ngram_counts |= _ngrams(reference, n)
    trans_ngram_counts = _ngrams(translation, n)
    overlap_ngram_counts = trans_ngram_counts & ref_ngram_counts
    matches += sum(overlap_ngram_counts.values())
    possible_matches = len(translation) - n + 1
    if possible_matches > 0:
        candidates += possible_matches

    return matches, candidates