Exemple #1
0
def compare(city):
    res = []
    city = city.lower()
    cities = parse_table(open("cities1000.txt", "rb"))
    for c in cities:
        comp = Comparator(city, c[1].lower())
        subseq = comp.longest_substring()
        if len(subseq) > 1:
            res.append((len(subseq), c[2], float(c[4]), float(c[5])))
    return sorted(res, reverse=True)
Exemple #2
0
def compare(city, limit=1):
    res = []
    city = city.lower()
    cities = parse_table(open("cities1000.txt"))
    for i in cities:
        comp = Comparator(city, i[1].lower())
        subseq = comp.longest_substring()
        if len(subseq) > limit:
            res.append((len(subseq), i[2], float(i[4]), float(i[5])))
    return sorted(res, reverse=True)