# Path: search/config.py
# MATCH_WEIGHT = 0.2
# DIST_WEIGHT = 0.8
# THRESHOLD = 0.75
# MIN_WORD_LENGTH = 3
# STR_SPLIT_REGEX = r'\W+'


import re
from search import config

    Args:
        values(iterable): Values to average, either `int` or `float`
        weights(iterable): Matching weights iterable

    Returns:
        float: weighted average

    """
    if len(values) != len(weights):
        raise ValueError(
            'Values and Weights length do not match for weighted average')
    val = sum(m * w for m, w in zip(values, weights))
    weights = sum(weights)
    return val / weights


def tokenize(string):
    """
    Given a string return a list of segments of the string,
    splitted with :any:`config.STR_SPLIT_REGEX`, removing every word <=
    :any:`config.MIN_WORD_LENGTH`.

    Example:
        >>> utils.tokenize('hello there, how are you')
        ['hello', 'there']

    """
    return [
        w for w in re.split(config.STR_SPLIT_REGEX, string)

# Path: search/config.py
# MATCH_WEIGHT = 0.2
# DIST_WEIGHT = 0.8
# THRESHOLD = 0.75
# MIN_WORD_LENGTH = 3
# STR_SPLIT_REGEX = r'\W+'


# Path: search/utils.py
import re
from search import config


    Args:
        values(iterable): Values to average, either `int` or `float`
        weights(iterable): Matching weights iterable

    Returns:
        float: weighted average

    """
    if len(values) != len(weights):
        raise ValueError(
            'Values and Weights length do not match for weighted average')
    val = sum(m * w for m, w in zip(values, weights))
    weights = sum(weights)
    return val / weights


def tokenize(string):
    """
    Given a string return a list of segments of the string,
    splitted with :any:`config.STR_SPLIT_REGEX`, removing every word <=
    :any:`config.MIN_WORD_LENGTH`.

    Example:
        >>> utils.tokenize('hello there, how are you')
        ['hello', 'there']

    """
    return [
        w for w in re.split(config.STR_SPLIT_REGEX, string)

        if len(w) > config.MIN_WORD_LENGTH