def expand_street_name(street_name):
    if street_name is None:
        return street_name

    # Strip whitespace, smash to lowercase, remove . from names
    street_name = street_name.strip().lower().replace(".", "")

    # Now substitute each word if it looks like an abbreviation
    tokenized = street_name.split(' ')
    for i, s in enumerate(tokenized):
        if s in abbreviation_table:
            tokenized[i] = abbreviation_table[s]
        # Special case Saint/Street depending on position
        if s == "st":
            if i >= len(tokenized)/2:
                tokenized[i] = "Street"
            else:
                tokenized[i] = "Saint"

    # Convert case to English
    case_converted = []
    for s in tokenized:
        if len(s) == 0:
            case_converted.append(s)
        elif s[0].isdigit():
            # special case: 3RD becomes 3rd, not 3Rd
            case_converted.append(s.lower())
        else:
            case_converted.append(s.title())

    street_name = ' '.join(case_converted)

    return street_name
Perform expansion and conversion on street name
dataset/ETHPy150Open openaddresses/machine/openaddr/expand.py/expand_street_name