I have a set
cities = {'london', 'paris', 'tokyo', 'new york', 'new york city', 'san francisco'}
and a string
user_input = 'london new yorQ Sity berlin pariX'
How can I return a list
result = ['london', 'new york city', 'berlin', 'paris']
The typos are at most 2 edit distance away from the original city name. If the cities had 1-word length, then this would be an easy problem. How can I do this when cities have multiple words?
Note that the algorithm specifically chose new york city instead of new york.