(doc_or_tokens: types.DocOrTokens, min_ttr: float = 0.72)
return statistics.mean(
        [_mtld_run(words, min_ttr), _mtld_run(reversed(words), min_ttr)]
    )
Compute the Measure of Textual Lexical Diversity (MTLD) of ``doc_or_tokens``,
    the average length of the longest consecutive sequences of words that maintain a TTR
    of at least ``min_ttr``.

    Higher values indicate higher lexical diversity.

    Args:
        doc_or_tokens: If a spaCy ``Doc``, non-punctuation tokens (words) are extracted;
            if an iterable of spaCy ``Token`` s, all non-punct elements are used.
        min_ttr: Minimum TTR for each segment in ``doc_or_tokens``. When an ongoing
            segment's TTR falls below this value, a new segment is started.
            Value should be in the range [0.66, 0.75].

    References:
        McCarthy, P. M., & Jarvis, S. (2010). MTLD, vocd-D, and HD-D: A validation study
        of sophisticated approaches to lexical diversity assessment. Behavior research
        methods, 42(2), 381-392.
Compute the Measure of Textual Lexical Diversity (MTLD) of ``doc_or_tokens``,
    the average length of the longest consecutive sequences of words that maintain a TTR
    of at least ``min_ttr``.
Compute the Measure of Textual Lexical Diversity ( MTLD ) of doc_or_tokens the average length of the longest consecutive sequences of words that maintain a TTR of at least min_ttr .
def mtld(doc_or_tokens: types.DocOrTokens, min_ttr: float = 0.72) -> float:
    """
    Compute the Measure of Textual Lexical Diversity (MTLD) of ``doc_or_tokens``,
    the average length of the longest consecutive sequences of words that maintain a TTR
    of at least ``min_ttr``.

    Higher values indicate higher lexical diversity.

    Args:
        doc_or_tokens: If a spaCy ``Doc``, non-punctuation tokens (words) are extracted;
            if an iterable of spaCy ``Token`` s, all non-punct elements are used.
        min_ttr: Minimum TTR for each segment in ``doc_or_tokens``. When an ongoing
            segment's TTR falls below this value, a new segment is started.
            Value should be in the range [0.66, 0.75].

    References:
        McCarthy, P. M., & Jarvis, S. (2010). MTLD, vocd-D, and HD-D: A validation study
        of sophisticated approaches to lexical diversity assessment. Behavior research
        methods, 42(2), 381-392.
    """
    words = tuple(utils.get_words(doc_or_tokens))
    return statistics.mean(
        [_mtld_run(words, min_ttr), _mtld_run(reversed(words), min_ttr)]
    )
def mtld ( doc_or_tokens : types . DocOrTokens , min_ttr : float = 0.72 ) -> float : words = tuple ( utils . get_words ( doc_or_tokens ) ) return statistics . mean ( [ _mtld_run ( words , min_ttr ) , _mtld_run ( reversed ( words ) , min_ttr ) ] )