search.utilsΒΆ

Utility module for the search engine

Contains various functions to do common operations on strings and iterables, such as normalization, tokenization, averages, splitting and walking through the elements of the iterable/string.

Functions

max_distance(sequence, idx) Given a list an int in range(len(sequence)), determine the maximum amount of movements available from that index position in the list.
normalize(iterable) Normalize an iterable of numbers in a series that sums up to 1.
position_similarity
scale_to_one(iterable) Scale an iterable of numbers proportionally such as the highest number
slider
splitter(string, chunk_size) Generator function that returns chunks of string of size chunk_size.
tokenize(string[, regexp, min_len]) Given a string return a list of segments of the string, splitted with config.STR_SPLIT_REGEX, removing every word < config.MIN_WORD_LENGTH.
weighted_average(values[, weights]) Calculate the weighted mean average between two iterables of values and matching weights.