import math


def extract_length(**kwargs):
    """
    Extract length measures (tokens and chars; linear and log) on whole query.

    Returns:
        (function) A feature extraction function that takes a query and \
            returns number of tokens and characters on linear and log scales
    """
    del kwargs

    def _extractor(query, resources):
        del resources
        tokens = len(query.normalized_tokens)
        chars = len(query.normalized_text)
        return {
            "tokens": tokens,
            "chars": chars,
            "tokens_log": math.log(tokens + 1),
            "chars_log": math.log(chars + 1),
        }

    return _extractor