tools/accuracy_checker/accuracy_checker/metrics/machine_translation.py
def _get_ngrams(segment, max_order):
    """Extracts all n-grams upto a given maximum order from an input segment.
    Args:
        segment: text segment from which n-grams will be extracted.
        max_order: maximum length in tokens of the n-grams returned by this
        methods.
    Returns:
        The Counter containing all n-grams upto max_order in segment
        with a count of how many times each n-gram occurred.
    """
    ngram_counts = Counter()
    for order in range(1, max_order + 1):
        for i in range(0, len(segment) - order + 1):
            ngram = tuple(segment[i:i+order])
            ngram_counts[ngram] += 1

    return ngram_counts
Extracts all n-grams upto a given maximum order from an input segment.
    Args:
        segment: text segment from which n-grams will be extracted.
        max_order: maximum length in tokens of the n-grams returned by this
        methods.
    Returns:
        The Counter containing all n-grams upto max_order in segment
        with a count of how many times each n-gram occurred.
    
Extracts all n-grams upto a given maximum order from an input segment.
Args:
segment: text segment from which n-grams will be extracted.
max_order: maximum length in tokens of the n-grams returned by this
methods.
Returns:
The Counter containing all n-grams upto max_order in segment
with a count of how many times each n-gram occurred.
Extracts all n - grams upto a given maximum order from an input segment . Args : segment : text segment from which n - grams will be extracted . max_order : maximum length in tokens of the n - grams returned by this methods . Returns : The Counter containing all n - grams upto max_order in segment with a count of how many times each n - gram occurred .
def _get_ngrams(segment, max_order):
    ngram_counts = Counter()
    for order in range(1, max_order + 1):
        for i in range(0, len(segment) - order + 1):
            ngram = tuple(segment[i:i+order])
            ngram_counts[ngram] += 1
    return ngram_counts
def _get_ngrams ( segment , max_order ) : ngram_counts = Counter ( ) for order in range ( 1 , max_order + 1 ) : for i in range ( 0 , len ( segment ) - order + 1 ) : ngram = tuple ( segment [ i : i + order ] ) ngram_counts [ ngram ] += 1 return ngram_counts
Extracts all n-grams upto a given maximum order from an input segment.
Extracts all n - grams upto a given maximum order from an input segment .
"""Extracts all n-grams upto a given maximum order from an input segment.
    Args:
        segment: text segment from which n-grams will be extracted.
        max_order: maximum length in tokens of the n-grams returned by this
        methods.
    Returns:
        The Counter containing all n-grams upto max_order in segment
        with a count of how many times each n-gram occurred.
    """
segment
max_order