(
    doc_or_tokens: types.DocOrTokens,
    variant: Literal["herdan", "summer", "dugast"] = "herdan",
)
Compute the logarithmic Type-Token Ratio (TTR) of ``doc_or_tokens``,
    a modification of TTR that uses log functions to better adapt for text length.

    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.
        variant: Particular variant of log-TTR.
            - "herdan" => ``log(n_types) / log(n_words)``
            - "summer" => ``log(log(n_types)) / log(log(n_words))``
            - "dugast" => ``log(n_words) ** 2 / (log(n_words) - log(n_types))``

    Note:
        All variants of this measure are slightly sensitive to document length,
        so values from texts with different lengths should be compared with care.

        The popular Maas variant of log-TTR is simply the reciprocal of Dugast's:
        ``(log(n_words) - log(n_types)) / log(n_words) ** 2``. It isn't included
        as a variant because its interpretation differs: *lower* values
        indicate higher lexical diversity.

    References:
        - Herdan, G. (1964). Quantitative linguistics. London: Butterworths.
        - Somers, H. H. (1966). Statistical methods in literary analysis. In J. Leeds
          (Ed.), The computer and literary style (pp. 128-140). Kent, OH: Kent
          State University.
        - Dugast, D. (1978). Sur quoi se fonde la notion d’étendue théoretique du
          vocabulaire? Le Français Moderne, 46, 25-32.
Compute the logarithmic Type-Token Ratio (TTR) of ``doc_or_tokens``,
    a modification of TTR that uses log functions to better adapt for text length.
Compute the logarithmic Type - Token Ratio ( TTR ) of doc_or_tokens a modification of TTR that uses log functions to better adapt for text length .
def log_ttr(
    doc_or_tokens: types.DocOrTokens,
    variant: Literal["herdan", "summer", "dugast"] = "herdan",
) -> float:
    """
    Compute the logarithmic Type-Token Ratio (TTR) of ``doc_or_tokens``,
    a modification of TTR that uses log functions to better adapt for text length.

    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.
        variant: Particular variant of log-TTR.
            - "herdan" => ``log(n_types) / log(n_words)``
            - "summer" => ``log(log(n_types)) / log(log(n_words))``
            - "dugast" => ``log(n_words) ** 2 / (log(n_words) - log(n_types))``

    Note:
        All variants of this measure are slightly sensitive to document length,
        so values from texts with different lengths should be compared with care.

        The popular Maas variant of log-TTR is simply the reciprocal of Dugast's:
        ``(log(n_words) - log(n_types)) / log(n_words) ** 2``. It isn't included
        as a variant because its interpretation differs: *lower* values
        indicate higher lexical diversity.

    References:
        - Herdan, G. (1964). Quantitative linguistics. London: Butterworths.
        - Somers, H. H. (1966). Statistical methods in literary analysis. In J. Leeds
          (Ed.), The computer and literary style (pp. 128-140). Kent, OH: Kent
          State University.
        - Dugast, D. (1978). Sur quoi se fonde la notion d’étendue théoretique du
          vocabulaire? Le Français Moderne, 46, 25-32.
    """
    n_words, n_types = utils.compute_n_words_and_types(utils.get_words(doc_or_tokens))
    try:
        if variant == "herdan":
            return math.log10(n_types) / math.log10(n_words)
        elif variant == "summer":
            return math.log10(math.log10(n_types)) / math.log10(math.log10(n_words))
        elif variant == "dugast":
            log10_n_words = math.log10(n_words)
            return (log10_n_words ** 2) / (log10_n_words - math.log10(n_types))
        else:
            raise ValueError(
                errors.value_invalid_msg(
                    "variant", variant, {"herdan", "summer", "dugast"}
                )
            )
    except ZeroDivisionError:
        return 0.0
def log_ttr ( doc_or_tokens : types . DocOrTokens , variant : Literal [ "herdan" , "summer" , "dugast" ] = "herdan" , ) -> float : n_words , n_types = utils . compute_n_words_and_types ( utils . get_words ( doc_or_tokens ) ) try : if variant == "herdan" : return math . log10 ( n_types ) / math . log10 ( n_words ) elif variant == "summer" : return math . log10 ( math . log10 ( n_types ) ) / math . log10 ( math . log10 ( n_words ) ) elif variant == "dugast" : log10_n_words = math . log10 ( n_words ) return ( log10_n_words ** 2 ) / ( log10_n_words - math . log10 ( n_types ) ) else : raise ValueError ( errors . value_invalid_msg ( "variant" , variant , { "herdan" , "summer" , "dugast" } ) ) except ZeroDivisionError : return 0.0