Generate the spelling correction file form token_folder and save to spelling_file

def write_spelling(token_folder, spelling_file):
    """
    Generate the spelling correction file form token_folder and save to spelling_file
    """
    token_pattern = r'[a-z]{3,}'
    tokens = []
    for base, dirlist, fnlist in os.walk(token_folder):
        for fn in fnlist:
            fp = os.path.join(base, fn)
            with open(fp) as f:
                toks = re.findall(token_pattern, f.read())
                tokens.extend(toks)

    token_ranked, _ = zip(*Counter(tokens).most_common())
    with open(spelling_file, 'w') as f:
        f.write('\n'.join(token_ranked))