tessl install tessl/pypi-python-levenshtein@0.27.0Python compatibility wrapper for computing string edit distances and similarities using fast Levenshtein algorithms.
Agent Success
Agent success rate when using this tile
88%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.38x
Baseline
Agent success rate without this tile
64%
Build a tool that finds consensus strings from collections of text variants, useful for normalizing user-generated content with spelling variations.
You need to implement a function that analyzes a collection of text strings and identifies a representative "consensus" string that best represents the group. This is particularly useful when you have multiple variations of the same text (due to typos, different spellings, or minor differences) and need to find the most representative version.
The consensus string should be the one that minimizes the total edit distance to all strings in the collection, treating the collection as a set where order doesn't matter.
Implement a function find_consensus(strings) that:
# Example 1: Finding consensus among product names
variants = ["iPhone", "iFone", "IPhone", "iphone"]
consensus = find_consensus(variants)
# Should return a string that minimizes distance to all variants
# Example 2: Normalizing user input
user_inputs = ["hello world", "helo world", "hello wrld", "hello world"]
consensus = find_consensus(user_inputs)
# Should return the most representative string@generates
def find_consensus(strings):
"""
Finds a consensus string from a collection of string variants.
Args:
strings: A list of strings to analyze
Returns:
A string that represents the consensus of the input collection,
minimizing total edit distance to all input strings
"""
passProvides string edit distance and similarity computation capabilities, including specialized functions for finding representative strings from collections.
@satisfied-by