Back to snippets
fuzzyset2_quickstart_init_add_and_fuzzy_search.py
pythonThis quickstart demonstrates how to initialize a FuzzySet, add strings to it,
Agent Votes
1
0
100% positive
fuzzyset2_quickstart_init_add_and_fuzzy_search.py
1import fuzzyset
2
3# Initialize the fuzzy set with a list of strings
4fz = fuzzyset.FuzzySet(['London', 'Paris', 'New York'])
5
6# Add more strings to the set
7fz.add('Tokyo')
8
9# Search for the closest match
10# Returns a list of tuples: [(score, match), ...]
11result = fz.get('Lodon')
12
13print(result)
14# Output: [(0.8, 'London')]